feat: Add support for MongoDB driver options serverSelectionTimeoutMS, maxIdleTimeMS, heartbeatFrequencyMS (#9910)

This commit is contained in:
Manuel
2025-11-07 20:11:12 +01:00
committed by GitHub
parent d5e7d6e0f6
commit 1b661e98c8
5 changed files with 33 additions and 0 deletions

View File

@@ -78,6 +78,9 @@ describe('Config Keys', () => {
maxStalenessSeconds: 10,
maxPoolSize: 10,
minPoolSize: 5,
serverSelectionTimeoutMS: 5000,
maxIdleTimeMS: 60000,
heartbeatFrequencyMS: 10000,
connectTimeoutMS: 5000,
socketTimeoutMS: 5000,
autoSelectFamily: true,

View File

@@ -1164,6 +1164,18 @@ module.exports.DatabaseOptions = {
action: parsers.booleanParser,
default: false,
},
heartbeatFrequencyMS: {
env: 'PARSE_SERVER_DATABASE_HEARTBEAT_FREQUENCY_MS',
help:
'The MongoDB driver option to specify the frequency in milliseconds at which the driver checks the state of the MongoDB deployment.',
action: parsers.numberParser('heartbeatFrequencyMS'),
},
maxIdleTimeMS: {
env: 'PARSE_SERVER_DATABASE_MAX_IDLE_TIME_MS',
help:
'The MongoDB driver option to specify the amount of time in milliseconds that a connection can remain idle in the connection pool before being removed and closed.',
action: parsers.numberParser('maxIdleTimeMS'),
},
maxPoolSize: {
env: 'PARSE_SERVER_DATABASE_MAX_POOL_SIZE',
help:
@@ -1199,6 +1211,12 @@ module.exports.DatabaseOptions = {
'The duration in seconds after which the schema cache expires and will be refetched from the database. Use this option if using multiple Parse Servers instances connected to the same database. A low duration will cause the schema cache to be updated too often, causing unnecessary database reads. A high duration will cause the schema to be updated too rarely, increasing the time required until schema changes propagate to all server instances. This feature can be used as an alternative or in conjunction with the option `enableSchemaHooks`. Default is infinite which means the schema cache never expires.',
action: parsers.numberParser('schemaCacheTtl'),
},
serverSelectionTimeoutMS: {
env: 'PARSE_SERVER_DATABASE_SERVER_SELECTION_TIMEOUT_MS',
help:
'The MongoDB driver option to specify the amount of time in milliseconds for a server to be considered suitable for selection.',
action: parsers.numberParser('serverSelectionTimeoutMS'),
},
socketTimeoutMS: {
env: 'PARSE_SERVER_DATABASE_SOCKET_TIMEOUT_MS',
help:

View File

@@ -252,12 +252,15 @@
* @property {Boolean} createIndexUserUsernameCaseInsensitive Set to `true` to automatically create a case-insensitive index on the username field of the _User collection on server start. Set to `false` to skip index creation. Default is `true`.<br><br>⚠️ When setting this option to `false` to manually create the index, keep in mind that the otherwise automatically created index may change in the future to be optimized for the internal usage by Parse Server.
* @property {Boolean} disableIndexFieldValidation Set to `true` to disable validation of index fields. When disabled, indexes can be created even if the fields do not exist in the schema. This can be useful when creating indexes on fields that will be added later.
* @property {Boolean} enableSchemaHooks Enables database real-time hooks to update single schema cache. Set to `true` if using multiple Parse Servers instances connected to the same database. Failing to do so will cause a schema change to not propagate to all instances and re-syncing will only happen when the instances restart. To use this feature with MongoDB, a replica set cluster with [change stream](https://docs.mongodb.com/manual/changeStreams/#availability) support is required.
* @property {Number} heartbeatFrequencyMS The MongoDB driver option to specify the frequency in milliseconds at which the driver checks the state of the MongoDB deployment.
* @property {Number} maxIdleTimeMS The MongoDB driver option to specify the amount of time in milliseconds that a connection can remain idle in the connection pool before being removed and closed.
* @property {Number} maxPoolSize The MongoDB driver option to set the maximum number of opened, cached, ready-to-use database connections maintained by the driver.
* @property {Number} maxStalenessSeconds The MongoDB driver option to set the maximum replication lag for reads from secondary nodes.
* @property {Number} maxTimeMS The MongoDB driver option to set a cumulative time limit in milliseconds for processing operations on a cursor.
* @property {Number} minPoolSize The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver.
* @property {Boolean} retryWrites The MongoDB driver option to set whether to retry failed writes.
* @property {Number} schemaCacheTtl The duration in seconds after which the schema cache expires and will be refetched from the database. Use this option if using multiple Parse Servers instances connected to the same database. A low duration will cause the schema cache to be updated too often, causing unnecessary database reads. A high duration will cause the schema to be updated too rarely, increasing the time required until schema changes propagate to all server instances. This feature can be used as an alternative or in conjunction with the option `enableSchemaHooks`. Default is infinite which means the schema cache never expires.
* @property {Number} serverSelectionTimeoutMS The MongoDB driver option to specify the amount of time in milliseconds for a server to be considered suitable for selection.
* @property {Number} socketTimeoutMS The MongoDB driver option to specify the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout.
*/

View File

@@ -624,6 +624,12 @@ export interface DatabaseOptions {
minPoolSize: ?number;
/* The MongoDB driver option to set the maximum number of opened, cached, ready-to-use database connections maintained by the driver. */
maxPoolSize: ?number;
/* The MongoDB driver option to specify the amount of time in milliseconds for a server to be considered suitable for selection. */
serverSelectionTimeoutMS: ?number;
/* The MongoDB driver option to specify the amount of time in milliseconds that a connection can remain idle in the connection pool before being removed and closed. */
maxIdleTimeMS: ?number;
/* The MongoDB driver option to specify the frequency in milliseconds at which the driver checks the state of the MongoDB deployment. */
heartbeatFrequencyMS: ?number;
/* The MongoDB driver option to specify the amount of time, in milliseconds, to wait to establish a single TCP socket connection to the server before raising an error. Specifying 0 disables the connection timeout. */
connectTimeoutMS: ?number;
/* The MongoDB driver option to specify the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout. */

View File

@@ -234,6 +234,9 @@ export interface DatabaseOptions {
maxStalenessSeconds?: number;
minPoolSize?: number;
maxPoolSize?: number;
serverSelectionTimeoutMS?: number;
maxIdleTimeMS?: number;
heartbeatFrequencyMS?: number;
connectTimeoutMS?: number;
socketTimeoutMS?: number;
autoSelectFamily?: boolean;