Skip to content

fix(persistence): drop entries whose row is gone instead of failing every later save - #1624

Open
leqatoavgust-dot wants to merge 1 commit into
MUnique:masterfrom
leqatoavgust-dot:fix/save-drop-entries-without-rows
Open

leqatoavgust-dot wants to merge 1 commit into
MUnique:masterfrom
leqatoavgust-dot:fix/save-drop-entries-without-rows

Conversation

@leqatoavgust-dot

Copy link
Copy Markdown
Contributor

What happened

A save fails with DbUpdateConcurrencyException ("expected to affect 1 row(s), but actually affected 0 row(s)") when it deletes or updates a row which no longer exists: an item destroyed by a chaos mix, or a dropped item which expired and was deleted by another context (both are in #1478). The failing entry stayed in the change tracker, so the bounded retry sent the same statement again three times, and every later save of the session failed the same way. Everything the player did until logout was lost.

The change

When a save is rejected with a DbUpdateConcurrencyException, EntityFrameworkContextBase now asks the database for each conflicting entry's row:

  • an entry in state Deleted or Modified whose row is gone is detached, together with its aggregate members (e.g. an item's option links, which are gone with it). A delete of such a row is done already; an update of it can never succeed.
  • the save is then retried, so all other changes are saved. The retry limit goes from 3 to 5, since each attempt can clear one conflicting batch.

Entries whose row still exists are left alone, so a real conflict still fails as before. Configuration edits (with their own transaction) are not touched.

How it was tested

  • Reproduced on a local server: an item row of an online character was deleted in the database, then /clearinv was used. The log showed the conflict (Save conflict for "Item" (...), state Deleted), then Dropping "Item" from the save: its row is gone already, and the retry saved the other 38 deleted items. Without the change, all three attempts fail and the session stays unable to save.
  • Persistence tests and the full test suite pass on our fork (4266 passed, 2 skipped).

Fixes #1478

🤖 Generated with Claude Code

…very later save

A delete or update of a row which no longer exists (for example an item destroyed by a
chaos mix, or a dropped item which expired and was deleted by another context) fails with
'expected to affect 1 row(s), but actually affected 0 row(s)'. The entry stayed in the change
tracker, so every retry and every later save of the session failed the same way, and the
player's progress was lost at logout.

When a save is rejected with a DbUpdateConcurrencyException, the conflicting entries are now
checked against the database: an entry in state Deleted or Modified whose row is gone is
detached (together with its aggregate members, e.g. an item's option links), and the save is
retried (up to 5 attempts instead of 3), so everything else is saved.

Fixes MUnique#1478
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 11 complexity

Metric Results
Complexity 11

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Player saves fail permanently for the session after crafting first wings (DbUpdateConcurrencyException, 0 rows affected) – progress lost on logout

1 participant