-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
Implement code to guard against toggling the incorrect line #984
Comments
If the safety check is to ensure the description of the task is sufficiently similar I'm afraid that only partially solves this issue. currently, afaik (based on reading so it seems that the description doesn't have anything to do with what uniquely identifies a task and indeed there may be two unique tasks with identical descriptions. "Compare task desc" could then only be a heuristic check that goes as, "we are reasonably sure that this task is the same one but not entirely". My current thoughts on a potential solutions are: 1Ensure that the following sequence of operations occur atomically: 1. read file, 2. create new Task(), 3. modify Task, 4. write new one. with the new Ob API of 2Change the UID of tasks to actually be As for (2.) I think this is particularly risky and goes against the goal to reduce breaking changes. As per Hyrums Law the undocumented but implicit contract of the Tasks plugin is the Task UID that I mentioned above (unless I missed something in the docs). ... I'm going to continue to investigate further...!!! |
I have limited capacity to parse the above at the moment, but a few thoughts on first reading:
Absolutely agree. But it is a low hanging and rather important fruit. Incidentally, the underlying file reading and writing may change significantly if we move to using datacore as the underlying mechanism. Therefore, I personally am focussing my time on other areas, until we know for sure if we can adopt datacore. I saw the discussion about I believe that Tasks in some places uses a cached read before updating a task, and I feel a non-cached read would be a safer thing to. |
Agreed! |
I'll take a stab at a PR for this. I have some ideas brewing ... the scope of the PR would be:
there would be an additional test (maybe) to ensure the invertibility of |
as for using you can see my branch where I've already got it implemented/works locally: https://github.com/BluBloos/obsidian-tasks/tree/data-integrity |
I don't know what version But yes, I am behind on updating dependencies in general - the smoke-testing takes time - but specifically there hasn't been any urgency to update Obsidian/CodeMirror deps as we weren't needing any of the newer features. |
Re: |
|
interesting ... I did test locally calling this func, but I'm not an insider so I'll take another look ... |
Now I'm really doubting myself! Narrator: She was correct to doubt herself. 🤣 |
https://discord.com/channels/686053708261228577/694235607810965636/1055894252569231421 |
Just to note that with the check you added in #1663, @BluBloos, I have actually once been able to manually trigger the conflict in my own vault. I need to do some more experimenting, but I am slightly hopeful that with a lot of exploratory testing I might be able to identify the cause of the bug... I'm not at all sure about the following but.... I wonder about a first release of the above anti-corruption fix, using the current Obsidian dependency... So that anyone who is stuck on an old Obsidian still gets their data protected. And then a later release with the Obsidian minimum version updated to I would welcome your thoughts... |
Just to make sure I understand, a timing issue occurred and the guard didn't get hit? And then some line got overwritten that wasn't supposed to? I'm not sure exactly what you repro on your end ... |
No - A timing issue occurred and the guard did get hit! 🎉 ❤️ And I got useful information in the (slightly reformatted) error message. In maybe 200 to 400 very rapid completions of recurring tasks, spread across multiple sections, I have received the error message twice, preventing overwriting of the line. I am super happy that I can now detect the issue, enabling me to try some systematic rapid testing and see if I can spot any patterns. |
Reproduction 1 - delete some lines before the taskin vault (optionally with sync enabled)
The cause is that Obsidian will only save-and-re-parse the edited file automatically every 2 seconds, so if you toggle what was the 20th task in a section, but there are no longer 20 tasks in the section, it will pick the wrong one. I think Sync may compound the problem, as sometimes Obsidian reports that a file has been changed outside of Obsidian when I was only editing it in Obsidian, and my suspicion is that Sync's merging results in an edited file that was uploaded to the server being re-downloaded and sometimes being seen as an externally modified file. in sample vault in Tasks
Workaround
This forces Obsidian to quickly re-parse the file, and usually then the task index is correct by the time you manually toggle the last task. FWIW, attached is the content of the Markdown file I was experimenting with when I found the above repro: sdfafa.md |
My current thinking is approximately something like this: The problem:
Potential band-aids: I am struggling to express this clearly, but I think the ultimate fix for this is going to be something like:
|
Whatever we do, it's gonna need some pretty |
Or does |
Reproduction 2 - change level of indentation
With original guard code:
With lightly-reformatted error message in not-yet-pushed code - still using
|
Note to self: Try these same reproduction steps in dataview |
Reproduction 3 - edit the line then complete it
Output:
|
Thoughts - 2023-02-18 - 1The weird thing with all of these is that:
Also:
Observations when testing on DesktopSo for me in this testing, the problem seems to fundamentally be the 'up to 2 seconds' between:
When I usually see this in the wild - usually on MobileWhen I have generally had the problem for real, it is:
|
Thoughts - 2023-02-18 - 2
So the problem scenarios seem to be:
|
Hi clare, I am able to repro these same cases! |
Thanks for testing. @BluBloos. This has been bugging me for ages - then your message made the issue visible and I have made so much progress in understanding the various things going on since then - at the risk of repeating myself, very many thanks indeed! |
pushed a PR that fixes this :) (I've adjusted the name also from "Data integrity 2" - that was a mistake) |
This was fixed in #1663 - thanks to BluBloos. |
Expected Behavior
When I toggle a task using the Tasks plugin, I expect the task that is completed to match the text of the task I toggled.
Current Behavior
Very, very occasionally, I find that the task completed is not the correct task.
I do not yet have a reproduction, but it is the exact same behaviour as is observed in #688, except it is never reproducible.
I'm starting this issue as a place-holder, to capture more ideas, and information on it.
Steps to Reproduce
Not yet known. I believe it is a timing issue.
Context (Environment)
Unknown.
Possible Causes
Possible Solution
The text was updated successfully, but these errors were encountered: