Opened 17 years ago

Closed 16 years ago

#3865 closed defect (fixed)

inuseprograms table is not updated properly when using symlinks for storage directories

Reported by: anonymous Owned by: cpinkham
Priority: minor Milestone: 0.21
Component: mythtv Version: head
Severity: medium Keywords: inuseprograms symlink
Cc: Ticket locked: no

Description

The inuseprograms table is not updated when a new recording starts when the target storage directory is a symlink to the actual storage directory. The following error is printed in the backend's log:

INSERT INTO inuseprograms  (chanid, starttime, recusage, hostname, lastupdatetime, rechost, recdir )  VALUES  ('2025', '2007-08-20T14:13:00', 'recorder', 'horus', '2007-08-20T14:13:20',  'horus', NULL);
Driver error was [2/1048]:
QMYSQL3: Unable to execute query
Database error was:
Column 'recdir' cannot be null

The following code from programinfo.cpp - MarkAsInUse? will incorrectly detect the symlinked directory as a filename and cut off the last portion of the path. Using a filename such as '/video' will leave the pathname as null and the DB update fails.

        if (testFile.exists())
        {
            if (testFile.isFile() || testFile.isSymLink())
                recDir = pathname.section("/", 0, -2);
            else if (testFile.isDir())
                recDir = pathname;
        }
        else
        {
            testFile.setFile(pathname.section("/", 0, -2));
            if (testFile.exists() && testFile.isDir())
                recDir = testFile.filePath();
        }

Attachments (1)

mythtv_symlink.patch (772 bytes) - added by David Madsen <david.madsen@…> 17 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 17 years ago by David Madsen <david.madsen@…>

This was filed by me. I guess the field was cleared as I was formatting the ticket or something.

Changed 17 years ago by David Madsen <david.madsen@…>

Attachment: mythtv_symlink.patch added

comment:2 Changed 17 years ago by David Madsen <david.madsen@…>

The attached patch fixes this problem for me.

I haven't tested it extensively outside of my current setup.

The code will probably infinite loop if the symlink links back to itself, but if your recording dir is a recursive symlink there's bigger problems I guess.

comment:3 Changed 17 years ago by cpinkham

Owner: changed from Isaac Richards to cpinkham

comment:4 Changed 17 years ago by cpinkham

Resolution: fixed
Status: newclosed

(In [14546]) Modify ProgramInfo::MarkAsInUse? so that it follows symlinks trying to find the actual directory that is in use. Loosely based on a patch by David Madsen.

I believe this closes #3865 and #4019. If these issues reoccur, I will need more info to debug.

comment:5 Changed 16 years ago by anonymous

Resolution: fixed
Status: closedreopened

When using a slave back end (slack5) to run the 'flagger' the inuseprograms does not show the 'flagger':

INSERT INTO inuseprograms (chanid, starttime, recusage, hostname, lastupdatetime, rechost, recdir ) VALUES ('2042', '2007-10-06T09:34:00', 'flagger', 'slack7', '2007-10-06T09:34:54', 'slack5', NULL);

Driver error was [2/1048]: QMYSQL3: Unable to execute query Database error was: Column 'recdir' cannot be null

However when the flagger is running on the master back end (slack7) it is inserted into the inuseprograms as expected. Using svn 14579 (9-30-07).

comment:6 Changed 16 years ago by anonymous

Sorry....master back end is slack5 and slave is slack7.

comment:7 Changed 16 years ago by cpinkham

Milestone: unknown0.21

comment:8 Changed 16 years ago by cpinkham

Resolution: fixed
Status: newclosed

(In [15807]) Try to make sure that the pathname we're dealing with in ProgramInfo::MarkAsInUse?() is an actual filename. Some places don't set ProgramInfo::pathname because they don't need to, so this code makes sure we can put the right recdir in the inuseprograms table for the Storage Groups scheduling code to work properly.

I believe this fixes #3865.

Note: See TracTickets for help on using tickets.