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 #3026

Closed
wants to merge 5 commits into from
Closed

TrackDAO/GlobalTrackCache: Handle file aliasing #3026

wants to merge 5 commits into from

Conversation

uklotzde
Copy link
Contributor

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.

@daschuer
Copy link
Member

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

I don't consider this as critical, because we need many exceptional cases at once to actually loose data.
However It would be nice to back port it anyway in case it merges cleanly.

@uklotzde
Copy link
Contributor Author

The backport requires a few, minor changes. I will substitute this branch. After merging we need to resolve some conflicts when merging into 2.3.

@uklotzde uklotzde changed the base branch from 2.3 to 2.2 August 16, 2020 20:33
@uklotzde uklotzde modified the milestones: 2.3.0, 2.2.5 Aug 16, 2020
@uklotzde
Copy link
Contributor Author

I will open a new PR to trigger the CI builds.

if (trackRef.hasCanonicalLocation()) {
trackPtr = lookupByCanonicalLocation(trackRef.getCanonicalLocation());
if (trackPtr) {
if (trackRef.hasId() &&
Copy link
Member

Choose a reason for hiding this comment

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

Can this ever be true because of the check in line 426?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If another track with a different id but the same canonical location has already been stored in the cache we will get here. That's part of the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But we might check that the found track also already has a valid id. Otherwise, this is a rare, intermediate edge case.

@@ -1227,7 +1227,20 @@ TrackPointer TrackDAO::getTrackFromDB(TrackId trackId) const {
// Just to be safe, but this should never happen!!
return pTrack;
}
DEBUG_ASSERT(pTrack->getId() == trackId);
if (pTrack->getId() != trackId) {
// This happens if two different tracks are referencing
Copy link
Member

Choose a reason for hiding this comment

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

// The cacheResolver() failed to resolve the track by it's trackId, but has found a different track listed in the database, referencing ...

It took me a bit to remind me how everything is connected. So I think I think this comment helps here.

Copy link
Member

Choose a reason for hiding this comment

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

The issue is that the using code keeps has the old track ID already on stack and keeps using it.
So we either need to inform the using code about the changed track ID or fail here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not able to solve all downstream issues and also haven't spotted any serious issues at first sight.

@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.

2 participants