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

Mongodb 6.x #12087

Merged
merged 1 commit into from
Oct 15, 2023
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 install/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"lru-cache": "10.0.1",
"mime": "3.0.0",
"mkdirp": "3.0.1",
"mongodb": "5.9.0",
"mongodb": "6.1.0",
"morgan": "1.10.0",
"mousetrap": "1.6.5",
"multiparty": "4.2.3",
Expand Down
1 change: 0 additions & 1 deletion public/language/en-GB/admin/advanced/database.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"mongo.file-size": "File Size",
"mongo.resident-memory": "Resident Memory",
"mongo.virtual-memory": "Virtual Memory",
"mongo.mapped-memory": "Mapped Memory",
"mongo.bytes-in": "Bytes In",
"mongo.bytes-out": "Bytes Out",
"mongo.num-requests": "Number of Requests",
Expand Down
9 changes: 6 additions & 3 deletions src/database/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,9 @@ mongoModule.info = async function (db) {
indexSizes: collectionInfo.indexSizes,
}));

stats.mem = serverStatus.mem || { resident: 0, virtual: 0, mapped: 0 };
stats.mem = serverStatus.mem || { resident: 0, virtual: 0 };
stats.mem.resident = (stats.mem.resident / 1024).toFixed(3);
stats.mem.virtual = (stats.mem.virtual / 1024).toFixed(3);
stats.mem.mapped = (stats.mem.mapped / 1024).toFixed(3);
stats.collectionData = listCollections;
stats.network = serverStatus.network || { bytesIn: 0, bytesOut: 0, numRequests: 0 };
stats.network.bytesIn = (stats.network.bytesIn / scale).toFixed(3);
Expand All @@ -170,7 +169,11 @@ mongoModule.info = async function (db) {

async function getCollectionStats(db) {
const items = await db.listCollections().toArray();
return await Promise.all(items.map(collection => db.collection(collection.name).stats()));
return await Promise.all(
items.map(collection => db.collection(collection.name).aggregate([
{ $collStats: { latencyStats: {}, storageStats: {}, count: {} } },
]))
);
}

mongoModule.close = async function () {
Expand Down
1 change: 1 addition & 0 deletions src/database/mongo/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ module.exports = function (module) {
$inc: increment,
}, {
returnDocument: 'after',
includeResultMetadata: true,
upsert: true,
});
cache.del(key);
Expand Down
1 change: 1 addition & 0 deletions src/database/mongo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ module.exports = function (module) {
$inc: { data: 1 },
}, {
returnDocument: 'after',
includeResultMetadata: true,
upsert: true,
});
return result && result.value ? result.value.data : null;
Expand Down
1 change: 1 addition & 0 deletions src/database/mongo/sorted.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ module.exports = function (module) {
$inc: data,
}, {
returnDocument: 'after',
includeResultMetadata: true,
upsert: true,
});
return result && result.value ? result.value.score : null;
Expand Down
1 change: 0 additions & 1 deletion src/views/admin/advanced/database.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<hr/>
<div class="d-flex justify-content-between"><span>[[admin/advanced/database:mongo.resident-memory]]</span> <span class="text-end">[[admin/advanced/database:x-gb, {mongo.mem.resident}]]</span></div>
<div class="d-flex justify-content-between"><span>[[admin/advanced/database:mongo.virtual-memory]]</span> <span class="text-end">[[admin/advanced/database:x-gb, {mongo.mem.virtual}]]</span></div>
<div class="d-flex justify-content-between"><span>[[admin/advanced/database:mongo.mapped-memory]]</span> <span class="text-end">[[admin/advanced/database:x-gb, {mongo.mem.mapped}]]</span></div>
<hr/>
<div class="d-flex justify-content-between"><span>[[admin/advanced/database:mongo.bytes-in]]</span> <span class="text-end">[[admin/advanced/database:x-gb, {mongo.network.bytesIn}]]</span></div>
<div class="d-flex justify-content-between"><span>[[admin/advanced/database:mongo.bytes-out]]</span> <span class="text-end">[[admin/advanced/database:x-gb, {mongo.network.bytesOut}]]</span></div>
Expand Down