nextcloud / text

📑 Collaborative document editing using Markdown
GNU Affero General Public License v3.0
539 stars 87 forks source link

Detect inconsistent initial steps in yjs and require page reload #5724

Open max-nextcloud opened 4 months ago

max-nextcloud commented 4 months ago

Is your feature request related to a problem? Please describe. In case two users start a new yjs session at the same time they need to initialize it with the initial ydoc content to create a consistent world view. https://github.com/nextcloud/text/pull/5589 tackles this. If for some reason the two clients come up with a different initial doc state we end up with a "split brain" situation - where both work on a similar yet different document and fail to sync fully.

Planned solution

Tasks

Acceptance Criteria

Open questions

max-nextcloud commented 2 months ago

I think this issue just changed from being theoretical to having been practically observed: grafik

I used this script: https://github.com/nextcloud/text/blob/investigate/inconsistencies-in-document/src/tests/investigate-corruption.spec.js#L41-51

So what the screenshot is printing is tr.afterState - which seems to be the state vector of all clients after processing that transaction.

Two things jump out here:

So it looks like two editing sessions ran in parallel for a while here before they were 'mixed'. On possible cause for this would be different initial state steps - which would lead to a split brain situation - where one client does not see the other clients changes and vice versa.