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

Conflict over saving after real time #1412

Open
cballevre opened this issue Oct 30, 2023 · 1 comment
Open

Conflict over saving after real time #1412

cballevre opened this issue Oct 30, 2023 · 1 comment
Assignees
Labels
discussion Discuss about a particular subject to take a decision

Comments

@cballevre
Copy link
Member

cballevre commented Oct 30, 2023

I encountered a problem when working on cozy-settings between real time and saving a document. The document in question is io.cozy.settings.instance but I think that the case can be found in other places.

The document sent by cozy-stack in real time is the CouchDB document. Unlike a call to the JSON Api, the document does not contain the attribute field. The stack also adds calculation fields to the call.

This difference in behaviour means that when a modification is made with a client.save, a 409 error of the conflict type is generated. The document stored in cozy-client does not correspond to the one used by the stack.

Solution 1:
One solution used was to call the JSON Api to retrieve the last object before updating systematically. This is not optimal in terms of performance and network consumption.

Solution 2:
Modify RealTimeQueries to be able to modify the object according to business rules before integrating it into the cozy-client store. I've done an initial PR on cozy-client for this solution, but I've still got to formalise an API that suits everyone.

Solution 3:
The solution would be to unify the document returned by the JSON Api and the real-time feedback so as to have a single source of truth. This is undoubtedly a long-term solution, but @nono, would it be viable for the stack?

If you see any other way of solving the problem, I'd be glad to discuss it.

@cballevre cballevre added the discussion Discuss about a particular subject to take a decision label Oct 30, 2023
@nono
Copy link
Member

nono commented Oct 30, 2023

The solution would be to unify the document returned by the JSON Api and the real-time feedback so as to have a single source of truth. This is undoubtedly a long-term solution, but @nono, would it be viable for the stack?

Probably on the long term

cballevre added a commit to cozy/cozy-settings that referenced this issue Oct 30, 2023
The document sent by cozy-stack in real time is the CouchDB document. Unlike a call to the JSON Api, the document does not contain the attribute field. When a change was made, it generated a conflict error. I modified the RealTimeQueries so that I could modify the real-time object before integrating it into the cozy-client. This makes it possible to have the same version everywhere and avoid conflicts.

See also: cozy/cozy-client#1412
cballevre added a commit to cozy/cozy-settings that referenced this issue Oct 31, 2023
The document sent by cozy-stack in real time is the CouchDB document. Unlike a call to the JSON Api, the document does not contain the attribute field. When a change was made, it generated a conflict error. I modified the RealTimeQueries so that I could modify the real-time object before integrating it into the cozy-client. This makes it possible to have the same version everywhere and avoid conflicts.

See also: cozy/cozy-client#1412
cballevre added a commit to cozy/cozy-settings that referenced this issue Nov 2, 2023
The document sent by cozy-stack in real time is the CouchDB document. Unlike a call to the JSON Api, the document does not contain the attribute field. When a change was made, it generated a conflict error. I modified the RealTimeQueries so that I could modify the real-time object before integrating it into the cozy-client. This makes it possible to have the same version everywhere and avoid conflicts.

See also: cozy/cozy-client#1412
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discuss about a particular subject to take a decision
Projects
None yet
Development

No branches or pull requests

4 participants