Skip to content

Support conditional writes on versioned puts in putObjectVerCase3 - #2678

Merged
bert-e merged 7 commits into
development/8.5from
improvement/ARSN-619
Aug 14, 2026
Merged

Support conditional writes on versioned puts in putObjectVerCase3#2678
bert-e merged 7 commits into
development/8.5from
improvement/ARSN-619

Conversation

@maeldonn

@maeldonn maeldonn commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Adds params.conditions support to putObjectVerCase3 so a version-specific put
becomes an atomic compare-and-write, failing with PreconditionFailed when the
stored version does not satisfy the condition.
Needed by CLDSRV-952.

Issue: ARSN-619

@maeldonn
maeldonn requested review from a team, SylvainSenechal and delthas July 23, 2026 10:40
@bert-e

bert-e commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Hello maeldonn,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@scality scality deleted a comment from bert-e Jul 23, 2026
@bert-e

bert-e commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.73684% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.63%. Comparing base (abad717) to head (d624af5).
⚠️ Report is 7 commits behind head on development/8.5.

Files with missing lines Patch % Lines
...orage/metadata/mongoclient/MongoClientInterface.ts 87.50% 2 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           development/8.5    #2678      +/-   ##
===================================================
+ Coverage            74.60%   74.63%   +0.02%     
===================================================
  Files                  227      227              
  Lines                18578    18603      +25     
  Branches              3844     3849       +5     
===================================================
+ Hits                 13861    13884      +23     
- Misses                4712     4714       +2     
  Partials                 5        5              

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maeldonn
maeldonn requested review from benzekrimaha and removed request for delthas July 23, 2026 11:13
@maeldonn
maeldonn marked this pull request as ready for review July 23, 2026 11:13
Comment thread lib/storage/metadata/mongoclient/MongoClientInterface.ts
Comment thread lib/storage/metadata/mongoclient/MongoClientInterface.ts Outdated
Comment thread tests/functional/metadata/mongodb/putObject.spec.js
Comment thread lib/storage/metadata/bucketclient/BucketClientInterface.js Outdated
Comment thread lib/storage/metadata/MetadataWrapper.js Outdated

@SylvainSenechal SylvainSenechal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The logic in putObjectVer3 is fine for me

Some discussion to have directly about the rejection of params.conditions

@bert-e

bert-e commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

The following reviewers are expecting changes from the author, or must review again:

@maeldonn
maeldonn force-pushed the improvement/ARSN-619 branch from fa9abec to aab2ae1 Compare July 24, 2026 14:09
Comment thread lib/storage/metadata/mongoclient/MongoClientInterface.ts
@maeldonn
maeldonn requested a review from SylvainSenechal July 24, 2026 14:37
Comment thread lib/storage/metadata/bucketclient/BucketClientInterface.js Outdated

@benzekrimaha benzekrimaha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One design comment, rest looks solid (good test coverage on the condition paths).

this.client.putObject(bucketName, objName, JSON.stringify(objVal),
log.getSerializedUids(), cb, params);
// reject rather than silently perform an unconditional write
if (params && params.conditions) {

@benzekrimaha benzekrimaha Jul 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no point guarding per backend: check params.conditions && !this.supportsConditionalPutObjectMD() once in MetadataWrapper.putObjectMD, that also covers the memory/file backends, which currently ignore conditions silently.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I talked with Maël, we are just not gonna do this at all : no need to return an error, params.conditions existed before this pr and was ignored.
This pr is more of a best effort to have better database consistency, adding it to mongo for now without touching metadata is fine

Comment thread tests/functional/metadata/mongodb/putObject.spec.js Outdated
Comment thread lib/storage/metadata/mongoclient/MongoClientInterface.ts Outdated
@SylvainSenechal
SylvainSenechal force-pushed the improvement/ARSN-619 branch 2 times, most recently from 8a4259c to 4701790 Compare August 12, 2026 20:31
Comment thread lib/storage/metadata/mongoclient/utils.ts
Comment thread lib/storage/metadata/mongoclient/MongoClientInterface.ts
},
],
[
'should throw when two sibling fields both contain a structural operator of the same type',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why does this throw : it looks like a valid expression to me, should it not work?

we support (or do we actually?) a query on multiple fields: { fieldA: 4, fieldB: "foo" }, so we should support when the value on each field is an expression?

(maybe not blocking, but weird enough that we should look at it, at least in a followup...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm gonna document it in the code, its a limitation of the current algo used, but we can still express the same thing by using explicit $and

SylvainSenechal and others added 5 commits August 14, 2026 16:32
Translate params.conditions into the version document filter so callers
can perform an atomic compare-and-write on an existing version. An
existing version failing the condition is rejected with
PreconditionFailed; duplicate key errors on the master operation remain
retryable InternalError.

Issue: ARSN-619
Replace the magic 11000 literal with MONGODB_DUPLICATE_KEY_ERROR
across MongoClientInterface, and expand the comment on the
conditional-write rejection path in putObjectVerCase3.

Issue: ARSN-619
@scality scality deleted a comment from bert-e Aug 14, 2026

@delthas delthas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Not a fan of the pseudo abstraction we're extending here (that wants Mongo operators, so not super abstract in the end), but that's the code we have 😛

Looks like prettier is complaining. Maybe add a "run prettier" commit before all your commits first then ensure each commit is prettier-passing?

@scality scality deleted a comment from bert-e Aug 14, 2026
@scality scality deleted a comment from SylvainSenechal Aug 14, 2026
@bert-e

bert-e commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

The following reviewers are expecting changes from the author, or must review again:

@scality scality deleted a comment from bert-e Aug 14, 2026
@francoisferrand

Copy link
Copy Markdown
Contributor

/bypass_author_approval

@bert-e

bert-e commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

The following reviewers are expecting changes from the author, or must review again:

The following options are set: bypass_author_approval

@bert-e

bert-e commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

I have successfully merged the changeset of this pull request
into targetted development branches:

  • ✔️ development/8.5

The following branches have NOT changed:

  • development/6.4
  • development/7.10
  • development/7.4
  • development/7.70
  • development/8.1
  • development/8.2
  • development/8.3
  • development/8.4

This pull request did not target the following hotfix branch(es) so they
were left untouched:

  • hotfix/7.10.2
  • hotfix/7.10.4
  • hotfix/7.4.2
  • hotfix/6.4.7
  • hotfix/7.5.0
  • hotfix/7.70.25
  • hotfix/7.10.29
  • hotfix/7.4.1
  • hotfix/7.4.4
  • hotfix/7.9.0
  • hotfix/7.8.0
  • hotfix/7.6.0
  • hotfix/7.10.57
  • hotfix/7.70.4
  • hotfix/7.2.0
  • hotfix/7.4.9
  • hotfix/7.70.14
  • hotfix/7.4.5
  • hotfix/7.4.0
  • hotfix/7.4.7
  • hotfix/7.7.0
  • hotfix/7.10.36
  • hotfix/7.10.1
  • hotfix/7.4.8
  • hotfix/7.10.47
  • hotfix/8.2.48
  • hotfix/7.4.10
  • hotfix/7.70.20
  • hotfix/7.4.3
  • hotfix/7.4.6
  • hotfix/7.10.3
  • hotfix/7.10.31
  • hotfix/7.10.0
  • hotfix/7.10.43
  • hotfix/7.10.46

Please check the status of the associated issue ARSN-619.

Goodbye maeldonn.

The following options are set: bypass_author_approval

@bert-e
bert-e merged commit d624af5 into development/8.5 Aug 14, 2026
14 checks passed
@SylvainSenechal

Copy link
Copy Markdown
Contributor

/approve

@bert-e
bert-e deleted the improvement/ARSN-619 branch August 14, 2026 15:27
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.

7 participants