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

release-20.2: importccl: avoid random() collisions between KV batches #61630

Merged
merged 1 commit into from
Mar 15, 2021

Conversation

pbardea
Copy link
Contributor

@pbardea pbardea commented Mar 8, 2021

Backport 1/1 commits from #61214.

/cc @cockroachdb/release


An import may parallelize the work to convert SQL rows into KVs. During
this phase, default expressions are evaluated. Previously, IMPORT's
implementations of random number generates that are evaluated in default
expressions assumed that all of the given row IDs were contiguous. This
is not the case since 1 row converter may be responsible for converting
several non-contiguous batches of rows. This resulted in random_values
colliding between different batches of KV space.

This commit fixes this bug by feeding in the current position and
resetting the random source backing these methods. This ensures that
import treats a new contiguous batch of rows separately.

Fixes #61203.

Release justification: bug fix
Release note (bug fix): Fix a bug where random numbers generated as
default expressions during IMPORT would collide a few hundred rows apart
from eachother.

@pbardea pbardea requested review from miretskiy and a team March 8, 2021 16:58
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@pbardea pbardea force-pushed the backport20.2-61214 branch from b4554d6 to 47392df Compare March 9, 2021 17:38
@pbardea
Copy link
Contributor Author

pbardea commented Mar 10, 2021

Huh, this is failing due to an error when trying to export to userfile locations. Put up #61789 and will rebase once that's in.

@pbardea pbardea force-pushed the backport20.2-61214 branch from 47392df to f0d93e6 Compare March 10, 2021 23:13
An import may parallelize the work to convert SQL rows into KVs. During
this phase, default expressions are evaluated. Previously, IMPORT's
implementations of random number generates that are evaluated in default
expressions assumed that all of the given row IDs were contiguous. This
is not the case since 1 row converter may be responsible for converting
several non-contiguous batches of rows. This resulted in random_values
colliding between different batches of KV space.

This commit fixes this bug by feeding in the current position and
resetting the random source backing these methods. This ensures that
import treats a new contiguous batch of rows separately.

Release justification: bug fix
Release note (bug fix): Fix a bug where random numbers generated as
default expressions during IMPORT would collide a few hundred rows apart
from each-other.
@pbardea pbardea force-pushed the backport20.2-61214 branch from f0d93e6 to 8a311c8 Compare March 12, 2021 21:34
@pbardea pbardea merged commit fc5e756 into cockroachdb:release-20.2 Mar 15, 2021
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.

3 participants