Repository navigation
fix: don't write last-played history after the device token is revoked - #1187
Merged
Merged
Conversation
recordLastPlay wrote the last-played history with a plain SET after the ingest was accepted, so a token revoked in between could still get a history entry. The write now goes through a small Redis EVAL that checks the token key and writes the history key as one atomic action; if the token is gone it writes nothing. Retention, ordering, record contents and TTL are unchanged, and a failed history write still doesn't fail an accepted ingest. Tested against the in-memory Redis emulator only. The new Lua script has not run against a real Redis or Upstash service; I checked its syntax and atomicity by reading it, and it follows the same EVAL pattern as the existing scripts. The race test uses deferred barriers rather than timers. Without the source change 1 of the 2 new tests fails; with it they pass.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After an ingest was accepted, recordLastPlay wrote the last-played history with a plain SET. If the device token was revoked in between, the history entry could still be written afterwards.
The write now goes through a small Redis EVAL that checks the token key and writes the history key as one atomic action. If the token is gone, it writes nothing. Retention, ordering, record contents and TTL are unchanged, and a failed history write still doesn't fail an accepted ingest.
Limits: I only tested this against the in-memory Redis emulator. The new Lua script hasn't run against a real Redis or Upstash service; I checked its syntax and atomicity by reading it, and it uses the same EVAL pattern as the existing scripts. The race test uses deferred barriers instead of timers. Without the source change 1 of the 2 new tests fails; with it they pass, and the hosted tests are 212/212 locally. The syntax check and build are clean.