Page MenuHomePhabricator

[RFC] Detect edit conflicts in ChangeOp instead of using diff-and-patch in EditEntity
Open, MediumPublic

Description

Currently, saving a change to an entity works something like this:

  1. Let r2 be the current revision of page Foo, and r1 an older revision.
  2. The client submits a change to Foo, with r1 as the base revision
  3. The API creates a ChangeOp to represent the modification
  4. The change op is validated and applied to r1, producing r1'
  5. r1' is diffed against r1, producing patch p
  6. p is applied to r2, producing r2'. If p does not apply cleanly, we have an edit conflict.

This procedure is rather wasteful and error prone. Alternatively, we should:

  1. Let r2 be the current revision of page Foo, and r1 an older revision.
  2. The client submits a change to Foo, with r1 as the base revision
  3. The API creates a ChangeOp to represent the modification
  4. The change op checks for conflicts, given both r1 and r2
  5. The change op is validated and applied to r2, producing r2'

Note that we should take care to make sure to supply the current revision ID we used for validation, r2, as the "$baseRevId" parameter of EntityStore::saveEntity, to avoid a race condition in case of concurrent edits.

Event Timeline

daniel raised the priority of this task from to Needs Triage.
daniel updated the task description. (Show Details)
daniel added a subscriber: daniel.
daniel set Security to None.
daniel updated the task description. (Show Details)
daniel updated the task description. (Show Details)
thiemowmde renamed this task from Detect edit conflicts in ChangeOp instead of using diff-and-patch in EditEntity to [RFC] Detect edit conflicts in ChangeOp instead of using diff-and-patch in EditEntity.Feb 16 2016, 1:54 PM
thiemowmde added a project: Proposal.
thiemowmde added subscribers: thiemowmde, aude, hoo, JanZerebecki.

@thiemowmde – Did you mean to tag this as TechCom-RFC or do you not want their input? Right now it's just generally tagged as TechCom-RFC, which essentially is merely "needs discussion".

Not sure what TechCom is. this is internal to Wikidata and doesn't need input from outside of the project. The TechCom-RFC tag is probably not helpful then.