Skip to content

fix: speed on ReadN #279

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

Merged
merged 6 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/logrepl/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (i *CDCIterator) NextN(ctx context.Context, n int) ([]opencdc.Record, error
return nil, fmt.Errorf("n must be greater than 0, got %d", n)
}

recs := make([]opencdc.Record, 0, n)
var recs []opencdc.Record

// Block until at least one record is received or context is canceled
select {
Expand Down
2 changes: 1 addition & 1 deletion source/logrepl/cdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ func TestCDCIterator_NextN(t *testing.T) {
}

// Will keep calling NextN until all records are received
var records []opencdc.Record
records := make([]opencdc.Record, 0, 2)
for len(records) < 2 {
recordsTmp, err := i.NextN(ctx, 5)
is.NoErr(err)
Expand Down
2 changes: 1 addition & 1 deletion source/logrepl/combined.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (c *CombinedIterator) NextN(ctx context.Context, n int) ([]opencdc.Record,
}

sdk.Logger(ctx).Debug().Msg("Snapshot completed, switching to CDC mode")
return c.activeIterator.NextN(ctx, n)
return c.NextN(ctx, n)
}
return records, nil
}
Expand Down
2 changes: 1 addition & 1 deletion source/logrepl/combined_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func TestCombinedIterator_NextN(t *testing.T) {
is.NoErr(err)

// Request 2 records in CDC mode
var records []opencdc.Record
records := make([]opencdc.Record, 0, 2)
var retries int
maxRetries := 10
for retries < maxRetries {
Expand Down