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

bf: S3UTILS-180 unbounded number of sproxyd keys in Map #325

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ObjectRepair/SproxydKeysSubscribers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DuplicateSproxydKeyFoundHandler {
this._getObjectURL = getObjectURL;
this.queue = queue(this._repairObject, 1);
// use OBJECT_REPAIR_DUPLICATE_KEYS_WINDOW_SIZE since there will be at least one sproxyd key per object
this.visitedObjects = new BoundedMap(env.DUPLICATE_KEYS_WINDOW_SIZE);
this.visitedObjects = new BoundedMap(env.OBJECT_REPAIR_DUPLICATE_KEYS_WINDOW_SIZE);
}

/**
Expand Down
20 changes: 14 additions & 6 deletions ObjectRepair/env.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
const env = {
OBJECT_REPAIR_BUCKETD_HOSTPORT: process.env.OBJECT_REPAIR_BUCKETD_HOSTPORT,
OBJECT_REPAIR_SPROXYD_HOSTPORT: process.env.OBJECT_REPAIR_SPROXYD_HOSTPORT,
OBJECT_REPAIR_RAFT_SESSION_ID: process.env.OBJECT_REPAIR_RAFT_SESSION_ID,
OBJECT_REPAIR_RAFT_LOG_BATCH_SIZE: process.env.OBJECT_REPAIR_RAFT_LOG_BATCH_SIZE || 1000,
OBJECT_REPAIR_LOOKBACK_WINDOW: process.env.OBJECT_REPAIR_LOOKBACK_WINDOW || 10000,
OBJECT_REPAIR_LOG_LEVEL: process.env.OBJECT_REPAIR_LOG_LEVEL || 'info',
OBJECT_REPAIR_DUMP_LEVEL: process.env.OBJECT_REPAIR_DUMP_LEVEL || 'error',
OBJECT_REPAIR_LOG_INTERVAL: process.env.OBJECT_REPAIR_LOG_INTERVAL || 300,
OBJECT_REPAIR_DUPLICATE_KEYS_WINDOW_SIZE:
Number.parseInt(process.env.OBJECT_REPAIR_DUPLICATE_KEYS_WINDOW_SIZE, 10) || 100000,
OBJECT_REPAIR_LOG_INTERVAL:
Number.parseInt(process.env.OBJECT_REPAIR_LOG_INTERVAL, 10) || 300,
OBJECT_REPAIR_LOG_LEVEL: process.env.OBJECT_REPAIR_LOG_LEVEL || 'info',
OBJECT_REPAIR_LOOKBACK_WINDOW:
Number.parseInt(process.env.OBJECT_REPAIR_LOOKBACK_WINDOW, 10) || 10000,
OBJECT_REPAIR_RAFT_LOG_BATCH_SIZE:
Number.parseInt(process.env.OBJECT_REPAIR_RAFT_LOG_BATCH_SIZE, 10) || 1000,
OBJECT_REPAIR_RAFT_LOG_BEGIN_SEQ:
Number.parseInt(process.env.OBJECT_REPAIR_RAFT_LOG_BEGIN_SEQ, 10) || null,
OBJECT_REPAIR_RAFT_SESSION_ID:
Number.parseInt(process.env.OBJECT_REPAIR_RAFT_SESSION_ID, 10) || undefined,
OBJECT_REPAIR_SPROXYD_HOSTPORT: process.env.OBJECT_REPAIR_SPROXYD_HOSTPORT,
};

module.exports = { env };
12 changes: 5 additions & 7 deletions ObjectRepair/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,26 @@ Optional environment variables:
OBJECT_REPAIR_TLS_CA_PATH: path to TLS alternate CA file
`;
for (const [key, value] of Object.entries(env)) {
if (!value) {
if (value === undefined) {
log.info(`${key} must be defined`);
console.error(USAGE);
process.exit(1);
}
}

env.OBJECT_REPAIR_RAFT_LOG_BEGIN_SEQ = process.env.OBJECT_REPAIR_RAFT_LOG_BEGIN_SEQ;

/**
* Creates new reader and runs until stop().
* @returns {undefined}
*/
function runJournalReader() {
if (env.OBJECT_REPAIR_RAFT_LOG_BEGIN_SEQ === undefined) {
if (env.OBJECT_REPAIR_RAFT_LOG_BEGIN_SEQ === null) {
log.info('OBJECT_REPAIR_RAFT_LOG_BEGIN_SEQ is not defined.'
+ 'Ingestion will start at latest cseq - OBJECT_REPAIR_LOOKBACK_WINDOW');
}
const reader = new RaftJournalReader(
Number.parseInt(env.OBJECT_REPAIR_RAFT_LOG_BEGIN_SEQ, 10),
Number.parseInt(env.OBJECT_REPAIR_RAFT_LOG_BATCH_SIZE, 10),
Number.parseInt(env.OBJECT_REPAIR_RAFT_SESSION_ID, 10),
env.OBJECT_REPAIR_RAFT_LOG_BEGIN_SEQ,
env.OBJECT_REPAIR_RAFT_LOG_BATCH_SIZE,
env.OBJECT_REPAIR_RAFT_SESSION_ID,
);
reader.run();
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s3utils",
"version": "1.14.13",
"version": "1.14.14",
"engines": {
"node": ">= 16"
},
Expand Down