Coder Social home page Coder Social logo

Comments (2)

Horusiath avatar Horusiath commented on August 19, 2024

tl;dr this works as expected. If you want to keep result consistent eg. for the sake of deterministic testing, you should create document with and explicit ID using Y.YDoc(client_id=X).

Longer explanation

The series of updates we're receiving in this scenario - concerning the ysource shared text type is basically:

  1. Create a document with randomised identifier X and put character "a" at the beginning.
  2. Concurrently to pt.1 at document with ID 845456925 insert character "a" at the beginning.
  3. After pt.2 (but still concurrently to pt.1) at the document with ID 3709507946 insert character "b" after character "a" inserted by 845456925.
  4. Serialise updates from pt.2 and pt.3. and apply them to document with ID X from pt.1.

The consistent part is that points 2. and 3. generate a string "ab" that's supposed to be inserted at the beginning of a ysource... however the actual position of a second "a" character is not set in stone, as we have concurrent operation of inserting character "a" at the same position by a different document.

In this case the conflict resolution algorithm will use document IDs to determine which piece of text ("ab" or "a") to insert first and which should be inserted second. Eg. if our document from pt.1 was generated with ID < 3709507946 (pt.3) the result will be "aba", but if its generated ID was higher, then the result will be "aab".

This means that depending on the run, the randomly generated ID can affect the order of operations. If that ID was static (not generated) the order would stay the same.

from ypy.

davidbrochart avatar davidbrochart commented on August 19, 2024

Makes sense, thanks a lot for the explanations!

from ypy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.