Skip to content

Commit 3aabb04

Browse files
authored
Merge pull request #8508 from dannyzaken/danny-postgres-pools
2 parents 9bce005 + 7ddd87d commit 3aabb04

File tree

5 files changed

+153
-83
lines changed

5 files changed

+153
-83
lines changed

config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,15 @@ config.S3_RESTORE_REQUEST_MAX_DAYS_BEHAVIOUR = 'TRUNCATE';
199199
/**
200200
* S3_MAX_KEY_LENGTH controls the maximum key length that will be accepted
201201
* by NooBaa endpoints.
202-
*
202+
*
203203
* This value is 1024 bytes for S3 but the default is `Infinity`
204204
*/
205205
config.S3_MAX_KEY_LENGTH = Infinity;
206206

207207
/**
208208
* S3_MAX_BUCKET_NAME_LENGTH controls the maximum bucket name length that
209209
* will be accepted by NooBaa endpoints.
210-
*
210+
*
211211
* This value is 63 bytes for S3 but the default is `Infinity`
212212
*/
213213
config.S3_MAX_BUCKET_NAME_LENGTH = Infinity;
@@ -229,7 +229,8 @@ config.ROOT_KEY_MOUNT = '/etc/noobaa-server/root_keys';
229229

230230
config.DB_TYPE = /** @type {nb.DBType} */ (process.env.DB_TYPE || 'postgres');
231231

232-
config.POSTGRES_MAX_CLIENTS = (process.env.LOCAL_MD_SERVER === 'true') ? 80 : 10;
232+
config.POSTGRES_DEFAULT_MAX_CLIENTS = 10;
233+
config.POSTGRES_MD_MAX_CLIENTS = (process.env.LOCAL_MD_SERVER === 'true') ? 70 : 10;
233234

234235
///////////////////
235236
// SYSTEM CONFIG //

src/deploy/NVA_build/standalone_deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const config = exports;
1515
config.DEFAULT_POOL_TYPE = 'HOSTS';
1616
config.AGENT_RPC_PORT = '9999';
1717
config.AGENT_RPC_PROTOCOL = 'tcp';
18-
config.POSTGRES_MAX_CLIENTS = 10;
18+
config.POSTGRES_DEFAULT_MAX_CLIENTS = 10;
1919
EOF
2020

2121
# setup_env is not needed when running inside a container because the container

src/server/object_services/md_store.js

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,43 @@ const config = require('../../../config');
3030
class MDStore {
3131

3232
constructor(test_suffix = '') {
33+
34+
35+
const postgres_pool = 'md';
36+
3337
this._objects = db_client.instance().define_collection({
3438
name: 'objectmds' + test_suffix,
3539
schema: object_md_schema,
3640
db_indexes: object_md_indexes,
41+
postgres_pool,
3742
});
3843
this._multiparts = db_client.instance().define_collection({
3944
name: 'objectmultiparts' + test_suffix,
4045
schema: object_multipart_schema,
4146
db_indexes: object_multipart_indexes,
47+
postgres_pool,
4248
});
4349
this._parts = db_client.instance().define_collection({
4450
name: 'objectparts' + test_suffix,
4551
schema: object_part_schema,
4652
db_indexes: object_part_indexes,
53+
postgres_pool,
4754
});
4855
this._chunks = db_client.instance().define_collection({
4956
name: 'datachunks' + test_suffix,
5057
schema: data_chunk_schema,
5158
db_indexes: data_chunk_indexes,
59+
postgres_pool,
5260
});
5361
this._blocks = db_client.instance().define_collection({
5462
name: 'datablocks' + test_suffix,
5563
schema: data_block_schema,
5664
db_indexes: data_block_indexes,
65+
postgres_pool,
5766
});
5867
this._sequences = db_client.instance().define_sequence({
5968
name: 'mdsequences' + test_suffix,
69+
postgres_pool,
6070
});
6171
}
6272

@@ -248,19 +258,16 @@ class MDStore {
248258
async remove_objects_and_unset_latest(objs) {
249259
if (!objs || !objs.length) return;
250260

251-
await this._objects.updateMany(
252-
{
253-
_id: {
254-
$in: objs.map(obj => obj._id),
255-
}
256-
},
257-
{
258-
$set: {
259-
deleted: new Date(),
260-
version_past: true,
261-
},
261+
await this._objects.updateMany({
262+
_id: {
263+
$in: objs.map(obj => obj._id),
262264
}
263-
);
265+
}, {
266+
$set: {
267+
deleted: new Date(),
268+
version_past: true,
269+
},
270+
});
264271
}
265272

266273
// 2, 3, 4
@@ -1362,7 +1369,7 @@ class MDStore {
13621369
}
13631370

13641371
/**
1365-
*
1372+
*
13661373
* @param {{
13671374
* tier: nb.ID,
13681375
* limit: number,
@@ -1387,14 +1394,14 @@ class MDStore {
13871394
}
13881395

13891396
return this._chunks
1390-
.find(selectors, {
1391-
projection: { _id: 1 },
1392-
hint: "tiering_index",
1393-
sort,
1394-
limit,
1395-
})
1397+
.find(selectors, {
1398+
projection: { _id: 1 },
1399+
hint: "tiering_index",
1400+
sort,
1401+
limit,
1402+
})
13961403

1397-
.then(chunks => db_client.instance().uniq_ids(chunks, "_id"));
1404+
.then(chunks => db_client.instance().uniq_ids(chunks, "_id"));
13981405
}
13991406

14001407

@@ -1775,8 +1782,7 @@ class MDStore {
17751782
find_deleted_blocks(max_delete_time, limit) {
17761783
const query = {
17771784
deleted: {
1778-
$lt: new Date(max_delete_time),
1779-
$exists: true // Force index usage
1785+
$lt: new Date(max_delete_time)
17801786
},
17811787
};
17821788
return this._blocks.find(query, {

src/test/system_tests/ceph_s3_tests/run_ceph_test_on_test_container.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export JWT_SECRET=123456789
2525
export NOOBAA_ROOT_SECRET='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
2626
export LOCAL_MD_SERVER=true
2727

28+
#The default max connections for postgres is 100. limit max clients to 10 per pool (per process).
29+
export CONFIG_JS_POSTGRES_MD_MAX_CLIENTS=10
30+
export CONFIG_JS_POSTGRES_DEFAULT_MAX_CLIENTS=10
31+
2832
export POSTGRES_HOST=${POSTGRES_HOST:-localhost}
2933
export MGMT_ADDR=wss://${NOOBAA_MGMT_SERVICE_HOST:-localhost}:${NOOBAA_MGMT_SERVICE_PORT:-5443}
3034
export BG_ADDR=wss://localhost:5445

0 commit comments

Comments
 (0)