Skip to content

fix(csharp): prevent Thrift buffer corruption on cancellation - #706

Open
vuanhphung wants to merge 2 commits into
mainfrom
stack/drain-status-poll-on-dispose
Open

vuanhphung wants to merge 2 commits into
mainfrom
stack/drain-status-poll-on-dispose

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Cancellation during Thrift serialization can leave partial bytes that corrupt the next cleanup RPC, consistent with CLOUDFETCH-014's intermittent failure. The race is reproduced locally; the original CI transport trace was unavailable.

Finish in-memory request writes without cancellation so HTTP flush can reset the buffer. Semaphore waits, flushes, and response reads remain cancellable. Restore linked heartbeat cancellation to avoid waiting for the request timeout on stop, and suppress shutdown-related poll errors.

Validation: 17 regression cases fail before the fix; 116 related unit tests pass. All supported driver targets and net472 tests compile. Static checks pass except Apache RAT, blocked by its artifact download. Live workspace tests and Windows execution were not run.

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 Medium

Looks good — a well-targeted fix with strong regression coverage. Making the per-poll timeoutCts independent of the stop token correctly prevents Stop()/Dispose() from aborting an in-flight status poll mid-serialization (the root cause of the lost CloseOperation), while the ThrowIfCancellationRequested() pre-check keeps prompt exit when stop precedes serialization, and the 30s timeout still bounds a hung poll. One medium note: disposal now blocks up to the full request timeout when the server is unresponsive (acknowledged in the PR) — raised inline for a human to weigh a bounded drain.

Comment thread csharp/src/Reader/DatabricksOperationStatusPoller.cs Outdated
@vuanhphung vuanhphung added integration-test Trigger integration tests in internal repo e2e-test Trigger E2E tests on this PR labels Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Integration tests triggered! View workflow run

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Integration tests triggered! View workflow run

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
@github-actions github-actions Bot removed the integration-test Trigger integration tests in internal repo label Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔒 Integration test approval reset

New commits were pushed to this PR. The integration-test label has been automatically removed for security.

A maintainer must re-review the changes and re-add the label to trigger tests again.

Why is this necessary?
  • New code requires fresh security review
  • Prevents approved PRs from adding malicious code later
  • Ensures all tested code has been explicitly approved

Latest commit: b6d58d1

@vuanhphung vuanhphung changed the title fix(csharp): drain active status polls before disposal fix(csharp): prevent Thrift buffer corruption on cancellation Oct 13, 2026
@vuanhphung vuanhphung removed the e2e-test Trigger E2E tests on this PR label Oct 13, 2026

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

@vuanhphung vuanhphung added integration-test Trigger integration tests in internal repo e2e-test Trigger E2E tests on this PR labels Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Integration tests triggered! View workflow run

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Integration tests triggered! View workflow run

This branch has not been deployed

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

Labels

ai-assisted e2e-test Trigger E2E tests on this PR integration-test Trigger integration tests in internal repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant