Concurrent task edits not supported, resulting in data loss #1829

Closed
opened 2021-09-20 21:27:24 +00:00 by OrangePony · 4 comments

First of all, big kudos on the stellar progress of vikunja!

We have just started using vikunja at home to track family projects & tasks. Today, we realized that tasks cannot be edited concurrently.

If user A edits a task (including modifying any core task attributes, including title and description, or marking it as done) while user B has this task or the list it belongs to open, all changes applied are lost if user B performs an edit on that task - including marking the task as done! Enabling the database debug, I can see that, even when marking a task as done, all of the attributes are updated to those passed on by the client, which basically means that all existing attributes are overwritten.

I think nobody should expects Vikunja to keep attributes set by a user if another user has the task modal open and submits it a few seconds later, but it probably is reasonable to expect it to keep attributes set by a user if another user comes along and marks a task as Done without refreshing the UI.

If I may, my suggestions would be to either...
a) Reject the edit with an error message if the task has been updated after the shown data in the modal or task list has been fetched. Looking through the Task Update code, perhaps we could simply reject it if the 'updated' task attributed passed by the client is older than the current 'updated' attribute?
b) Mark the task as done but keep all other attributes intact when marking a task as Done.
c) Show real-time task attribute modifications performed by a user to all other users that have that task or task list open.

Now that I'm writing this, given that (a) is a backend fix, perhaps I should log this as a new issue in the backend repo?

First of all, big kudos on the stellar progress of vikunja! ✨ We have just started using vikunja at home to track family projects & tasks. Today, we realized that tasks cannot be edited *concurrently*. If user A edits a task (including modifying any core task attributes, including title and description, or marking it as done) while user B has this task or the list it belongs to open, all changes applied are lost if user B performs an edit on that task - including marking the task as done! Enabling the database debug, I can see that, even when marking a task as done, all of the attributes are updated to those passed on by the client, which basically means that all existing attributes are overwritten. I think nobody should expects Vikunja to keep attributes set by a user if another user has the task modal open and submits it a few seconds later, but it probably is reasonable to expect it to keep attributes set by a user if another user comes along and marks a task as Done without refreshing the UI. If I may, my suggestions would be to either... a) Reject the edit with an error message if the task has been updated after the shown data in the modal or task list has been fetched. Looking through the [Task Update code](https://kolaente.dev/vikunja/api/src/commit/abfdae00124aa9942b9524c720225ae0f6a88c3a/pkg/models/tasks.go#L959), perhaps we could simply reject it if the 'updated' task attributed passed by the client is older than the current 'updated' attribute? b) Mark the task as done but keep all other attributes intact when marking a task as Done. c) Show real-time task attribute modifications performed by a user to all other users that have that task or task list open. Now that I'm writing this, given that (a) is a backend fix, perhaps I should log this as a new issue in the backend repo?
Member

I think this is a duplicate of vikunja/frontend#594

I think this is a duplicate of https://kolaente.dev/vikunja/frontend/issues/594
konrad added the
kind/feature
label 2021-09-21 19:48:43 +00:00
Owner

Ideally, we will have some kind of real time sync between multiple users one day. There is a similar thread on the forum: https://community.vikunja.io/t/offline-capabilities-of-the-front-end/252

b) Mark the task as done but keep all other attributes intact when marking a task as Done.

The problem with this is that this extends to all attributes and you need to figure out if the attribute has been changed or removed from the task. In Go, there's no easy way to do this, hence all of that logic in the task update code.

Closing this in favor of #594, feel free to reopen if you think this one is different.

Ideally, we will have some kind of real time sync between multiple users one day. There is a similar thread on the forum: https://community.vikunja.io/t/offline-capabilities-of-the-front-end/252 > b) Mark the task as done but keep all other attributes intact when marking a task as Done. The problem with this is that this extends to all attributes and you need to figure out if the attribute has been changed or removed from the task. In Go, there's no easy way to do this, hence all of that logic in the task update code. Closing this in favor of #594, feel free to reopen if you think this one is different.
Author

You are completely right, #594 is related to this! Sorry for that, I did not find it.

b) Mark the task as done but keep all other attributes intact when marking a task as Done.

The problem with this is that this extends to all attributes and you need to figure out if the attribute has been changed or removed from the task. In Go, there's no easy way to do this, hence all of that logic in the task update code.

Closing this in favor of #594, feel free to reopen if you think this one is different.

I think this is a tricky one - would a full task block as described in #594 solve this edge case? Perhaps only the real-time sync between multiple users that you are mentioning would solve this.

Perhaps a new, simple API endpoint to mark a task as done without modifying the rest of the attributes could be implemented? This could be the specific API call that takes place when a user marks a task as done by clicking on a checkbox, outside of a task modification screen. If I am not mistaken, is this the only attribute that can be changed from outside of a task detail screen?

Perhaps this is too much work for an edge case, feel free to ignore this in any case.

You are completely right, #594 is related to this! Sorry for that, I did not find it. > > b) Mark the task as done but keep all other attributes intact when marking a task as Done. > > The problem with this is that this extends to all attributes and you need to figure out if the attribute has been changed or removed from the task. In Go, there's no easy way to do this, hence all of that logic in the task update code. > > Closing this in favor of #594, feel free to reopen if you think this one is different. I think this is a tricky one - would a full task block as described in #594 solve this edge case? Perhaps only the real-time sync between multiple users that you are mentioning would solve this. Perhaps a new, simple API endpoint to mark a task as done without modifying the rest of the attributes could be implemented? This could be the specific API call that takes place when a user marks a task as done by clicking on a checkbox, outside of a task modification screen. If I am not mistaken, is this the only attribute that can be changed from outside of a task detail screen? Perhaps this is too much work for an edge case, feel free to ignore this in any case.
Owner

If I am not mistaken, is this the only attribute that can be changed from outside of a task detail screen?

Ah, I think I now understand the problem here. A new endpoint might not even be required for this to work, maybe a little change in how we're marking the task as done in these cases would be enough. Will take a look.

> If I am not mistaken, is this the only attribute that can be changed from outside of a task detail screen? Ah, I think I now understand the problem here. A new endpoint might not even be required for this to work, maybe a little change in how we're marking the task as done in these cases would be enough. Will take a look.
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: vikunja/vikunja#1829
No description provided.