Skip to content

fix: propagate context for cancellable imports#803

Open
ashnaaseth2325-oss wants to merge 1 commit intoOneBusAway:mainfrom
ashnaaseth2325-oss:fix/gtfsdb-context-propagation
Open

fix: propagate context for cancellable imports#803
ashnaaseth2325-oss wants to merge 1 commit intoOneBusAway:mainfrom
ashnaaseth2325-oss:fix/gtfsdb-context-propagation

Conversation

@ashnaaseth2325-oss
Copy link
Copy Markdown
Contributor

SUMMARY

This PR fixes a context propagation issue in the GTFS import flow that prevented database operations from being cancellable during shutdown. The change ensures the caller’s context.Context is properly passed through instead of being overridden.

Primary changes are in gtfsdb/helpers.go and gtfsdb/client.go, specifically around processAndStoreGTFSDataWithSource and its callers.


FIX

// Before 
func (c *Client) processAndStoreGTFSDataWithSource(b []byte, source string) error {
    ctx := context.Background()
}

// After 
func (c *Client) processAndStoreGTFSDataWithSource(ctx context.Context, b []byte, source string) error {
}

VERIFICATION

Tested by triggering a GTFS import and sending a SIGTERM while it was still processing. Before this change, the app would hang for minutes waiting for the DB writes to finish. Now, the import cancels immediately and the service shuts down cleanly without delay.

Replace hardcoded context.Background() with the caller-supplied context
so in-flight DB imports can be cancelled on shutdown or timeout.

Signed-off-by: ashnaaseth2325-oss <ashnaaseth2325@gmail.com>
@ashnaaseth2325-oss
Copy link
Copy Markdown
Contributor Author

Hello @aaronbrethorst
This change ensures GTFS imports respect the caller’s context, allowing them to be cancelled during shutdown. It helps avoid long-running DB operations blocking a clean and timely exit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant