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

mirror: fix non-determinism in case two packages have the same path #143169

Merged
merged 1 commit into from
Mar 20, 2025

Conversation

rickystewart
Copy link
Collaborator

This code previously assumed that go mod download -json would not produce two different versions of the same dependency with the same path. This is typically a sensible assumption but no longer holds in some niche scenarios. We use replace in go.mod to effectively import two different versions of the same dependency with the same path. This results in non-determinism in the mirroring code with respect to which version of the dependency we select.

We now disambiguate with a path/version pair, which will be unique. We also add some additional validation to check assumptions so if these assumptions are ever broken in the future, the tool will fail loudly instead of proceeding silently and performing a potentially harmful operation.

Fixes #143168
Epic: CRDB-17171

Release note: None

@rickystewart rickystewart requested a review from a team as a code owner March 19, 2025 22:55
Copy link

blathers-crl bot commented Mar 19, 2025

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

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

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rickystewart rickystewart added backport-24.1.x Flags PRs that need to be backported to 24.1. backport-24.3.x Flags PRs that need to be backported to 24.3 backport-25.1.x Flags PRs that need to be backported to 25.1 labels Mar 19, 2025
This code previously assumed that `go mod download -json` would not
produce two different versions of the same dependency with the same
path. This is typically a sensible assumption but no longer holds in
some niche scenarios. We use [replace](https://github.com/cockroachdb/cockroach/blob/65b2ed4fbdf5502f3fbe0af4ddbd30a7ac7eabb4/go.mod#L500) in `go.mod`
to effectively import two different versions of the same dependency
with the same path. This results in non-determinism in the mirroring
code with respect to which version of the dependency we select.

We now disambiguate with a path/version pair, which will be unique. We
also add some additional validation to check assumptions so if these
assumptions are ever broken in the future, the tool will fail loudly
instead of proceeding silently and performing a potentially harmful
operation.

Fixes cockroachdb#143168
Epic: CRDB-17171

Release note: None
// not. We can import B many times under different
// imported names.
if _, ok := ret[mod.Path]; ok {
panic(fmt.Sprintf("found duplicate imported path: %s. This is a bug. Go tell dev-inf about it.", mod.Path))
Copy link
Member

Choose a reason for hiding this comment

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

Yes! :)

@rickystewart
Copy link
Collaborator Author

bors r=rail

craig bot pushed a commit that referenced this pull request Mar 20, 2025
143100: kv: use origin timestamp to validate lww semantics r=jeffswenson a=jeffswenson

The PR updates the implementation of put, cput, delete, and range delete
to return an error if a replicated write with an origin timestamp would
overwrite a value with a more recent origin or MVCC timestamp.

No explicit version checks are included. In a mixed-version environment,
a SQL writer running 25.1 and writing to a 25.2 KV server will encounter
"condition failed" errors if an insert would overwrite a tombstone and
retry the write until it is upgraded or the LDR PTS ages out. This is
acceptable, as LDR remains in preview and the SQL writer is neither the
default nor the recommended writer.

Release note: none
Epic: [CRDB-48647](https://cockroachlabs.atlassian.net/browse/CRDB-48647)

143169: mirror: fix non-determinism in case two packages have the same path r=rail a=rickystewart

This code previously assumed that `go mod download -json` would not produce two different versions of the same dependency with the same path. This is typically a sensible assumption but no longer holds in some niche scenarios. We use [replace](https://github.com/cockroachdb/cockroach/blob/65b2ed4fbdf5502f3fbe0af4ddbd30a7ac7eabb4/go.mod#L500) in `go.mod` to effectively import two different versions of the same dependency with the same path. This results in non-determinism in the mirroring code with respect to which version of the dependency we select.

We now disambiguate with a path/version pair, which will be unique. We also add some additional validation to check assumptions so if these assumptions are ever broken in the future, the tool will fail loudly instead of proceeding silently and performing a potentially harmful operation.

Fixes #143168
Epic: CRDB-17171

Release note: None

Co-authored-by: Jeff Swenson <[email protected]>
Co-authored-by: Ricky Stewart <[email protected]>
@craig
Copy link
Contributor

craig bot commented Mar 20, 2025

Build failed (retrying...):

@craig craig bot merged commit 982d6db into cockroachdb:master Mar 20, 2025
24 checks passed
Copy link

blathers-crl bot commented Mar 20, 2025

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 #143168: branch-release-24.1, branch-release-24.3, branch-release-25.1.


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

Copy link

blathers-crl bot commented Mar 20, 2025

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 87769f7 to release-24.1: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

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

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


error creating merge commit from 87769f7 to release-24.3: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

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

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


error creating merge commit from 87769f7 to release-25.1: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

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

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


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-24.1.x Flags PRs that need to be backported to 24.1. backport-24.3.x Flags PRs that need to be backported to 24.3 backport-25.1.x Flags PRs that need to be backported to 25.1 backport-failed target-release-25.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mirror: non-deterministic behavior if go mod list produces two packages with the same path
3 participants