Anime-Game-Servers / Grasscutter-Quests

A server software implementation, ineroperable with a certain anime game client. The code in this repository is fully custom made for edyoucational purposes and future preservation, no copyrighted code is allowed in this repository.
https://grasscutters.xyz/grasscutter
GNU Affero General Public License v3.0
137 stars 31 forks source link

Handle concurrent saving error #102

Closed scooterboo closed 9 months ago

scooterboo commented 9 months ago

Description

At the end of An Impromptu Change of Plan, only one of the three Adepti quests fired: Wangshu When Wangshu saves, the timing on my computer makes it save two times at the same time (for 100301 and 100320). When this happens, a E11000 duplicate key error collection: grasscutter.quests index: _id_ dup key: { _id: ObjectId('65ceb86e3a88695a7c17d491') } is thrown, and the quest accept system bails. The quest system ends up not accepting the other two Adepti quests.

A long term fix would be for the main quest to not save to the backup database as things change, but to save in batches. For example on world ticks or every 30s worth of world ticks.

This proposed fix makes it gracefully fail and continue to accept quests if saving fails.

image

Type of changes

Checklist:

sonarcloud[bot] commented 9 months ago

Quality Gate Passed Quality Gate passed

Issues
1 New issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud