rxdb icon indicating copy to clipboard operation
rxdb copied to clipboard

webrtc p2p replication Infinite loop

Open BingCoke opened this issue 7 months ago • 5 comments

This is something that can happen with a certain probability (and the probability is quite high). The code repository is: https://github.com/BingCoke/replication-test.git run yarn server and run yarn dev; When multiple pages are opened simultaneously to demonstrate the synchronization effect, and I randomly click on an item to delete it, there is a chance of triggering an infinite loop—where the item gets repeatedly created and deleted indefinitely.

https://github.com/user-attachments/assets/8ee8ca2f-493b-4df2-b304-0c8423bb439f

Another possible scenario is when I keep deleting items until all items on one page are removed, but some items may still remain on other pages. These remaining items might disappear upon refreshing the page, or they could reappear on other open pages.

Image

BingCoke avatar May 22 '25 11:05 BingCoke

btw, When I printed the changes of each find operation, I noticed that when I deleted a certain item, the value in the database would change multiple times—sometimes up to 8 times. The item would be repeatedly deleted and recreated in the database, ultimately increasing its revision count by eight.

[
  {
    "id": "a95d451c-2e43-48b4-a384-a9aa130e8d26",
    "title": "add from button",
    "done": false,
    "created": "2025-05-22T11:56:25.660Z",
    "_meta": {
      "lwt": 1747914985660.01
    },
    "_deleted": false,
    "_attachments": {},
    "_rev": "1-ukexlniyxw"
  },
  {
    "id": "bb3456a3-af53-4b2c-872c-337b06a76169",
    "title": "add from button",
    "done": false,
    "created": "2025-05-22T11:56:25.832Z",
    "_meta": {
      "lwt": 1747914985832.03
    },
    "_deleted": false,
    "_attachments": {},
    "_rev": "1-ukexlniyxw"
  },
  {
    "id": "ea8c7820-e097-4fe7-9207-480318e1fd52",
    "title": "add from button",
    "done": false,
    "created": "2025-05-22T11:56:13.635Z",
    "_deleted": false,
    "_meta": {
      "lwt": 1747915050067.03
    },
    "_rev": "9-ukexlniyxw",
    "_attachments": {}
  }
]

finally

[
  {
    "id": "a95d451c-2e43-48b4-a384-a9aa130e8d26",
    "title": "add from button",
    "done": false,
    "created": "2025-05-22T11:56:25.660Z",
    "_meta": {
      "lwt": 1747914985660.01
    },
    "_deleted": false,
    "_attachments": {},
    "_rev": "1-ukexlniyxw"
  },
  {
    "id": "bb3456a3-af53-4b2c-872c-337b06a76169",
    "title": "add from button",
    "done": false,
    "created": "2025-05-22T11:56:25.832Z",
    "_meta": {
      "lwt": 1747914985832.03
    },
    "_deleted": false,
    "_attachments": {},
    "_rev": "1-ukexlniyxw"
  },
  {
    "id": "ea8c7820-e097-4fe7-9207-480318e1fd52",
    "title": "add from button",
    "done": false,
    "created": "2025-05-22T11:56:13.635Z",
    "_deleted": false,
    "_meta": {
      "lwt": 1747915050087.04
    },
    "_attachments": {},
    "_rev": "15-ukexlniyxw"
  }
]

So it ultimately wasn't deleted after all...

BingCoke avatar May 22 '25 12:05 BingCoke

This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. Please update it or it may be closed to keep our repository organized. The best way is to add some more information or make a pull request with a test case. Also you might get help in fixing it at the RxDB Community Chat If you know you will continue working on this, just write any message to the issue (like "ping") to remove the stale tag.

stale[bot] avatar May 29 '25 12:05 stale[bot]

ping

BingCoke avatar May 29 '25 14:05 BingCoke

This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. Please update it or it may be closed to keep our repository organized. The best way is to add some more information or make a pull request with a test case. Also you might get help in fixing it at the RxDB Community Chat If you know you will continue working on this, just write any message to the issue (like "ping") to remove the stale tag.

stale[bot] avatar Jun 05 '25 15:06 stale[bot]

Hi @BingCoke I have no idea what is going on there to be honest. Please debug.

pubkey avatar Jun 05 '25 19:06 pubkey

This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. Please update it or it may be closed to keep our repository organized. The best way is to add some more information or make a pull request with a test case. Also you might get help in fixing it at the RxDB Community Chat If you know you will continue working on this, just write any message to the issue (like "ping") to remove the stale tag.

stale[bot] avatar Jun 12 '25 19:06 stale[bot]

Issues are autoclosed after some time. If you still have a problem, make a PR with a test case or to prove that you have tried to fix the problem.

stale[bot] avatar Jul 03 '25 19:07 stale[bot]