fix(web): the identity wipe runs outside the Web Locks section, so a concurrent write can resurrect a trade
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 53/100
Research direction
Start with indexeddb.rs: read clear_identity_data and compare its locking with exclusive, save_trade, patch_trade_by_order_id, and the outbox operations. The issue calls for taking patch_serial once and then the trades and outbox origin locks in that order around the wipe. The repository has no wasm test suite; done means the wipe cannot interleave with those writers, with two-tab verification noted as a future check after #409's round-trip tests exist.
Written by the indexing model from the issue text.
Description
IndexedDbStorage::clear_identity_data (indexeddb.rs:500) opens its transactions directly. Every writer of a whole document first enters the exclusive section — exclusive() (indexeddb.rs:230), which takes the in-process patch_serial mutex plus the origin-wide lock: save_trade (:300), patch_trade_by_order_id (:252) and the outbox operations, under
TRADES_LOCK / OUTBOX_LOCK (:44-45). The wipe takes neither.
Those writers are read-modify-write: they read the document, change one field and write the whole document back, with awaits in between. That is precisely why #408 added the locks. The wipe can therefore land in the middle of one:
- Tab B reads the trade document.
- Tab A generates a new user; the wipe commits.
- Tab B writes its document back — the previous identity's trade is in the new
identity's database.
Any tab of the origin shares the database, and the web app is deployed, so two tabs is an ordinary situation; the same shape applies to an in-flight patch in the tab doing the wipe.
Not to be confused with #409, which tracks wasm round-trip tests and the message index and states it does not affect correctness. This one does.
Proposed fix
Enter the exclusive section around the wipe: take patch_serial once — the mutex is not reentrant, so exclusive() cannot simply be called twice — plus both origin locks in a fixed order (trades, then outbox). No other code path holds two of them, so no deadlock is introduced.
Verification
Read-only, since the repo has no wasm test suite. Worth re-checking by hand with two tabs once #409's round-trip tests exist.
Enter the exclusive section around the wipe: take patch_serial once — the mutex is not reentrant, so exclusive() cannot simply be called twice — plus both origin locks in a fixed order (trades, then outbox). No other code path holds two of them, so no deadlock is introduced.
Verification
Read-only, since the repo has no wasm test suite. Worth re-checking by hand with two tabs once #409's round-trip tests exist.
- Dominant language
- Dart
- Stars
- 11
- Forks
- 9
- Avg merge
- 12h 8m
- Merged PRs (30d)
- 257
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MostroP2P/app
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Add-invoice screen stays on "Sent, waiting for the node" after a late acceptance on a sell orderOpenbug priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
area: ui
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
lugassawan/swe-workbench#799 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
epam/dmtools-dart#385 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
commetchat/commet#1085 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
first-timers-only good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Raza-learner/Runmote#11 ·