calpaterson / quarchive

Traditional "Web 2.0" social bookmarking, with small improvements
https://quarchive.com/
GNU Affero General Public License v3.0
100 stars 6 forks source link

Bookmark CRDT is not total #16

Closed calpaterson closed 3 years ago

calpaterson commented 4 years ago

Description

Bookmark CRDT covers nearly all cases but not everything - sometimes merges are not commutative.

Steps to reproduce

  1. Two bookmarks A and B with same updated time but other differing features
  2. Merge A with B to create C
  3. Merge B with A to create D

Expected result

C == D

Actual result

C != D

Additional details

The problem occurs in this code:

        more_recent: "Bookmark" = sorted(
            (self, other),
            # The below lambda should include all fields for which more_recent is consulted
            # ie, everything other than created and updated
            key=lambda b: (
                b.updated,
                len(b.title),
                len(b.description),
                b.title,
                b.description,
            ),
            reverse=True,

        return Bookmark(
            url=self.url,
            created=min((self.created, other.created)),
            updated=max((self.updated, other.updated)),
            title=more_recent.title,
            description=more_recent.description,
            unread=more_recent.unread,
            deleted=more_recent.deleted,
        )    )[0]
calpaterson commented 4 years ago

Fixed in 11a930062513926e98b34ef34dd7ac1f558d1736

calpaterson commented 4 years ago

Reopening as it's not been fixed in the extension

calpaterson commented 4 years ago

Pretty sure this issue is fixed but need to confirm it

calpaterson commented 3 years ago

Review the code, extension differs slightly and needs to be brought into line: https://github.com/calpaterson/quarchive/issues/57