Opened 14 years ago

Closed 13 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@… 14 years ago.
housekeeper: cleanup tvchain table
myth_clean_tvchain2.diff (2.4 KB) - added by gnome42@… 14 years ago.
update
myth_clean_tvchain3.diff (2.3 KB) - added by gnome42@… 14 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@… 14 years ago.
Give the function a more accurate name: CleanupOldLivetvChains?() to CleanupOrphanedLivetvChains?()

Download all attachments as: .zip

Change History (9)

Changed 14 years ago by gnome42@…

Attachment: myth_clean_tvchain.diff added

housekeeper: cleanup tvchain table

comment:1 Changed 14 years ago by gnome42@…

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

Changed 14 years ago by gnome42@…

Attachment: myth_clean_tvchain2.diff added

update

comment:2 Changed 14 years ago by gnome42@…

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 :)

Changed 14 years ago by gnome42@…

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.

Changed 14 years ago by gnome42@…

Attachment: myth_clean_tvchain4.diff added

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

comment:3 Changed 14 years ago by cpinkham

Owner: changed from Isaac Richards to cpinkham

comment:4 Changed 14 years ago by Janne Grunau

Version: 0.20head

comment:5 Changed 13 years ago by cpinkham

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.