Impossible to continue aborted scan

Bug #1425705 reported by Max Linke
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mixxx
Fix Released
High
Max Linke

Bug Description

When i abort a library scan it is impossible to continue at a later point. The scanner just thinks that I have scanned everything

Debug [LibraryScanner 1]: LibraryScanner::slotStartScan
Debug [LibraryScanner 1]: upgrade filename is "/home/kain88/.mixxx/DBUPGRADED"
Debug [LibraryScanner 1]: Committing transaction on "LIBRARY_SCANNER" result: true
Debug [LibraryScanner 1]: Legacy importer took 0 ms
Debug [LibraryScanner 1]: Recursively scanning library.
Debug [LibraryScanner 1]: LibraryScanner::slotFinishScan
Debug [LibraryScanner 1]: Recursive scanning finished cleanly.
Debug [LibraryScanner 1]: Committing transaction on "LIBRARY_SCANNER" result: true
Debug [LibraryScanner 1]: Marking tracks in changed directories as verified
Debug [LibraryScanner 1]: Marking unchanged directories and tracks as verified
Debug [LibraryScanner 1]: Checking remaining unverified tracks.
Debug [LibraryScanner 1]: Marking unverified tracks as deleted.
Debug [LibraryScanner 1]: Marking unverified directories as deleted.
Debug [LibraryScanner 1]: Detecting moved files.
Debug [LibraryScanner 1]: Committing transaction on "LIBRARY_SCANNER" result: true
Debug [LibraryScanner 1]: Detecting cover art for unscanned files.
Debug [LibraryScanner 1]: Scan finished cleanly
Debug [LibraryScanner 1]: Scan took: 150014269 ns. 617 unchanged directories. 0 changed/added directories. 0 tracks verified from changed/added directories. 0 new tracks.

Tags: library
Revision history for this message
Max Linke (max-linke) wrote :

I've started to look into this more. This seems to be a problem of the new threaded approach to scanning the library.

I guess the problem lies in recursiveScanDirectoryTask

recursiveScanDirectoryTask.cpp : 82

    if (prevHash != newHash) {
        // Rescan that mofo! If importing fails then the scan was cancelled so
        // we return immediately.
        if (!filesToImport.isEmpty()) {
            m_pScanner->queueTask(new ImportFilesTask(m_pScanner, m_scannerGlobal,
                                                      filesToImport, possibleCovers,
                                                      m_pToken));
        }

        // Insert or update the hash in the database.
        emit(directoryHashed(dirPath, !prevHashExists, newHash));
    } else {
        emit(directoryUnchanged(dirPath));
    }

To me this looks like the Code assumes that once I queue an ImportFilesTask it will run for no matter what happens later. But this assumption is wrong when we allow to cancel the scan.

This causes us to save directories as scanned and imported in the database while they are not in truth.

I haven't done any close checking yet. But what I assume happens is that the complete recursiveScan is finished a long time before the importFileTasks are finished.

Suprisingly I see this in the most severe form because I have a SSD. With an HDD there will be only a some tracks left unscanned.

I'm not sure what would be a good easy fix for this. It seems to me a like a design flaw and I don't have a lot of experience with debugging task queues. My current idea would be to keep the recursiveScanTask alive until the importFilesTask it has started is finished and notified of that, only then is the recursiveScanTask allowed to emit the directoryHashed signal. But that might complicate things way to much, it sounds like there should be an easier solution.

@rryan any comments?

Revision history for this message
Max Linke (max-linke) wrote :

Or maybe we just don't use the queue/task to importFiles but call al plain old function.

Max Linke (max-linke)
Changed in mixxx:
assignee: nobody → Max Linke (max-linke)
status: Confirmed → In Progress
Revision history for this message
Owen Williams (ywwg) wrote :

When you say "inconsistent state" (in your email), do you mean the database is hosed, or just that the user needs to exit mixxx and restart it to fix the issue? I'm not sure what the consequence is.

Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

Inconsistent here means:
1) Directory hash marked as up-to-date
2) Some files that contributed to that directory hash have not been imported (since the import task was canceled half way through).

Database isn't hosed but the files in the dir won't ever be scanned until the directory changes (so its hash changes). Reboot won't fix it.

Max Linke (max-linke)
Changed in mixxx:
status: In Progress → Fix Committed
RJ Skerry-Ryan (rryan)
Changed in mixxx:
status: Fix Committed → Fix Released
Revision history for this message
Swiftb0y (swiftb0y) wrote :

Mixxx now uses GitHub for bug tracking. This bug has been migrated to:
https://github.com/mixxxdj/mixxx/issues/7875

lock status: Metadata changes locked and limited to project staff
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.