quest invitation partial failure: RSVPNeeded never received
#10,275 创建于 2018年4月22日
描述
When a party member uses a quest scroll to send quest invitations to party members, two things happen:
- the party's
quest.membersobject is updated with a list of all members' User IDs, each with the valuenull(later changed to true or false when the member accepts/rejects) - each member has the quest's key added to their party data and has
party.quest.RSVPNeededset to true (later changed to false when they accept/reject).
Those two updates are saved to the database separately, so it's possible for the first update to succeed (i.e., the party's data is correct) but the update made to one or more of the players' accounts can fail. This means that they never receive the quest invitation and so can't participate in the quest.
This happened today to MEmry the Listful (78fbf973-0280-40a4-a3a6-0509e1901b51) - I confirmed that their RSVPNeeded value was false even though their acceptance in the party was still listed as null. They've said it's happened to other party members too in the past: "I'm having a recurring glitch with quests. It seems like at least every other quest I start, there's one party member who cannot join. It just doesn't give the option. This time we have an invite out there for the squirrel quest, and I am the one who cannot join it."
This is a similar problem to https://github.com/HabitRPG/habitica/issues/10210 and I'd suggest that the fix would be similar ("Adjust the current code for updating the party's document and updating the player's document so that it checks to see if both updates were done, and if either or both fails, it repeats them until they're successful.")
With PR #12335 the Habitica codebase has been updated to support MongoDB 4.2 and transactions making it possible to fix this issue.
Transactions allow operations on multiple documents to be executed ensuring that either all of them are executed correctly or none, making it possible to fix this issue.
An example on using transactions can be found at https://mongoosejs.com/docs/transactions.html while more info at https://docs.mongodb.com/manual/core/transactions/. If you want to work on this issue and have any question please leave a comment!