diff --git a/spec/ParseConfigKey.spec.js b/spec/ParseConfigKey.spec.js index a8f62681d9..fe7556123b 100644 --- a/spec/ParseConfigKey.spec.js +++ b/spec/ParseConfigKey.spec.js @@ -81,6 +81,11 @@ describe('Config Keys', () => { maxTimeMS: 1000, maxStalenessSeconds: 10, maxPoolSize: 10, + minPoolSize: 5, + connectTimeoutMS: 5000, + socketTimeoutMS: 5000, + autoSelectFamily: true, + autoSelectFamilyAttemptTimeout: 3000 }, })).toBeResolved(); expect(loggerErrorSpy.calls.all().reduce((s, call) => s += call.args[0], '')).not.toMatch(invalidKeyErrorMessage); diff --git a/src/Options/Definitions.js b/src/Options/Definitions.js index a1da6c09a7..2356890425 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -1044,6 +1044,24 @@ module.exports.FileUploadOptions = { }, }; module.exports.DatabaseOptions = { + autoSelectFamily: { + env: 'PARSE_SERVER_DATABASE_AUTO_SELECT_FAMILY', + help: + 'The MongoDB driver option to set whether the socket attempts to connect to IPv6 and IPv4 addresses until a connection is established. If available, the driver will select the first IPv6 address.', + action: parsers.booleanParser, + }, + autoSelectFamilyAttemptTimeout: { + env: 'PARSE_SERVER_DATABASE_AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT', + help: + 'The MongoDB driver option to specify the amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the autoSelectFamily option. If set to a positive integer less than 10, the value 10 is used instead.', + action: parsers.numberParser('autoSelectFamilyAttemptTimeout'), + }, + connectTimeoutMS: { + env: 'PARSE_SERVER_DATABASE_CONNECT_TIMEOUT_MS', + help: + '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.', + action: parsers.numberParser('connectTimeoutMS'), + }, enableSchemaHooks: { env: 'PARSE_SERVER_DATABASE_ENABLE_SCHEMA_HOOKS', help: @@ -1069,6 +1087,12 @@ module.exports.DatabaseOptions = { 'The MongoDB driver option to set a cumulative time limit in milliseconds for processing operations on a cursor.', action: parsers.numberParser('maxTimeMS'), }, + minPoolSize: { + env: 'PARSE_SERVER_DATABASE_MIN_POOL_SIZE', + help: + 'The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver.', + action: parsers.numberParser('minPoolSize'), + }, retryWrites: { env: 'PARSE_SERVER_DATABASE_RETRY_WRITES', help: 'The MongoDB driver option to set whether to retry failed writes.', @@ -1080,6 +1104,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'), }, + socketTimeoutMS: { + env: 'PARSE_SERVER_DATABASE_SOCKET_TIMEOUT_MS', + help: + '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.', + action: parsers.numberParser('socketTimeoutMS'), + }, }; module.exports.AuthAdapter = { enabled: { diff --git a/src/Options/docs.js b/src/Options/docs.js index 4c2883adaa..9505266164 100644 --- a/src/Options/docs.js +++ b/src/Options/docs.js @@ -234,12 +234,17 @@ /** * @interface DatabaseOptions + * @property {Boolean} autoSelectFamily The MongoDB driver option to set whether the socket attempts to connect to IPv6 and IPv4 addresses until a connection is established. If available, the driver will select the first IPv6 address. + * @property {Number} autoSelectFamilyAttemptTimeout The MongoDB driver option to specify the amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the autoSelectFamily option. If set to a positive integer less than 10, the value 10 is used instead. + * @property {Number} connectTimeoutMS 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. * @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} 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} 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. */ /** diff --git a/src/Options/index.js b/src/Options/index.js index 40e15afb27..67dfa4e68e 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -602,8 +602,18 @@ export interface DatabaseOptions { maxTimeMS: ?number; /* The MongoDB driver option to set the maximum replication lag for reads from secondary nodes.*/ maxStalenessSeconds: ?number; + /* The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver. */ + 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, 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. */ + socketTimeoutMS: ?number; + /* The MongoDB driver option to set whether the socket attempts to connect to IPv6 and IPv4 addresses until a connection is established. If available, the driver will select the first IPv6 address. */ + autoSelectFamily: ?boolean; + /* The MongoDB driver option to specify the amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the autoSelectFamily option. If set to a positive integer less than 10, the value 10 is used instead. */ + autoSelectFamilyAttemptTimeout: ?number; } export interface AuthAdapter {