Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic split merge #1707

Merged
merged 9 commits into from
Mar 31, 2025
Merged

Topic split merge #1707

merged 9 commits into from
Mar 31, 2025

Conversation

rekby
Copy link
Member

@rekby rekby commented Mar 24, 2025

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Other information

Copy link

github-actions bot commented Mar 24, 2025

github.com/ydb-platform/ydb-go-sdk/v3/trace

compatible changes

Topic.OnReaderEndPartitionSession: added
Topic.OnReaderReceiveGRPCMessage: added
Topic.OnReaderSentGRPCMessage: added
TopicOnReaderEndPartitionSession: added
TopicOnReaderReceiveGRPCMessage: added
TopicOnReaderSentGRPCMessage: added
TopicReaderEndPartitionSessionInfo: added
TopicReaderReceiveGRPCMessageInfo: added
TopicReaderSentGRPCMessageInfo: added

summary

Base version: v3.104.8-0.20250327190759-68da27dfe590 (master)
Cannot suggest a release version.
Can only suggest a release version when compared against the most recent version of this major: v3.104.7.

@rekby rekby requested a review from Copilot March 28, 2025 13:53
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces new topic partition session events to support split and merge operations along with refinements in the reader trace and batching logic, as well as updates for auto-partitioning settings. Key changes include:

  • Adding new callbacks and trace methods for handling end partition sessions and GRPC message events.
  • Enhancing the batching mechanism to support partition flush operations.
  • Updating integration tests and client/GRPC wrapper logic to accommodate the new events and settings.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
trace/topic_gtrace.go Adds composition for OnReaderEndPartitionSession, OnReaderSentGRPCMessage, and OnReaderReceiveGRPCMessage.
trace/topic.go Introduces related event info structs and callbacks.
tests/integration/topic_partitions_balanced_test.go Adds new integration tests for split and merge partition flows.
internal/xslices/delete_old.go, delete.go Adds conditional implementation of Delete based on Go version.
internal/topic/topicreaderinternal/stream_reader_impl.go Processes EndPartitionSession events and flushes sessions accordingly.
internal/topic/topicreaderinternal/reader.go Updates the raw stream connector signature to pass readerID and trace.
internal/topic/topicreaderinternal/batcher.go Enhances batcher with sessionsForFlush management and updated lookup.
internal/topic/topicreadercommon/read_partition_session.go Adds new methods to mark partition sessions as having no more messages.
internal/grpcwrapper/rawtopic/rawtopicreader/* Updates message handling to include EndPartitionSession and GRPC trace events.
internal/grpcwrapper/rawtopic/controlplane_types.go Adds new fields and error handling for auto-partitioning settings.
internal/grpcwrapper/rawtopic/client.go Updates the StreamRead signature to accept readerID and tracer.
Comments suppressed due to low confidence (1)

internal/topic/topicreaderinternal/reader.go:26

  • [nitpick] The type name 'TopicSteamReaderConnect' appears to contain a typo; consider renaming it to 'TopicStreamReaderConnect' for improved clarity.
type TopicSteamReaderConnect func(connectionCtx context.Context, readerID int64, tracer *trace.Topic) (topicreadercommon.RawTopicReaderStream, error)

Comment on lines +336 to +337
if len(b.sessionsForFlush) > 0 && b.sessionsForFlush[0] == res.Key {
b.sessionsForFlush = xslices.Delete(b.sessionsForFlush, 0, 1)
Copy link
Preview

Copilot AI Mar 28, 2025

Choose a reason for hiding this comment

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

The code only checks and removes a flush session if it is the first element in sessionsForFlush. If flush sessions can occur in any order, consider iterating over the slice to remove any matching session instead of only checking index 0.

Suggested change
if len(b.sessionsForFlush) > 0 && b.sessionsForFlush[0] == res.Key {
b.sessionsForFlush = xslices.Delete(b.sessionsForFlush, 0, 1)
for i, session := range b.sessionsForFlush {
if session == res.Key {
b.sessionsForFlush = xslices.Delete(b.sessionsForFlush, i, 1)
break
}

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. change array during iteration is bad idea
  2. the code flush sessions in order - it is ok

@codecov-commenter
Copy link

codecov-commenter commented Mar 31, 2025

Codecov Report

Attention: Patch coverage is 75.74257% with 49 lines in your changes missing coverage. Please review.

Project coverage is 71.40%. Comparing base (68da27d) to head (5d74b11).

Files with missing lines Patch % Lines
...nternal/grpcwrapper/rawtopic/controlplane_types.go 45.23% 22 Missing and 1 partial ⚠️
...al/topic/topicreaderinternal/stream_reader_impl.go 71.42% 6 Missing and 2 partials ⚠️
...cwrapper/rawtopic/rawtopicreader/rawtopicreader.go 85.41% 4 Missing and 3 partials ⚠️
...al/grpcwrapper/rawtopic/rawtopicreader/messages.go 72.72% 2 Missing and 1 partial ⚠️
internal/topic/topicreaderinternal/batcher.go 92.10% 2 Missing and 1 partial ⚠️
internal/xslices/delete_old.go 70.00% 2 Missing and 1 partial ⚠️
.../topic/topicreadercommon/read_partition_session.go 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1707      +/-   ##
==========================================
- Coverage   71.51%   71.40%   -0.12%     
==========================================
  Files         381      383       +2     
  Lines       39688    39845     +157     
==========================================
+ Hits        28383    28450      +67     
- Misses      10176    10251      +75     
- Partials     1129     1144      +15     
Flag Coverage Δ
experiment 70.94% <76.04%> (-0.17%) ⬇️
go-1.21.x 71.09% <74.00%> (-0.07%) ⬇️
go-1.24.x 71.36% <76.04%> (-0.14%) ⬇️
integration 54.24% <72.77%> (-0.08%) ⬇️
macOS 37.67% <25.74%> (-0.04%) ⬇️
ubuntu 71.39% <75.74%> (-0.13%) ⬇️
unit 37.70% <25.74%> (-0.02%) ⬇️
windows 37.67% <25.74%> (-0.05%) ⬇️
ydb-24.1 52.07% <48.51%> (-0.24%) ⬇️
ydb-24.2 51.68% <48.51%> (-0.65%) ⬇️
ydb-24.3 52.01% <48.51%> (-0.77%) ⬇️
ydb-24.4 52.04% <48.51%> (-0.51%) ⬇️
ydb-25.1 54.11% <72.77%> (-0.03%) ⬇️
ydb-nightly 70.94% <76.04%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rekby rekby marked this pull request as ready for review March 31, 2025 15:30
@rekby rekby merged commit 3df23e2 into master Mar 31, 2025
48 checks passed
@rekby rekby deleted the topic-split-merge branch March 31, 2025 15:30
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.

2 participants