-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Track Metadata: Fix synchronization (import/export) of file tags #4628
Conversation
Tests the fixes from the preceding commits. Reverting each of those commits will cause test failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I have left some comments.
|
||
/// The status could not be determined for whatever reason, | ||
/// e.g. inaccessible file, ... | ||
Undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference between Undefined/Unknown/Void is not obvious in the using code.
How about renaming these value to
NotImported/UnknownSyncronizedTime/UnknownFileTime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The synchronization status type should not mention files directly. It is independent of how the content of sources is stored. Files are just one kind of storage type.
As already mentioned synchronization time stamps should not be confused with raw file time stamps and we should not mix that up on this higher level of abstraction.
The names of the variants are abstract and do not need to leak implementation details from other parts of the code. Descriptions of possible use cases have deliberately been added as possible examples in the comments.
I also dislike composed terms that start with the same stem. Different kind of "unknowns" are confusing, too. It is easier to recognize distinct words.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so what about:
SourceSyncStatus = Unsynced
SourceSyncStatus = Syncronized
SourceSyncStatus = ImportPending
SourceSyncStatus = ExportPending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide a mapping to the existing values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Void = Unsynced
Syncronized = Syncronized
Outdated = ImportPending
Undefined = ExportPending
Unknown = Unknown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My proposal is this PR. I did not receive any alternative proposals yet that I consider as an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my feeling my recent proposal follows your demand in #4628 (comment)
My demand is to have more descriptive names than the ambiguous Undefined/Unknown/Void.
What would be an alternative for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variant names are recognizable and they were helpful while writing the different test cases.
They represent a state and are not directly related to any import/export activity as you suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you really insist to keep these empty and interchangeable words Undefined/Unknown/Void and like to rely on out of sight comments, I'll give up. It is a pity that we have not found a compromise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming can be changed at any time. But I refuse to overload this PR with more unrelated changes.
I hope that c72115f fixes the sporadic CI failures. One sleep might have been missing. The dependency on uncontrollable side effects is unfortunate. |
Now clang-tidy fails. |
TrackDAO: Refactorings from debugging #4628
|
These extensive tests with all their combinatorics have revealed many issues. |
We should restart the build jobs repeatedly to see if there are still timing issues on Ubuntu with the minimum delay of 1 ms between file modifications. All timing code in Mixxx and the tests should only compare time stamps that have been generated by the file system as the single source of truth. I am not aware that we missed any occurrence that uses time stamps from a second, inconsistent source. |
Manually restarting GitHub Actions jobs will cancel the old run. You can hack around this by repeatedly doing |
Restarting works as expected and the tests have been rerun as intended. We want them to fail, not to succeed. |
This saves 1 sleep operation per test run.
It is still failing locally in rare cases:
|
Unfortunately we cannot loop our track saving code until a different time stamp for the file is generated when exporting metadata. Then we need to increase the sleep time until the tests succeed reliably. I am running the tests on btrfs and tmpfs (used by QTemporaryDir). They succeed even if I comment out the sleep. |
src/test/libraryfilesynctest.cpp
Outdated
ASSERT_EQ(1, pTrack.use_count()); | ||
const auto trackId = pTrack->getId(); | ||
ASSERT_TRUE(trackId.isValid()); | ||
ASSERT_TRUE(pTrack->isDirty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the case? This does not match to the comment below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
The latest commit works here. However I would prefer a more robust solution by just setting the file time to an reasonable old value on creation. |
That would be inconsistent with the implicit update of the modification time stamp when saving the file. We don't know anything about the relation of the different clocks and should rely on a single source of truth. I have already burned my fingers and will not touch it again!! |
Original we had in one case a bussy loop that finds exactly the minimum difference that is considered as such. But you had no solution for setting the file to a newer value. Now you have increased the sleep time to 2 ms, a wild guess that works on my device which makes the busy loop obsolete, because the 2 is used there as well. This mean you original demand to test with them I um difference does no longer work anyway. I think a much better solution is to creat the file, read the file time and sibstract 1 and write it back. The same can be done when advancing the file time read it add one and write it back. This way it should be rock solid. |
Thanks. That was actually a good idea. The current test design has proven to be solid as this change was easy to integrate. Though somehow also tricky, I added comments. |
Now it is working reliable. Thank you. I am sorry for you burned fingers. |
Synchronization of file tags (import/export) is severely broken due to various reasons:
Those 2 different causes made it difficult to discover the misbehavior. The new unit test ensures that this will never break again.