[scd] Fix missing transaction timeout in SCD datastore#1402
Open
ashishjsharda wants to merge 1 commit intointeruss:masterfrom
Open
[scd] Fix missing transaction timeout in SCD datastore#1402ashishjsharda wants to merge 1 commit intointeruss:masterfrom
ashishjsharda wants to merge 1 commit intointeruss:masterfrom
Conversation
Apply context.WithTimeout in SCD Transact() so database transactions are bounded by DefaultTimeout (10s), preventing the DSS from continuing to process requests after the HTTP layer has already timed out. RID and AUX datastores already applied this pattern; SCD was missing it, causing the observed behaviour in interuss#1393 where a PUT /dss/v1/operational_intent_references request completed and committed state changes even after the client received a 503 timeout. Co-Authored-By: Ashish Sharda <ashishjsharda@users.noreply.github.com>
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 #1393
Problem
The SCD
Transact()method passed the context to CockroachDB with no deadline, so database transactions had no timeout. When a proxy timed out and dropped the client connection, the DSS continued processing and committed state changes which is the behaviour observed with the PUT /dss/v1/operational_intent_references request that completed and transitioned state to "Activated" after the client already received a 503.Fix
Apply
context.WithTimeout(ctx, DefaultTimeout)in SCD'sTransact()before executing the database transaction. This mirrors the existing pattern already used by both the RID and AUX datastores.Known Limitation
DefaultTimeoutis hardcoded to 10s in the store rather than being wired to the--server timeoutflag. This matches current RID/AUX behaviour but is not ideal .the long-term fix is an HTTP middleware/interceptor that sets a context deadline based on the flag uniformly for all handlers, as noted in the existing TODO inpkg/rid/server/v1/subscription_handler.go.