Repository navigation
Return an error when the ingress store exhausts its retries; tolerate missing state in UpdateIngress/DeleteIngress - #5049
Merged
biglittlebigben merged 5 commits intoOct 26, 2026
Conversation
- a DeleteIngress landing after the caller's LoadIngress was overwritten by the update, bringing the ingress and its stream key back
| } | ||
|
|
||
| return nil | ||
| return errors.Wrapf(redis.TxFailedErr, "could not store ingress %s after %d attempts", info.IngressId, maxRetries) |
Contributor
There was a problem hiding this comment.
Please use a psrpc.Error here (and below).
Contributor
Author
There was a problem hiding this comment.
Done in 2d8aa0c: both retry-exhausted returns are now psrpc.NewError(psrpc.Aborted, ...) wrapping the original error, so the code reaches twirp/psrpc clients and errors.Is(err, redis.TxFailedErr) still holds for the tests.
| } | ||
|
|
||
| return nil | ||
| return psrpc.NewError(psrpc.Aborted, errors.Wrapf(redis.TxFailedErr, "could not store ingress %s after %d attempts", info.IngressId, maxRetries)) |
Contributor
There was a problem hiding this comment.
I think returning a 5xx error, such as psrpc.Unavailable would be more appropriate here (and below) as an indication to retry.
Contributor
Author
There was a problem hiding this comment.
Changed to psrpc.Unavailable in 51cc07e, both here and in storeIngressState.
biglittlebigben
approved these changes
Oct 26, 2026
Contributor
|
Thanks! |
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.
Fixes #5048
Problem
RedisStore.storeIngress/storeIngressStatereturn nil after losing their optimistic lockmaxRetriestimes, so a lost update is reported as success:CreateIngressreturns a phantom ingress, an orphan{ingress}_state:<id>key is left behind, state transitions are dropped silently. Separately,IngressService.UpdateIngress/DeleteIngresspanic whenLoadIngressreturns an info without state, the case #4806 fixed only inIOInfoService.UpdateIngressState.Change
One commit per defect.
pkg/service/redisstore.go: after the retry loop, return an error wrappingredis.TxFailedErrinstead of nil.CreateIngressnow fails instead of returning an ingress that was never written,StoreIngressstops before creating the orphan state key, and a droppedUpdateIngressStatereaches the caller's existing error log.pkg/service/ingress.go: the Fix nil pointer dereference in IOInfoService.UpdateIngressState on concurrent DeleteIngress #4806 guard applied to the two Twirp handlers, treating a nilStateas empty.UpdateIngressthen applies and stores the request;DeleteIngressdeletes without calling the ingress service.pkg/service/redisstore.go:UpdateIngressnow fails withErrIngressNotFoundwhen the ingress no longer exists, checked inside the WATCH on theingresshash so a later delete fails the EXEC. Without it an update racing aDeleteIngressrecreated the deleted ingress and its stream key; this was possible before this PR whenever the delete landed afterLoadIngress, and the guard in 2 widened the window to the gap between its two reads.The guard stays at the call sites to match #4806 and keep API responses unchanged. Normalizing in
RedisStore.LoadIngresswould also coverListIngress(state: {}instead of omitted); happy to move it if preferred.Tests
TestIngressStoreReportsLostOptimisticLock: a go-redis hook writes to the watched key from a second connection after everyWATCH, so every attempt fails withTxFailedErrdeterministically. Asserts the error, that nothing was written, and that no state key is left behind. Needs Redis like the otherRedisStoretests.TestIngressAPIWithNilState: panics atingress.go:318/:401on master, passes with the fix.TestUpdateIngressDoesNotRecreateDeletedIngress: delete between load and update; the update fails withErrIngressNotFoundand neither the ingress, its stream key nor its room membership reappears.go test -race ./pkg/service/...andgolangci-lintv2.14.0 pass locally against Redis 7.