Skip to content

fix(streamtimeout): exempt bulk export/import methods - #3143

Open
ivanauth wants to merge 3 commits into
authzed:mainfrom
ivanauth:fix/exempt-bulk-export-from-streamtimeout
Open

fix(streamtimeout): exempt bulk export/import methods#3143
ivanauth wants to merge 3 commits into
authzed:mainfrom
ivanauth:fix/exempt-bulk-export-from-streamtimeout

Conversation

@ivanauth

Copy link
Copy Markdown
Contributor

The streaming-timeout interceptor cancels a stream if the server is silent for StreamingAPITimeout (default 30s), assuming a hung client. Bulk export/import legitimately go silent for long stretches between batches on large datasets, so the interceptor was cancelling healthy streams (clients saw RST_STREAM NO_ERROR).

Add WithExemptMethods to the interceptor and exempt:

  • PermissionsService/ExportBulkRelationships
  • PermissionsService/ImportBulkRelationships
  • ExperimentalService/BulkExportRelationships
  • ExperimentalService/BulkImportRelationships

All other streaming methods keep the timeout.

@ivanauth
ivanauth requested a review from a team as a code owner May 29, 2026 15:15
@github-actions github-actions Bot added area/api v1 Affects the v1 API area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels May 29, 2026
@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.10526% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/middleware/streamtimeout/streamtimeout.go 81.25% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@ivanauth
ivanauth force-pushed the fix/exempt-bulk-export-from-streamtimeout branch from be4ad12 to c4cb74c Compare June 5, 2026 23:00
@ivanauth
ivanauth force-pushed the fix/exempt-bulk-export-from-streamtimeout branch 3 times, most recently from 0a289b6 to 31c2837 Compare June 29, 2026 19:00
@ivanauth ivanauth closed this Jun 29, 2026
@ivanauth ivanauth reopened this Jun 29, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 29, 2026
@ivanauth ivanauth closed this Jun 29, 2026
@ivanauth ivanauth reopened this Jun 29, 2026
@ivanauth ivanauth closed this Jul 1, 2026
@ivanauth ivanauth reopened this Jul 1, 2026
@ivanauth
ivanauth force-pushed the fix/exempt-bulk-export-from-streamtimeout branch from 31c2837 to 8f82315 Compare July 1, 2026 19:51
@ivanauth ivanauth closed this Jul 1, 2026
@ivanauth ivanauth reopened this Jul 1, 2026
@ivanauth
ivanauth force-pushed the fix/exempt-bulk-export-from-streamtimeout branch from 8f82315 to 31c2837 Compare July 1, 2026 19:58
@ivanauth
ivanauth force-pushed the fix/exempt-bulk-export-from-streamtimeout branch from 31c2837 to 9a2a70d Compare July 13, 2026 14:24
@ivanauth
ivanauth force-pushed the fix/exempt-bulk-export-from-streamtimeout branch from 9a2a70d to 14e04c8 Compare July 24, 2026 17:49
@tstirrat15
tstirrat15 force-pushed the fix/exempt-bulk-export-from-streamtimeout branch from 9371e98 to 5b2b3c6 Compare August 4, 2026 21:18
Comment thread internal/services/v1/experimental.go Outdated
streamtimeout.MustStreamServerInterceptor(
config.StreamReadTimeout,
// Bulk export/import are designed to run for arbitrarily long
// periods on large datasets; their inter-batch gaps regularly

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm curious about these inter-batch gaps? why do they happen?

Signed-off-by: ivanauth <ivan@authzed.com>
…ing it

Messages received from the client now reset the stream timeout, so the timeout
bounds inactivity rather than the total duration of a call. Bulk import is
therefore no longer capped at the streaming-api timeout regardless of how
actively the client is sending, and because the timer stops once the client
half-closes, committing the import is not bounded either.

Bulk import is no longer exempt: it holds an open write transaction with retries
disabled for the life of the stream, so removing every server-side bound on it
is not worth the write-pool exposure. Bulk export stays exempt, since it sends
one batch per datastore page and holds no transaction or connection in between.

Also corrects the flag help text, which still listed ExportBulkRelationships as
covered, in both serve.go and the checked-in docs/spicedb.md that the docs
workflow publishes.

Tests cover the client-streaming shape that regressed, and a single interceptor
with one exempt and one non-exempt method to catch an over-broad exemption.
@ivanauth
ivanauth force-pushed the fix/exempt-bulk-export-from-streamtimeout branch from 31817be to a9f87e9 Compare August 6, 2026 19:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area/api v1 Affects the v1 API area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants