[mythtv-users] duplicates in dtv_multiplex

Stephen Worthington stephen_agent at jsw.gen.nz
Fri Sep 22 08:55:44 UTC 2023


On Thu, 21 Sep 2023 10:39:21 -0700, you wrote:

>My dtv_multiplex table has a few cases where the same frequency
>appears in several mplexes:
>
>select mplexid, sourceid, transportid, networkid, frequency/1e6 as
>MHz, visible, hierarchy, serviceversion, updatetimestamp from
>dtv_multiplex order by frequency, updatetimestamp;
>MariaDB [mythconverg]>
>+---------+----------+-------------+-----------+------+---------+-----------+----------------+---------------------+
>| mplexid | sourceid | transportid | networkid | MHz  | visible |
>hierarchy | serviceversion | updatetimestamp     |
>+---------+----------+-------------+-----------+------+---------+-----------+----------------+---------------------+
>|      16 |        1 |         259 |      NULL |   79 |       0 | a
>     |             33 | 2022-09-21 13:28:35 |
>|       3 |        1 |         381 |      NULL |  207 |       0 | a
>     |             33 | 2022-09-19 21:03:42 |
>|       2 |        1 |         377 |      NULL |  207 |       0 | a
>     |             33 | 2023-09-10 13:53:37 |
>|       4 |        1 |         397 |      NULL |  213 |       0 | a
>     |             33 | 2022-09-19 21:03:42 |
>|       6 |        1 |         401 |      NULL |  213 |       0 | a
>     |             33 | 2023-02-25 11:44:37 |
>|       5 |        1 |        9739 |      NULL |  473 |       0 | a
>     |             33 | 2022-09-19 21:03:42 |
>|       7 |        1 |         385 |      NULL |  473 |       0 | a
>     |             33 | 2023-02-25 11:44:37 |
>|       8 |        1 |        4069 |      NULL |  515 |       0 | a
>     |             33 | 2022-09-19 21:03:42 |
>For example, mplexid's 3 and 2 refer to the same frequency.
>Is this likely to cause any trouble?
>If I take all the entries in the channel table that refer to mplexid 2
>and change them to mplexid 3, and then delete the row
>for mplexid 2 from the dtv_multiplex table, is that likely to cause
>any trouble (assuming I don't do it when when of the affected channels
>is recording)?
>
>Any direct change to these tables will put dtv_multiplex out of sync
>with the scan information in channelscan_dtv_multiplex.
>
>This situation arose because a program I wrote to handle channel
>packing and rearranging operates by rewriting the frequency of an
>existing plex; mplexid 2 was presumably using a different frequency.
>
>I realized my update procedure wasn't quite right, and noticed this
>problem while reviewing the code.  My thought is the code should be
>moving the channels between existing plexes, or creating a new plex if
>one doesn't exist.
>In particular some atsc_major channels are split across different
>plexes; a recent change split channels 4.1-4.5 across 3 different
>frequencies.

Dumping the database schema allows you to find all uses of the mplexid
name:

cd /tmp
sudo mysqldump --no-data mythconverg > schema.sql
less schema.sql
/mplexid

I can see it in these tables:

channel
channelscan_dtv_multiplex
dtv_multiplex
scan_channels

so if you want to fix everything, you would need to fix those four
tables.  However, I suspect that channelscan_dtv_multiplex and
scan_channels can be ignored as they are only used for channel
scanning, and you can just do a full scan the next time you need to do
a scan.

Yes, your code should not be changing the contents of dtv_multiplex
rows like that - if it needs one with a different frequency to the
existing ones, it should create a new one.  The only time you would
want to change the frequency of an existing dtv_multiplex row would be
if the entire multiplex had moved to a different frequency.


More information about the mythtv-users mailing list