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

Server-side JSON-Patch OT #453

Closed
4 of 6 tasks
tomalec opened this issue Nov 21, 2018 · 10 comments
Closed
4 of 6 tasks

Server-side JSON-Patch OT #453

tomalec opened this issue Nov 21, 2018 · 10 comments

Comments

@tomalec
Copy link

tomalec commented Nov 21, 2018

Starcounter version: 2.4.999.191

Issue type

  • Bug
  • Feature request
  • Suggestion
  • Question
  • Cannot reproduce
  • Urgent

Issue description

During investigation of HeadsOne issue (fast clicking on create button) https://github.com/Starcounter/HeadsOmni/issues/665#issuecomment-440784899
from reading the Starcounter.XSON code I figured out (I'm not a pro in C#, so please, tell me that I'm wrong) that we do not transform JSON Patches against JSON Patches on server-side - meaning we do not have JSON Patch Operational Transformation (OT).

  • we do some kind of transformations on Handle - when we apply patch to the JSON tree,
  • but we do not transform JSON Patches against JSON Patches.

OT - Operational Transformation - is about transforming operations not the object. That's what makes it fast and simple.

Reproduction code snippet

Send two, separate but consecutive Web Socket messages from client(browser), that changes a property in JSON view-model.

[{"op":"replace","path":"/_ver#c$","value":1},{"op":"test","path":"/_ver#s","value":0},{"op":"replace","path":"/BlendingProvider_0/Content/Products_0/CurrentPage/Products_0/CreateProductTrigger$","value":"1"}] //C1
[{"op":"replace","path":"/_ver#c$","value":2},{"op":"test","path":"/_ver#s","value":0},{"op":"replace","path":"/BlendingProvider_0/Content/Products_0/CurrentPage/Products_0/CreateProductTrigger$","value":"2"}] //C2

Server-side of an app should remove the modified object in response to the first message:

[{"op":"replace","path":"/_ver#s","value":1},{"op":"test","path":"/_ver#c$","value":1},{"op":"remove","path":"/BlendingProvider_0/Content/Products_0/CurrentPage"}] //S1

Expected behaviour

Server-side JSON Patch OT, should transform
C2' = C2 ∘ S1 regardless of JSON tree.

[{"op":"replace","path":"/_ver#c$","value":2},{"op":"test","path":"/_ver#s","value":1}] //C2'

Actual behaviour - Exception stack trace

Unknown property in path. Patch: '{"op":"replace","path":"/BlendingProvider_0/Content/Products_0/CurrentPage/Products_0/CreateProductTrigger$","value":"2"}'. Property: 'CreateProductTrigger$'. Viewmodel versions: {client (_ver#c$): 3, clients serverversion: 2, server (_ver#s): 3}.

Related issues:

//cc @warpech @eriohl @erikvk @alshakero

@eriohl
Copy link

eriohl commented Nov 22, 2018

Unfortunately only Christian is/was fully familiar with how this stuff works and is supposed to work. So it is not entirely trivial answering questions about it. Not sure if Joachim was involved in this as well but if so it was a while ago.

He also started up a rewrite of it is but he didn't get very far. (if you lack access to it is a little disabled code riddled with TODOs, so it is probably not all that useful).

So it is probably quite a large project cleaning this up. And for me it is not entirely clear on how to approach this. Up to @erikvk though. Let me know if and how I can help.

@erikvk
Copy link

erikvk commented Nov 22, 2018

cc @dan31 @eriohl @tomalec

I should let you know that I'm currently busy with the high-prio migrator tool for the root data model (AKA Doctor M) used in mapping, and will be unable to look into this before I'm done with that, i.e. sometime mid-December.

@miyconst
Copy link

As far as I remember from discussions with Christian, this feature was never implemented, and it's lack was hitting us every now and then.

@miyconst
Copy link

Christian also told me that there is a way to setup server side JSON Patch applicator to ignore patches to non-existing objects instead of crashing, but now I was not able to find how to use that feature, maybe it's only available internally in Level1/XSON.

@warpech
Copy link

warpech commented Dec 12, 2018

The roadmap https://github.com/Starcounter/CompanyTrack/blob/master/Roadmap/Roadmap.md considers long and short-term solution to the lack of this feature. @dan31, @eriohl do you remember what is the short-term solution that is meant there?

I think the only way to fix this is to implement the actual transformations. It should not be super hard, given that we aleady have a reference implementation in JS: https://github.com/Palindrom/JSON-Patch-OT-agent

@eriohl
Copy link

eriohl commented Dec 12, 2018

I don't remember discussing that part nor do I understand how to short term fix it given that there isn't any OT there to fix. But maybe it is possible just to use the existing implementation given that is is possible to embed Node.js in .NET? It requires no input other the patches right?

@tomalec
Copy link
Author

tomalec commented Dec 16, 2018

It requires no input other the patches right?

Just patches (with/and version numbers), JSON tree is not needed.

@tomalec
Copy link
Author

tomalec commented Apr 15, 2019

On Thursday 11th April @eriohl @erikvk @dan31 and me had a meeting to gather common understanding of current implementations and plan the architecture and the way to go with the new server-side implementations.

I'd like to write down some highlights from the meeting.

Please correct me, if I wrote something wrong or missed something.

@erikvk
Copy link

erikvk commented Apr 15, 2019

@tomalec Thanks for the writeup!

@miyconst
Copy link

miyconst commented Jan 7, 2020

Archiving.

@miyconst miyconst closed this as completed Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants