Skip to content

After a property delete and its undo, the server keeps a value the clients do not have #1313

Open

Description

@yuxi-liu-wired

Steps

Alice and Bob edit the same synced graph. A property "stage" has the choices "draft" and "done". Page "page 1" has a block "a".

  1. Alice goes offline.
  2. Alice sets "stage" on block "a" to "draft".
  3. Alice deletes the property "stage".
  4. Alice presses Ctrl+Z.
  5. Bob, online, edits any other block (in the test he sets another block to DONE).
  6. Alice goes online.

Expected

After the sync, Alice, Bob and the server hold the same data.

Actual

The server's copy of block "a" differs from both clients' copies:

  • On the server, "a" keeps a value of "stage" that points at the deleted choice: the datom [a :user.property/stage 195], where 195 was the id of "draft" and no entity has that id any more.
  • On Alice's client, and on Bob's after he pulls, "a" has no value of "stage".

The sync checksum does not notice: it covers only :block/uuid, :block/parent, :block/page, :block/order, :block/title and :block/name (relevant-attrs, deps/db-sync/src/logseq/db_sync/checksum.cljs:75-78).

The difference comes from Alice's client applying her 3 unconfirmed requests again after Bob's edit. The rows it then uploads, in order:

  1. [:db/add a :user.property/stage [:block/uuid draft]] (the property value)
  2. [:db/retractEntity stage], [:db/retractEntity done], [:db/retractEntity draft] (the property delete)
  3. the property "stage" and its choices created again with their uuids (the undo)

On Alice's client, retracting "draft" also removes a's value. On the server, after the same rows, a's value is still there and points at the old id of "draft".

Separately, the undo does not give "a" its value back, also without sync (see #1309 for the undo of deleting a property with choices).

Found with a 2-person property-based test of undo under sync (random requests of 2 people, random sync points), replayed on upstream master 16c4ed1a0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions