find_orphans.py Fails

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
jamoody
Junior
Posts: 85
Joined: Mon Aug 18, 2014 4:19 pm
United States of America

find_orphans.py Fails

Post by jamoody »

Power failure caused database corruption so I restored from a backup 2 days old. The restored database works fine but is of course out of sync with recording files. Ran find_orphans (dated Nov 2011) which correctly identified the orphaned recording entries for recordings deleted since the backup was created. When I tried to tell find_orphans to delete these orphaned recording entries the script fails with the following traceback:

Are you sure you want to continue?
> yes
Traceback (most recent call last):
File "./find_orphans.py", line 230, in <module>
main()
File "./find_orphans.py", line 214, in main
opt[1](opt[2])
File "./find_orphans.py", line 129, in delete_recs
rec.delete(True, True)
File "/usr/lib/python2.7/dist-packages/MythTV/dataheap.py", line 365, in delete
return self.getProgram().delete(force, rerecord)
File "/usr/lib/python2.7/dist-packages/MythTV/dataheap.py", line 377, in getProgram
return Program.fromRecorded(self)
File "/usr/lib/python2.7/dist-packages/MythTV/mythproto.py", line 943, in fromRecorded
return be.getRecording(rec.chanid, rec.starttime)
File "/usr/lib/python2.7/dist-packages/MythTV/mythproto.py", line 644, in getRecording
return Program(res[1:], db=self.db)
File "/usr/lib/python2.7/dist-packages/MythTV/mythproto.py", line 872, in __init__
DictData.__init__(self, raw)
File "/usr/lib/python2.7/dist-packages/MythTV/altdict.py", line 147, in __init__
data = self._process(data)
File "/usr/lib/python2.7/dist-packages/MythTV/altdict.py", line 163, in _process
data = self._trans[self._field_type](v)
File "/usr/lib/python2.7/dist-packages/MythTV/altdict.py", line 103, in <lambda>
lambda x: datetime.fromtimestamp(x, datetime.UTCTZ())\
File "/usr/lib/python2.7/dist-packages/MythTV/utility/dt.py", line 304, in fromtimestamp
obj = super(datetime, cls).fromtimestamp(float(timestamp), tz)
ValueError: timestamp out of range for platform time_t

I recently moved to MythTV 028.-45. Any ideas on how to delete the bad entries from the database?
jamoody
Junior
Posts: 85
Joined: Mon Aug 18, 2014 4:19 pm
United States of America

Re: find_orphans.py Fails

Post by jamoody »

I updated my copy of find_orphans.py from https://www.mythtv.org/wiki/Find_orphans.py which was slightly different than the version I was using, but no change:

Traceback (most recent call last):
File "./find_orphans2.py", line 230, in <module>
main()
File "./find_orphans2.py", line 214, in main
opt[1](opt[2])
File "./find_orphans2.py", line 129, in delete_recs
rec.delete(True, True)
File "/usr/lib/python2.7/dist-packages/MythTV/dataheap.py", line 365, in delete
return self.getProgram().delete(force, rerecord)
File "/usr/lib/python2.7/dist-packages/MythTV/dataheap.py", line 377, in getProgram
return Program.fromRecorded(self)
File "/usr/lib/python2.7/dist-packages/MythTV/mythproto.py", line 943, in fromRecorded
return be.getRecording(rec.chanid, rec.starttime)
File "/usr/lib/python2.7/dist-packages/MythTV/mythproto.py", line 644, in getRecording
return Program(res[1:], db=self.db)
File "/usr/lib/python2.7/dist-packages/MythTV/mythproto.py", line 872, in __init__
DictData.__init__(self, raw)
File "/usr/lib/python2.7/dist-packages/MythTV/altdict.py", line 147, in __init__
data = self._process(data)
File "/usr/lib/python2.7/dist-packages/MythTV/altdict.py", line 163, in _process
data = self._trans[self._field_type](v)
File "/usr/lib/python2.7/dist-packages/MythTV/altdict.py", line 103, in <lambda>
lambda x: datetime.fromtimestamp(x, datetime.UTCTZ())\
File "/usr/lib/python2.7/dist-packages/MythTV/utility/dt.py", line 304, in fromtimestamp
obj = super(datetime, cls).fromtimestamp(float(timestamp), tz)
ValueError: timestamp out of range for platform time_t
jamoody
Junior
Posts: 85
Joined: Mon Aug 18, 2014 4:19 pm
United States of America

Re: find_orphans.py Fails

Post by jamoody »

Worked around the problem with find_orphans failing by manually creating the missing files (copied another recording to the missing file name) and then deleted the recording per usual in MythTV. Time consuming, but it worked. Hopefully someone will identify the problem with find_orphans and fix it eventually.
User avatar
pgbennett
Developer
Posts: 503
Joined: Mon Apr 27, 2015 5:41 pm
United States of America

Re: find_orphans.py Fails

Post by pgbennett »

If you have a recording in your database but the file is missing you should be able to find it in "watch recordings" on the frontend. It will not play and will show with a red border or something to indicate the file is missing, but you should be able to select "menu" and then delete it. After that you should check group "deleted" and delete again if it is there.
jamoody
Junior
Posts: 85
Joined: Mon Aug 18, 2014 4:19 pm
United States of America

Re: find_orphans.py Fails

Post by jamoody »

These orphaned entries were already in the deleted list at the time of the database backup with the files actually removed between the backup and restore. Automatic and manual removal of the orphaned entries from the System Status -> Auto Expire list failed and the entries remained in the Auto Expire list forever. Perhaps that is where an improvement can be made. Deleting orphaned entries for the Watch Recordings list works fine, but not from the Auto Expire list.
kb8qew
Newcomer
Posts: 2
Joined: Wed Jul 13, 2016 11:18 am
United States of America

Re: find_orphans.py Fails

Post by kb8qew »

If this helps,

find_orphans.py did not work for me. Then I looked at the permissions of the files it was trying to delete. It seems my backend was recording files as root. I did a chmod mythtv:mythtv and ran find_orphans.py again and it was successful in deleting the files.
User avatar
pgbennett
Developer
Posts: 503
Joined: Mon Apr 27, 2015 5:41 pm
United States of America

Re: find_orphans.py Fails

Post by pgbennett »

jamoody wrote:These orphaned entries were already in the deleted list at the time of the database backup with the files actually removed between the backup and restore. Automatic and manual removal of the orphaned entries from the System Status -> Auto Expire list failed and the entries remained in the Auto Expire list forever. Perhaps that is where an improvement can be made. Deleting orphaned entries for the Watch Recordings list works fine, but not from the Auto Expire list.
I did not see this response when you made it. You can select the "deleted" recording group in the Watch recordings screen and apply the process there.
Post Reply