Spaces:
Paused
Paused
deploy fea5985b
Browse files- lib/mongoPool.ts +5 -1
- scripts/check-shards.mjs +1 -1
lib/mongoPool.ts
CHANGED
|
@@ -106,7 +106,11 @@ async function usage(group: ShardGroup): Promise<number[]> {
|
|
| 106 |
dbs.map(async (db) => {
|
| 107 |
try {
|
| 108 |
const s = await db.command({ dbStats: 1, scale: 1 })
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
} catch {
|
| 111 |
return 0 // unreachable shard: don't let a probe failure block writes
|
| 112 |
}
|
|
|
|
| 106 |
dbs.map(async (db) => {
|
| 107 |
try {
|
| 108 |
const s = await db.command({ dbStats: 1, scale: 1 })
|
| 109 |
+
// dataSize, NOT storageSize. Atlas bills uncompressed BSON plus indexes;
|
| 110 |
+
// storageSize is the compressed on-disk figure and reads ~40% lower, so
|
| 111 |
+
// using it reports a cluster as half full when Atlas has already blocked
|
| 112 |
+
// writes on it.
|
| 113 |
+
return (s.dataSize ?? 0) + (s.indexSize ?? 0)
|
| 114 |
} catch {
|
| 115 |
return 0 // unreachable shard: don't let a probe failure block writes
|
| 116 |
}
|
scripts/check-shards.mjs
CHANGED
|
@@ -45,7 +45,7 @@ for (const [group, prefix, collection] of [
|
|
| 45 |
await client.connect()
|
| 46 |
const db = client.db(DB_NAME)
|
| 47 |
const stats = await db.command({ dbStats: 1, scale: 1 })
|
| 48 |
-
const used = (stats.
|
| 49 |
const pct = ((used / QUOTA) * 100).toFixed(1)
|
| 50 |
const cols = (await db.listCollections().toArray()).map((c) => c.name)
|
| 51 |
const docs = cols.includes(collection)
|
|
|
|
| 45 |
await client.connect()
|
| 46 |
const db = client.db(DB_NAME)
|
| 47 |
const stats = await db.command({ dbStats: 1, scale: 1 })
|
| 48 |
+
const used = (stats.dataSize ?? 0) + (stats.indexSize ?? 0)
|
| 49 |
const pct = ((used / QUOTA) * 100).toFixed(1)
|
| 50 |
const cols = (await db.listCollections().toArray()).map((c) => c.name)
|
| 51 |
const docs = cols.includes(collection)
|