Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrackDAO/GlobalTrackCache: Handle file aliasing #3027

Merged
merged 14 commits into from Aug 25, 2020
Merged

TrackDAO/GlobalTrackCache: Handle file aliasing #3027

merged 14 commits into from Aug 25, 2020

Conversation

uklotzde
Copy link
Contributor

@uklotzde uklotzde commented Aug 16, 2020

Replaces #3026

Topic on Zulip: DEBUG_ASSDERT in GlobalTrackCache::resolve

Two tracks with different locations but the same canonical locations cause a debug assertion. This is possible by creating a symbolic link to an existing track in the music folder and rescanning the library. Both tracks are now shown in the library, but they refer to the same file.

Only one of those tracks could be loaded at the same time!! This might cause some inconvenience and inconsistencies in the UI when editing the track properties, but it prevents file corruption when exporting file tags.

Not sure if this is a critical bug. Backport to 2.2? I did not check if this is feasible.

@uklotzde uklotzde added this to the 2.2.5 milestone Aug 16, 2020
@Holzhaus
Copy link
Member

I'll try to review this tomorrow. Can you add a changelog entry?

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments in #3026

@uklotzde
Copy link
Contributor Author

CI failures are unrelated.

Rescanning a library with a single, physical file and multiple aliases (= symbolic links, both for (sub-)directories and files) now works flawlessly. The files are added one after another by subsequent library scans as expected.

We cannot store canonical file paths in the database, because those are not supposed to be stable and persistent. Mount points may change over time. This is the reason why aliased files could not reliably be detected as duplicates without accessing all existing files individually.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid we need to fail the lookup in this case, as if the track is not existing.

This case is well tested in the using code, but returning a track with a different ID is not considered and will lead to hard to explain follow up issue.

The ASSERT was there for a good reason, it is deeply assumed everywhere.

For example in AutoDJProcessor::getNextTrackFromQueue() the track is loaded with a different ID.
AutoDJProcessor::removeTrackFromTopOfQueue considered this track as manually loaded and does not remove the track. Result, the same track is played over and over again.

The track will never be anlyzed but the result is not stored in AnalysisFeature::analyzeTracks

The play counter of the Track will not be increase, the preview button will not light up the BPM lock will be bypassed ..... to be continued

I actually think that this situation is a faulty state, we should inform him about this bad state and just fail.
Mixxx is not ready to graceful deal with this situation.

@uklotzde
Copy link
Contributor Author

Not possible. If we fail the lookup a different track will be loaded for the same file resulting in potential file corruption when exporting tracks. Caching the 2nd track would also fail, because we cannot cache 2 different tracks with the same canonical location.

<< "instead of"
<< trackId
<< "with the same canonical file location"
<< pTrack->getFileInfo().canonicalFilePath();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can safely return return TrackPointer(); here. All using code need to handle that anyway.

I have found three issue we need urgently fixed anyway:

AutoDJFeature::slotAddRandomTrack() has a debug assert that is wrong

void TrackExportWorker::run(), CrateFeature::slotExportTrackFiles() and SetlogFeature::slotJoinWithPrevious() are also missing the null check.

@daschuer
Copy link
Member

Not possible. If we fail the lookup a different track will be loaded for the same file resulting in potential file corruption when exporting tracks.

I mean returning a null track as if the track is not available.

Caching the 2nd track would also fail, because we cannot cache 2 different tracks with the same canonical location.

Yes, that's why I consider the library as faulty. No need to workaround in Mixxx, just fail.

@uklotzde
Copy link
Contributor Author

For testing purposes: dumb_music_folder.tar.gz

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Just a suggestion.

src/library/dao/trackdao.cpp Outdated Show resolved Hide resolved
@uklotzde
Copy link
Contributor Author

@daschuer Ping

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thank you.

@daschuer daschuer merged commit d2f3d77 into mixxxdj:2.2 Aug 25, 2020
@uklotzde uklotzde deleted the 2.2_globaltrackcache branch August 25, 2020 16:06
@uklotzde uklotzde modified the milestones: 2.2.5, 2.3.0 May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants