Skip to content

fix putData : detect collision on specific provided version id - #6230

Open
SylvainSenechal wants to merge 1 commit into
development/9.4from
improvement/CLDSRV-953
Open

fix putData : detect collision on specific provided version id#6230
SylvainSenechal wants to merge 1 commit into
development/9.4from
improvement/CLDSRV-953

Conversation

@SylvainSenechal

Copy link
Copy Markdown
Contributor

Issue: CLDSRV-953

The putData collision detection previously fetched the master object and compared its versionId against the incoming x-scal-version-id header. This caused issues when replicating a non-current version : the master's versionId wouldn't match, so no collision was detected and data was re-uploaded unnecessarily

Fix : decode the x-scal-version-id header in the router and use it as the metadata lookup key, so objMd is always the specific version being replicated

@bert-e

bert-e commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Hello sylvainsenechal,

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.

errorInstances.BadRequest.customizeDescription('bad request: invalid x-scal-version-id header'),
);
}
if (objMd && objMd.versionId === incomingVersionIdDecoded) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No need for objMd.versionId === incomingVersionIdDecoded anymore as the middleware is already fetching objMd for the specific versionID provided in the header

Comment thread lib/routes/routeBackbeat.js
@bert-e

bert-e commented Jul 20, 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 20, 2026

Copy link
Copy Markdown

❌ 11 Tests Failed:

Tests completed Failed Passed Skipped
9874 11 9863 0
View the full list of 11 ❄️ flaky test(s)
"after each" hook for "should batch delete 1000 objects"::Multi-Object Delete Success "after each" hook for "should batch delete 1000 objects"

Flake rate in main: 100.00% (Passed 0 times, Failed 7 times)

Stack Traces | 1.13s run time
The bucket you tried to delete is not empty.
"before each" hook for "should batch delete 1000 objects"::Multi-Object Delete Success "before each" hook for "should batch delete 1000 objects"

Flake rate in main: 100.00% (Passed 0 times, Failed 7 times)

Stack Traces | 5.32s run time
Socket timed out without establishing a connection within 5000 ms
"before each" hook for "should grant read access"::With default signature PUT Bucket ACL using predefined groups - authenticated request "before each" hook for "should grant read access"

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.1s run time
We encountered an internal error. Please try again.
"before each" hook for "should grant read access"::With default signature PUT Bucket ACL using predefined groups - unauthenticated request "before each" hook for "should grant read access"

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.168s run time
We encountered an internal error. Please try again.
"before each" hook for "should grant read access"::With default signature PUT Object ACL using predefined groups - authenticated request "before each" hook for "should grant read access"

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.035s run time
We encountered an internal error. Please try again.
"before each" hook for "should grant read access"::With default signature PUT Object ACL using predefined groups - unauthenticated request "before each" hook for "should grant read access"

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.125s run time
We encountered an internal error. Please try again.
"before each" hook for "should grant read access"::With v4 signature PUT Bucket ACL using predefined groups - authenticated request "before each" hook for "should grant read access"

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.06s run time
We encountered an internal error. Please try again.
"before each" hook for "should grant read access"::With v4 signature PUT Bucket ACL using predefined groups - unauthenticated request "before each" hook for "should grant read access"

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.329s run time
We encountered an internal error. Please try again.
"before each" hook for "should grant read access"::With v4 signature PUT Object ACL using predefined groups - authenticated request "before each" hook for "should grant read access"

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.393s run time
We encountered an internal error. Please try again.
"before each" hook for "should grant read access"::With v4 signature PUT Object ACL using predefined groups - unauthenticated request "before each" hook for "should grant read access"

Flake rate in main: 100.00% (Passed 0 times, Failed 10 times)

Stack Traces | 0.067s run time
We encountered an internal error. Please try again.
should allow action on an object specified in the policy::With default signature Bucket policies with resource statement should allow action on an object specified in the policy

Flake rate in main: 13.81% (Passed 668 times, Failed 107 times)

Stack Traces | 40s run time
Timeout of 40000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (.../test/bucket/bucketPolicyWithResourceStatements.js)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@scality scality deleted a comment from bert-e Jul 20, 2026
@SylvainSenechal
SylvainSenechal force-pushed the improvement/CLDSRV-953 branch from 148ca98 to 18d305d Compare July 20, 2026 16:26
@SylvainSenechal
SylvainSenechal requested review from a team, benzekrimaha, Copilot, delthas and maeldonn and removed request for benzekrimaha July 20, 2026 16:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Backbeat putData collision detection for replication of non-current object versions by ensuring the metadata lookup targets the specific replicated version (from x-scal-version-id) rather than always using the master version.

Changes:

  • Decode x-scal-version-id in the Backbeat router for PUT /_/backbeat/data and use it as the versionId for metadata lookup so objMd corresponds to the replicated version.
  • Simplify collision detection in putData to treat the presence of that specific version’s objMd as a collision (while explicitly excluding ExternalNullVersionId / "null").
  • Add functional test coverage for collisions on a non-current version and adjust the "null" version test to cover cases where a master already exists.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/functional/backbeat/putData.js Adds/updates functional tests to validate collision behavior for non-current versions and "null" version behavior.
lib/routes/routeBackbeat.js Uses decoded x-scal-version-id to fetch version-specific metadata for putData, fixing collision detection semantics.

@maeldonn maeldonn 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.

Logic is fine, need a little refactor

}
if (objMd && objMd.versionId === incomingVersionIdDecoded) {
// Data already at destination for this version; return 409 with the existing
if (objMd) {

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.

if (objMd) only means "this version exists" because the router's isPutDataApi block fetched the header version instead of the master; that coupling is easy to break. Clearer to drop the router block and fetch the version here with metadataGetObject (returns undefined when missing):

const incomingVersionId = decode(incomingVersionIdEncoded);
// ... BadRequest on decode error ...
return metadataGetObject(request.bucketName, request.objectKey, incomingVersionId, null, log, (err, versionMd) => {
    if (err) {
        return callback(err);
    }
    if (versionMd) {
        // existing 409 conflict path, using versionMd.microVersionId
    }
    return writeData();
});

// For putData api: the version to check is passed
// via x-scal-version-id header, not the URL query. Fetch that specific
// version so objMd matches the replicated version, not always the master.
const isPutDataApi = request.method === 'PUT' && request.resourceType === 'data';

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 router shouldn't special-case one handler, and these guards duplicate putData's. Move the version lookup into putData itself (see handler comment) so this block goes away.

const versionIdHeader = request.headers['x-scal-version-id'];
if (versionIdHeader !== undefined && versionIdHeader !== ExternalNullVersionId) {
const decoded = decode(versionIdHeader);
if (!(decoded instanceof Error)) {

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.

Decode failure is ignore, should it be handled ?

@bert-e

bert-e commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Incorrect fix version

The Fix Version/s in issue CLDSRV-953 contains:

  • 9.4.0

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

  • 9.4.2

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

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.

5 participants