Opened 19 years ago

Closed 19 years ago

#3115 closed enhancement (fixed)

HouseKeeper - Add cleanup of tvchain table

Reported by: gnome42@… Owned by: cpinkham
Priority: minor Milestone: unknown
Component: mythtv Version: head
Severity: low Keywords:
Cc: Ticket locked: no

Description

Housekeeping: HouseKeeper::CleanupOldLivetvChains(void)

Entries in the tvchain DB table are usually cleaned up properly, but occasionally if the frontend/backend crashes etc. there can be orphaned entries in the tvchain db table. This probably doesn't happen much for normal usage but livetv is used for testing a lot and many devs have many orphaned entries.

Attached is a housekeeping patch that cleans up any orphaned tvchains left in the table. It runs once a day and is fairly conservative in what it deletes. It only deletes tvchains that don't have any endtimes that are more recent than four hours ago. Seems to work fine here but needs review.

Attachments (4)

myth_clean_tvchain.diff (2.3 KB ) - added by gnome42@… 19 years ago.
housekeeper: cleanup tvchain table
myth_clean_tvchain2.diff (2.4 KB ) - added by gnome42@… 19 years ago.
update
myth_clean_tvchain3.diff (2.3 KB ) - added by gnome42@… 19 years ago.
Final update - Don't use TRUNCATE to protect against race with new livetv chain being created after the first select call and before the delete.
myth_clean_tvchain4.diff (2.3 KB ) - added by gnome42@… 19 years ago.
Give the function a more accurate name: CleanupOldLivetvChains() to CleanupOrphanedLivetvChains()

Download all attachments as: .zip

Change History (9)

by gnome42@…, 19 years ago

Attachment: myth_clean_tvchain.diff added

housekeeper: cleanup tvchain table

comment:1 by gnome42@…, 19 years ago

Please hold off on this, there may be a problem. I will re-open this ticket later.

by gnome42@…, 19 years ago

Attachment: myth_clean_tvchain2.diff added

update

comment:2 by gnome42@…, 19 years ago

Severity: mediumlow
Type: patchenhancement

I have added an updated version. It fixes two issues:

  • bindValue() was adding extra quoting that was causing problems. Switched to QString().
  • there was a small window between the two queries where a new livetv chain could be created and then erroneously deleted. The check against 'endtime' in the delete query should protect against that. (That points out another problem! I'll upload a third version shortly :)

by gnome42@…, 19 years ago

Attachment: myth_clean_tvchain3.diff added

Final update - Don't use TRUNCATE to protect against race with new livetv chain being created after the first select call and before the delete.

by gnome42@…, 19 years ago

Attachment: myth_clean_tvchain4.diff added

Give the function a more accurate name: CleanupOldLivetvChains() to CleanupOrphanedLivetvChains()

comment:3 by cpinkham, 19 years ago

Owner: changed from Isaac Richards to cpinkham

comment:4 by Janne Grunau, 19 years ago

Version: 0.20head

comment:5 by cpinkham, 19 years ago

Resolution: fixed
Status: newclosed

(In [13569]) Add a task to the housekeeper to cleanup orphaned LiveTV chains from the tvchain table.

Closes #3115 using slightly modified patch by gnome42.

Note: See TracTickets for help on using tickets.