diff --git a/CRR/ReplicationStatusUpdater.js b/CRR/ReplicationStatusUpdater.js index c1a0495f..6216ff40 100644 --- a/CRR/ReplicationStatusUpdater.js +++ b/CRR/ReplicationStatusUpdater.js @@ -1,3 +1,4 @@ +const crypto = require('crypto'); const { doWhilst, eachSeries, eachLimit, waterfall, } = require('async'); @@ -72,6 +73,14 @@ class ReplicationStatusUpdater { this.forceUsingConfiguration = forceUsingConfiguration; this.log = log; + // Random replicationGroupId (7 chars) and instanceId (6 chars) for + // microVersionId generation: this tool bypasses CloudServer's + // configured values, so per-instance random tokens prevent + // collisions with concurrent writers. Sizes match LENGTH_RG and + // LENGTH_ID in arsenal's VersionID module. + this.replicationGroupId = crypto.randomBytes(4).toString('hex').slice(0, 7); + this.instanceId = crypto.randomBytes(3).toString('hex').slice(0, 6); + this._setupClients(); this.logProgressInterval = setInterval(this._logProgress.bind(this), LOG_PROGRESS_INTERVAL_MS); @@ -193,7 +202,7 @@ class ReplicationStatusUpdater { return process.nextTick(next); } - objMD.updateMicroVersionId(); + objMD.updateMicroVersionId(this.instanceId, this.replicationGroupId); const md = objMD.getSerialized(); return this.cloudserverclient.putMetadata({ Bucket: bucket, diff --git a/package.json b/package.json index a3f63fa4..ba942c8c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "s3utils", - "version": "1.18.0", + "version": "1.19.0", "engines": { "node": ">= 22" },