Skip to content

sql/copy: fix rare flake in TestLargeCopy#160764

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
yuzefovich:fix-copy-flake
Jan 10, 2026
Merged

sql/copy: fix rare flake in TestLargeCopy#160764
craig[bot] merged 1 commit intocockroachdb:masterfrom
yuzefovich:fix-copy-flake

Conversation

@yuzefovich
Copy link
Copy Markdown
Member

We have automatic retry mechanism for COPY but it can only be used for non-atomic COPY. If we have the atomic COPY and hit a txn retry error, it's bubbled up to the client. We now adjust TestLargeCopy to match this behavior fixing a rare flake where we'd fail the test on the txn retry error when we should've ignored it.

Fixes: #160537.
Release note: None

We have automatic retry mechanism for COPY but it can only be used for
non-atomic COPY. If we have the atomic COPY and hit a txn retry error,
it's bubbled up to the client. We now adjust `TestLargeCopy` to match
this behavior fixing a rare flake where we'd fail the test on the txn
retry error when we should've ignored it.

Release note: None
@yuzefovich yuzefovich requested review from a team and michae2 January 9, 2026 11:29
@yuzefovich yuzefovich added backport-25.3.x Flags PRs that need to be backported to 25.3 backport-25.4.x Flags PRs that need to be backported to 25.4 backport-26.1.x Flags PRs that need to be backported to 26.1 labels Jan 9, 2026
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@yuzefovich
Copy link
Copy Markdown
Member Author

For context, the relevant block is

cockroach/pkg/sql/copy_from.go

Lines 1171 to 1193 in a10d701

// It is currently only safe to retry if we are not in atomic copy
// mode & we are in an implicit transaction.
//
// NOTE: we cannot re-use the connExecutor retry scheme here as COPY
// consumes directly from the read buffer, and the data would no
// longer be available during the retry.
if c.implicitTxn && !c.p.SessionData().CopyFromAtomicEnabled && c.p.SessionData().CopyFromRetriesEnabled {
log.SqlExec.Infof(ctx, "%s is retrying", c.copyFromAST.String())
if c.p.ExecCfg().TestingKnobs.CopyFromInsertRetry != nil {
if err := c.p.ExecCfg().TestingKnobs.CopyFromInsertRetry(); err != nil {
return err
}
}
continue
} else {
log.SqlExec.Infof(
ctx,
"%s is not retrying; "+
"implicit: %v; copy_from_atomic_enabled: %v; copy_from_retryable_enabled %v",
c.copyFromAST.String(), c.implicitTxn,
c.p.SessionData().CopyFromAtomicEnabled, c.p.SessionData().CopyFromRetriesEnabled,
)
}

Copy link
Copy Markdown
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

:lgtm: Thanks!

@michae2 reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @yuzefovich).

@yuzefovich
Copy link
Copy Markdown
Member Author

TFTR!

bors r+

craig bot pushed a commit that referenced this pull request Jan 9, 2026
160632: sql/bulkmerge: reuse SST iterator across bulk merge tasks r=spilchen a=spilchen

This change reduces overhead in the bulk merge processor by initializing a single iterator over all input SSTs at startup, rather than creating a new one per task. The iterator is reused across tasks, seeking only when needed.

Informs #159414
Epic: CRDB-48845
Release note: none

Co-authored by: `@jeffswenson`

160760: execbuilder: fix a stats-related flake in a new test r=yuzefovich a=yuzefovich

Fixes: #160752.
Fixes: #160753.
Release note: None

160764: sql/copy: fix rare flake in TestLargeCopy r=yuzefovich a=yuzefovich

We have automatic retry mechanism for COPY but it can only be used for non-atomic COPY. If we have the atomic COPY and hit a txn retry error, it's bubbled up to the client. We now adjust `TestLargeCopy` to match this behavior fixing a rare flake where we'd fail the test on the txn retry error when we should've ignored it.

Fixes: #160537.
Release note: None

Co-authored-by: Matt Spilchen <matt.spilchen@cockroachlabs.com>
Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 10, 2026

Build failed (retrying...):

craig bot pushed a commit that referenced this pull request Jan 10, 2026
160760: execbuilder: fix a stats-related flake in a new test r=yuzefovich a=yuzefovich

Fixes: #160752.
Fixes: #160753.
Release note: None

160764: sql/copy: fix rare flake in TestLargeCopy r=yuzefovich a=yuzefovich

We have automatic retry mechanism for COPY but it can only be used for non-atomic COPY. If we have the atomic COPY and hit a txn retry error, it's bubbled up to the client. We now adjust `TestLargeCopy` to match this behavior fixing a rare flake where we'd fail the test on the txn retry error when we should've ignored it.

Fixes: #160537.
Release note: None

Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 10, 2026

Build failed (retrying...):

craig bot pushed a commit that referenced this pull request Jan 10, 2026
160764: sql/copy: fix rare flake in TestLargeCopy r=yuzefovich a=yuzefovich

We have automatic retry mechanism for COPY but it can only be used for non-atomic COPY. If we have the atomic COPY and hit a txn retry error, it's bubbled up to the client. We now adjust `TestLargeCopy` to match this behavior fixing a rare flake where we'd fail the test on the txn retry error when we should've ignored it.

Fixes: #160537.
Release note: None

Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 10, 2026

Build failed:

@yuzefovich
Copy link
Copy Markdown
Member Author

bors retry

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 10, 2026

@craig craig bot merged commit 7403428 into cockroachdb:master Jan 10, 2026
25 checks passed
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Jan 10, 2026

Based on the specified backports for this PR, I applied new labels to the following linked issue(s). Please adjust the labels as needed to match the branches actually affected by the issue(s), including adding any known older branches.


Issue #160537: branch-release-25.3, branch-release-25.4, branch-release-26.1.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Jan 10, 2026

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from ae6e38c to blathers/backport-release-25.3-160764: POST https://api.github.com/repos/yuzefovich/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 25.3.x failed. See errors above.


error creating merge commit from ae6e38c to blathers/backport-release-25.4-160764: POST https://api.github.com/repos/yuzefovich/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 25.4.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@yuzefovich yuzefovich deleted the fix-copy-flake branch January 10, 2026 02:42
@yuzefovich yuzefovich removed backport-failed backport-25.3.x Flags PRs that need to be backported to 25.3 backport-25.4.x Flags PRs that need to be backported to 25.4 labels Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-26.1.x Flags PRs that need to be backported to 26.1 v26.2.0-prerelease

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg/sql/copy/copy_test: TestLargeCopy failed

3 participants