Skip to content
Open
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: 2 additions & 0 deletions src/server/object_services/schemas/data_chunk_indexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module.exports = [{
{
fields: {
dedup_key: 1,
system: 1,
bucket: 1
},
options: {
unique: false,
Expand Down
23 changes: 23 additions & 0 deletions src/upgrade/upgrade_scripts/5.21.0/remove_datachunks_index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* Copyright (C) 2025 NooBaa */
"use strict";

async function run({ dbg, db_client }) {
/* After the index is dropped, a new composite index (system, bucket, dedup_key)
will be created during bootstrap */
const indexName = 'idx_btree_datachunks_dedup_key';

try {
const pool = db_client.instance().get_pool();
await pool.query(`DROP INDEX IF EXISTS ${indexName};`);

dbg.log0("Executed upgrade script for dropping index ", indexName);
} catch (err) {
dbg.error('An error ocurred in the upgrade process:', err);
throw err;
}
Comment on lines +9 to +17
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Tighten error logging message (typo and missing context).

Functionally this looks good and idempotent; only nit is the error log text. There’s a typo and the message doesn’t mention which index failed, which can hinder debugging.

-  } catch (err) {
-    dbg.error('An error ocurred in the upgrade process:', err);
-    throw err;
-  }
+  } catch (err) {
+    dbg.error('An error occurred while dropping index', indexName, err);
+    throw err;
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try {
const pool = db_client.instance().get_pool();
await pool.query(`DROP INDEX IF EXISTS ${indexName};`);
dbg.log0("Executed upgrade script for dropping index ", indexName);
} catch (err) {
dbg.error('An error ocurred in the upgrade process:', err);
throw err;
}
try {
const pool = db_client.instance().get_pool();
await pool.query(`DROP INDEX IF EXISTS ${indexName};`);
dbg.log0("Executed upgrade script for dropping index ", indexName);
} catch (err) {
dbg.error('An error occurred while dropping index', indexName, err);
throw err;
}
🤖 Prompt for AI Agents
In src/upgrade/upgrade_scripts/5.21.0/remove_datachunks_index.js around lines 9
to 17, the catch block's log message has a typo ("ocurred") and lacks context
about which index failed; update the dbg.error call to use the correct spelling
("occurred") and include the indexName and the error object in the message so
the log clearly shows which index failed and why (e.g., construct a single error
string or pass indexName and err to dbg.error).

}

module.exports = {
run,
description: 'Delete the "idx_btree_datachunks_dedup_key" index'
};