Skip to content

Commit 6602143

Browse files
authored
Merge pull request #8865 from dannyzaken/danny-fixes
Added an index for deleted unreclaimed blocks
2 parents 56ca1a1 + 983d5f2 commit 6602143

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/server/object_services/schemas/data_block_indexes.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ module.exports = [{
1515
}
1616
}
1717
},
18+
{
19+
fields: {
20+
_id: 1,
21+
},
22+
options: {
23+
unique: false,
24+
// mongo does not support partial indexes on _id field
25+
// This is a workaround to exclude it for mongo for tests purposes
26+
postgres_only: true,
27+
name: "deleted_not_reclaimed",
28+
partialFilterExpression: {
29+
deleted: { $exists: true },
30+
reclaimed: { $exists: false }
31+
}
32+
}
33+
},
1834
{
1935
// iterate_node_chunks()
2036
// count_blocks_of_node()

src/util/mongo_client.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ class MongoCollection {
3333
MongoCollection.implements_interface(this);
3434
this.schema = col.schema;
3535
this.name = col.name;
36-
this.db_indexes = col.db_indexes;
36+
this.db_indexes = col.db_indexes?.filter(index => !index?.options?.postgres_only);
3737
this.mongo_client = mongo_client;
38-
3938
}
4039

4140
/**
@@ -46,9 +45,9 @@ class MongoCollection {
4645
}
4746

4847
/**
49-
*
50-
* @param {object} doc
51-
* @param {'warn'} [warn]
48+
*
49+
* @param {object} doc
50+
* @param {'warn'} [warn]
5251
*/
5352
validate(doc, warn) {
5453
if (this.schema) {
@@ -553,7 +552,7 @@ class MongoClient extends EventEmitter {
553552
}
554553

555554
/**
556-
*
555+
*
557556
* @returns {nb.DBCollection}
558557
*/
559558
define_collection(col) {
@@ -585,7 +584,7 @@ class MongoClient extends EventEmitter {
585584
}
586585

587586
/**
588-
*
587+
*
589588
* @returns {nb.DBCollection}
590589
*/
591590
collection(col_name) {

0 commit comments

Comments
 (0)