Skip to content

feat(go): add stream/topic purge API with BDD tests and fix server purge bug - #3608

Open
chengxilo wants to merge 22 commits into
apache:masterfrom
chengxilo:feat/go-sdk-purge-stream-topic
Open

feat(go): add stream/topic purge API with BDD tests and fix server purge bug#3608
chengxilo wants to merge 22 commits into
apache:masterfrom
chengxilo:feat/go-sdk-purge-stream-topic

Conversation

@chengxilo

@chengxilo chengxilo commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR address?

Relates to #2148

Rationale

Go SDK doesn't have the purge topic/ purge stream API, so this PR implement them. To test it, I added an new BDD test scenario, and implemented both Go and Rust BDD tests.

What changed?

The Go SDK was missing PurgeStream and PurgeTopic methods. Added them along with a shared BDD scenario (stream_topic_purge.feature) and implementations in both Go and Rust.

While testing, discovered that purge_all_segments only cleared on-disk segments but left stale messages in the journal and in-flight tiers. Polling after purge would return messages that should have been deleted. Fixed by calling journal.reset() and clear_in_flight() during partition re-initialization. I am not famliar with Rust server code so during the code review this part worth more attention

Local Execution

  • Passed
  • Pre-commit hooks ran

AI Usage

  1. DeepSeek pro v4, Claude Opus 4.6
  2. DeepSeek pro v4 for BDD test implementation, Claude Opus 4.6 for server bug fixing(bug doesn't exists anymore now, 9/2/2026).
  3. I reviewed them with my best effert, the bdd scripts are executed and actually works, and they found that there is a bug in the server so I believe test test works.
  4. I hope so.

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Jul 4, 2026
@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.13%. Comparing base (f45f9dd) to head (13df54c).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
foreign/go/internal/command/stream.go 0.00% 4 Missing ⚠️
foreign/go/internal/command/topic.go 0.00% 4 Missing ⚠️
foreign/go/client/tcp/tcp_stream_management.go 0.00% 3 Missing ⚠️
foreign/go/client/tcp/tcp_topic_management.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3608      +/-   ##
============================================
- Coverage     85.15%   85.13%   -0.02%     
  Complexity     1402     1402              
============================================
  Files          1230     1226       -4     
  Lines        181317   181327      +10     
  Branches     147611   147607       -4     
============================================
- Hits         154392   154376      -16     
- Misses        22874    22907      +33     
+ Partials       4051     4044       -7     
Components Coverage Δ
Rust Core 86.06% <ø> (-0.02%) ⬇️
Java SDK 67.29% <ø> (ø)
C# SDK 75.53% <ø> (ø)
Python SDK 90.06% <ø> (ø)
PHP SDK 85.65% <ø> (ø)
Node SDK 96.24% <ø> (ø)
Go SDK 69.19% <0.00%> (-0.12%) ⬇️
Files with missing lines Coverage Δ
foreign/go/client/tcp/tcp_stream_management.go 78.04% <0.00%> (-6.17%) ⬇️
foreign/go/client/tcp/tcp_topic_management.go 87.27% <0.00%> (-5.04%) ⬇️
foreign/go/internal/command/stream.go 85.00% <0.00%> (-9.45%) ⬇️
foreign/go/internal/command/topic.go 83.01% <0.00%> (-3.26%) ⬇️

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chengxilo chengxilo changed the title test(sdk): add stream/topic purge scenario, go/rust implemented, one server purge bug fixed feat(go): add stream/topic purge API with BDD tests and fix server purge bug Jul 4, 2026
@hubcio

hubcio commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@chengxilo i'll check this during the weekend. could you please rebase?

@hubcio hubcio added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Jul 9, 2026
@numinnex

numinnex commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

I've checked whether there is potential concurrency issue due to interleaving of flush + purge commands as this is what I've reckon from the changes could potentially be an issue and did not find any problems with that. Let's wait for @hubcio review and we can merge it.

@chengxilo
chengxilo force-pushed the feat/go-sdk-purge-stream-topic branch from 8bc60d8 to f5d74d9 Compare July 14, 2026 02:08
@chengxilo

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Jul 14, 2026
@chengxilo

Copy link
Copy Markdown
Contributor Author

nothing has been changed, just because I rebased onto master locally so it was forced pushed() I shouldn't do that tho.

@chengxilo
chengxilo force-pushed the feat/go-sdk-purge-stream-topic branch from 9b5e79c to a604653 Compare July 25, 2026 22:29
@hubcio

hubcio commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@chengxilo could you please rebase again? i will review this today

@chengxilo

chengxilo commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@chengxilo could you please rebase again? i will review this today

done. Currently, we get the pre-purge messages back for roughly > a second. I'm not sure if we should justify it in BDD test or fix it. Previously for the non-VSR it was fixed. But not for the VSR enabled one. (since according to the comments, it was intended)

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

If you need a review, please ensure CI is green and the PR is rebased on the latest master. Don't hesitate to ping the maintainers - either @core on Discord or by mentioning them directly here on the PR.

Thank you for your contribution!

@github-actions github-actions Bot added the S-stale Inactive issue or pull request label Aug 22, 2026
@github-actions github-actions Bot removed the S-stale Inactive issue or pull request label Aug 22, 2026
@slbotbm

slbotbm commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

@chengxilo Seems the rust bdd test is failing?

/author

@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Aug 23, 2026
Comment on lines +33 to +34
And I poll messages from stream "purge-test-stream", topic "purge-topic", partition 0 starting from offset 0
Then I should receive 0 messages

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.

Could we wait for purge convergence before polling here? The purge command commits a new purge generation, but the partition reconciler clears the messages on a later tick. This immediate poll can therefore still see pre-purge data and make this scenario flaky (faced this while writing tests for cpp). Consider adding bounded retry/wait logic before asserting the message count. The same applies to the other immediate post-purge polls in this feature.

Comment thread scripts/run-bdd-tests.sh
@chengxilo

chengxilo commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

@chengxilo Seems the rust bdd test is failing?

/author

Yes, I am wondering if this is a behavior that need to be fixed. Though in the comment in server side, it seems to be expected. (I mean like... I personally don't like this behavior.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

If you need a review, please ensure CI is green and the PR is rebased on the latest master. Don't hesitate to ping the maintainers - either @core on Discord or by mentioning them directly here on the PR.

Thank you for your contribution!

@github-actions github-actions Bot added the S-stale Inactive issue or pull request label Aug 31, 2026
@github-actions github-actions Bot removed the S-stale Inactive issue or pull request label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author PR is waiting on author response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants