Skip to content

support params.conditions in all putObject cases - #2691

Open
maeldonn wants to merge 5 commits into
development/8.5from
improvement/ARSN-624
Open

support params.conditions in all putObject cases#2691
maeldonn wants to merge 5 commits into
development/8.5from
improvement/ARSN-624

Conversation

@maeldonn

Copy link
Copy Markdown
Contributor

Issue: ARSN-624

@bert-e

bert-e commented Aug 31, 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
/bypass_source_branch_lineage Bypass the cross-branch contamination check
/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.
/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.

@bert-e

bert-e commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Incorrect fix version

The Fix Version/s in issue ARSN-624 contains:

  • None

Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:

  • 8.5.16

Please check the Fix Version/s of ARSN-624, or the target
branch of this pull request.

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.70%. Comparing base (0bbe970) to head (f5351d0).

Files with missing lines Patch % Lines
...orage/metadata/mongoclient/MongoClientInterface.ts 85.71% 7 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           development/8.5    #2691      +/-   ##
===================================================
+ Coverage            74.65%   74.70%   +0.05%     
===================================================
  Files                  227      227              
  Lines                18606    18644      +38     
  Branches              3850     3893      +43     
===================================================
+ Hits                 13890    13928      +38     
  Misses                4711     4711              
  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.

@bert-e

bert-e commented Aug 31, 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

@maeldonn
maeldonn force-pushed the improvement/ARSN-624 branch 2 times, most recently from ed67a15 to 17203c5 Compare August 31, 2026 13:09
@scality scality deleted a comment from claude Bot Aug 31, 2026
Comment thread lib/storage/metadata/mongoclient/MongoClientInterface.ts Outdated
@maeldonn
maeldonn force-pushed the improvement/ARSN-624 branch from 17203c5 to 7202dad Compare August 31, 2026 13:34
Factor the params.conditions translation used by putObjectVerCase3 into a
shared buildConditionsFilter helper, so the other put cases can reuse it.

Issue: ARSN-624
Apply the translated conditions to the master upsert filter of the
suspended-versioning put. A failing condition turns the upsert into an
insert of an existing key, which is reported as PreconditionFailed.

Issue: ARSN-624
Apply the translated conditions to the master upsert filter of the
non-versioned put, reporting a failing condition as PreconditionFailed.

Issue: ARSN-624
Apply the translated conditions to the lookup filter of the oplog update
path. Conditions are nested under $and so that a condition using $or does
not collide with the deleted flag filter, and an unmatched condition is
reported as PreconditionFailed instead of NoSuchKey.

Issue: ARSN-624
Apply the translated conditions to the version upsert filter of the
repairMaster put. A failing condition turns the upsert into an insert of
an existing key, which is reported as PreconditionFailed. The master
repair itself is left unconditional.

Issue: ARSN-624
@maeldonn
maeldonn force-pushed the improvement/ARSN-624 branch from 7202dad to f5351d0 Compare August 31, 2026 13:35
@maeldonn
maeldonn requested review from a team, DarkIsDude and francoisferrand August 31, 2026 13:36
@maeldonn
maeldonn marked this pull request as ready for review August 31, 2026 13:36
objVal.versionId = versionId;
const masterKey = formatMasterKey(objName, params.vFormat);
c.updateOne({ _id: masterKey }, { $set: { value: objVal }, $setOnInsert: { _id: masterKey } }, { upsert: true })
const filter = buildConditionsFilter('putObjectVerCase2', { _id: masterKey }, params.conditions, log);

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.

is this case (putObjectVerCase2) used for metadata updates as well, or just for creating new versions in the suspended-versioning case?
(conditional updates should only be used for, well, updates 😇... Not sure if I see an issue here, but I think it's better to double-think this, and make sure we have predictable outcome...)

}
const key = formatMasterKey(objName, params.vFormat);
const putFilter = { _id: key };
const putFilter = buildConditionsFilter('putObjectNoVer', { _id: key }, params?.conditions, log);

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.

same: can we distinguish object "replacement" from actual "metadata updates" ? do we need to, or can it be part of the "conditional update semantics" ?

Comment on lines +1424 to +1429
const conditionsFilter = buildConditionsFilter('putObjectNoVerWithOplogUpdate', {}, params.conditions, log);
if (!conditionsFilter) {
return cb(errors.InternalError);
}
// conditions go under $and to leave the deleted flag $or above untouched
findFilter.$and = [conditionsFilter];

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 not like the others:

Suggested change
const conditionsFilter = buildConditionsFilter('putObjectNoVerWithOplogUpdate', {}, params.conditions, log);
if (!conditionsFilter) {
return cb(errors.InternalError);
}
// conditions go under $and to leave the deleted flag $or above untouched
findFilter.$and = [conditionsFilter];
const findFilters = buildConditionsFilter('putObjectNoVerWithOplogUpdate', {
...putFilter,
...notDeletedFilter,
}, params.conditions, log);
if (!putFilter) {
return cb(errors.InternalError);
}

if (!doc?.value) {
if (hasConditions(params.conditions)) {
// a transiently deleted document is absent, not a condition mismatch
return collection.findOne({ ...putFilter, ...notDeletedFilter }).then(existing => {

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.

that looks fishy (if we can't find it, we can't).....and I think this is actually not correct : conditional updates is for updates (i.e. modifying metadata: transition, replication status...), which should never go through this code (which "builds" a fake oplog update entry, to simulate the ObjMD was deleted then created) ?

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