From 3a685f214435a22bfc6e80ee5c7a80c38e1734b1 Mon Sep 17 00:00:00 2001 From: Colin Ulin Date: Thu, 9 Jan 2025 13:44:21 -0500 Subject: [PATCH 1/6] Updated datatabaseOptions to include minPoolSize, connectTimeoutMS, socketTimeoutMS --- spec/ParseConfigKey.spec.js | 3 +++ src/Options/Definitions.js | 18 ++++++++++++++++++ src/Options/docs.js | 3 +++ src/Options/index.js | 6 ++++++ 4 files changed, 30 insertions(+) diff --git a/spec/ParseConfigKey.spec.js b/spec/ParseConfigKey.spec.js index a8f62681d9..c5f01456f8 100644 --- a/spec/ParseConfigKey.spec.js +++ b/spec/ParseConfigKey.spec.js @@ -81,6 +81,9 @@ describe('Config Keys', () => { maxTimeMS: 1000, maxStalenessSeconds: 10, maxPoolSize: 10, + minPoolSize: 5, + connectTimeoutMS: 5000, + socketTimeoutMS: 5000, }, })).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..6ccd397eb8 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -1051,6 +1051,12 @@ module.exports.DatabaseOptions = { action: parsers.booleanParser, default: false, }, + 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'), + }, maxPoolSize: { env: 'PARSE_SERVER_DATABASE_MAX_POOL_SIZE', help: @@ -1080,6 +1086,18 @@ 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'), }, + connectTimeoutMS: { + env: 'PARSE_SERVER_DATABASE_CONNECT_TIMEOUT_MS', + help: + 'Specifies 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'), + }, + socketTimeoutMS: { + env: 'PARSE_SERVER_DATABASE_SOCKET_TIMEOUT_MS', + help: + 'Specifies 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..ad37f7c002 100644 --- a/src/Options/docs.js +++ b/src/Options/docs.js @@ -235,11 +235,14 @@ /** * @interface DatabaseOptions * @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} minPoolSize The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver. * @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 {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} connectTimeoutMS Specifies 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 {Number} socketTimeoutMS Specifies 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..3600f7d542 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -602,8 +602,14 @@ 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; + /* Specifies 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 + /* Specifies the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout. */ + socketTimeoutMS } export interface AuthAdapter { From e2a375cd0d8197c752ac4ecde90c69d73b3b7eb9 Mon Sep 17 00:00:00 2001 From: Colin Ulin Date: Thu, 9 Jan 2025 20:12:13 -0500 Subject: [PATCH 2/6] fixed linting error --- src/Options/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Options/index.js b/src/Options/index.js index 3600f7d542..efa5accec8 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -607,9 +607,9 @@ export interface DatabaseOptions { /* The MongoDB driver option to set the maximum number of opened, cached, ready-to-use database connections maintained by the driver. */ maxPoolSize: ?number; /* Specifies 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 + connectTimeoutMS: ?number; /* Specifies the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout. */ - socketTimeoutMS + socketTimeoutMS: ?number; } export interface AuthAdapter { From 9fb430b519526baa4f1240fddc4c1982ec7bfd40 Mon Sep 17 00:00:00 2001 From: Colin Ulin Date: Mon, 27 Jan 2025 09:18:45 -0500 Subject: [PATCH 3/6] running definitions generation scriptg --- src/Options/Definitions.js | 24 ++++++++++++------------ src/Options/docs.js | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Options/Definitions.js b/src/Options/Definitions.js index c24d7d7651..0510127fd2 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -1043,6 +1043,12 @@ module.exports.FileUploadOptions = { }, }; module.exports.DatabaseOptions = { + connectTimeoutMS: { + env: 'PARSE_SERVER_DATABASE_CONNECT_TIMEOUT_MS', + help: + 'Specifies 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: @@ -1050,12 +1056,6 @@ module.exports.DatabaseOptions = { action: parsers.booleanParser, default: false, }, - 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'), - }, maxPoolSize: { env: 'PARSE_SERVER_DATABASE_MAX_POOL_SIZE', help: @@ -1074,6 +1074,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.', @@ -1085,12 +1091,6 @@ 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'), }, - connectTimeoutMS: { - env: 'PARSE_SERVER_DATABASE_CONNECT_TIMEOUT_MS', - help: - 'Specifies 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'), - }, socketTimeoutMS: { env: 'PARSE_SERVER_DATABASE_SOCKET_TIMEOUT_MS', help: diff --git a/src/Options/docs.js b/src/Options/docs.js index f54c711e53..73cae334c8 100644 --- a/src/Options/docs.js +++ b/src/Options/docs.js @@ -234,14 +234,14 @@ /** * @interface DatabaseOptions + * @property {Number} connectTimeoutMS Specifies 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} minPoolSize The MongoDB driver option to set the minimum number of opened, cached, ready-to-use database connections maintained by the driver. * @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} connectTimeoutMS Specifies 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 {Number} socketTimeoutMS Specifies the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout. */ From b9263ee8d03da59249f7b195074d7e13ac4cea1c Mon Sep 17 00:00:00 2001 From: Colin Ulin Date: Mon, 27 Jan 2025 09:22:54 -0500 Subject: [PATCH 4/6] added "the mognodb driver option to..." --- src/Options/Definitions.js | 6 +++--- src/Options/docs.js | 6 +++--- src/Options/index.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Options/Definitions.js b/src/Options/Definitions.js index 0510127fd2..f35a68851b 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -1046,13 +1046,13 @@ module.exports.DatabaseOptions = { connectTimeoutMS: { env: 'PARSE_SERVER_DATABASE_CONNECT_TIMEOUT_MS', help: - 'Specifies 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.', + '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: - '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.', + 'The MongoDB driver option to enable 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.', action: parsers.booleanParser, default: false, }, @@ -1094,7 +1094,7 @@ module.exports.DatabaseOptions = { socketTimeoutMS: { env: 'PARSE_SERVER_DATABASE_SOCKET_TIMEOUT_MS', help: - 'Specifies the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout.', + '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'), }, }; diff --git a/src/Options/docs.js b/src/Options/docs.js index 73cae334c8..4cd3f388c0 100644 --- a/src/Options/docs.js +++ b/src/Options/docs.js @@ -234,15 +234,15 @@ /** * @interface DatabaseOptions - * @property {Number} connectTimeoutMS Specifies 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} 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 The MongoDB driver option to enable 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 Specifies the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout. + * @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 2cf551caaf..54a4aa86f7 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -591,7 +591,7 @@ export interface FileUploadOptions { } export interface DatabaseOptions { - /* 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. + /* The MongoDB driver option to enable 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. :DEFAULT: false */ enableSchemaHooks: ?boolean; /* 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. */ @@ -606,9 +606,9 @@ 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; - /* Specifies 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. */ + /* 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; - /* Specifies the amount of time, in milliseconds, spent attempting to send or receive on a socket before timing out. Specifying 0 means no timeout. */ + /* 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; } From ef133c99e04d398f4639315580538cb7dc820248 Mon Sep 17 00:00:00 2001 From: Colin Ulin Date: Mon, 27 Jan 2025 09:23:37 -0500 Subject: [PATCH 5/6] updated docs for new mongo settingd --- src/Options/Definitions.js | 2 +- src/Options/docs.js | 2 +- src/Options/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Options/Definitions.js b/src/Options/Definitions.js index f35a68851b..1573feaeca 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -1052,7 +1052,7 @@ module.exports.DatabaseOptions = { enableSchemaHooks: { env: 'PARSE_SERVER_DATABASE_ENABLE_SCHEMA_HOOKS', help: - 'The MongoDB driver option to enable 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.', + '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.', action: parsers.booleanParser, default: false, }, diff --git a/src/Options/docs.js b/src/Options/docs.js index 4cd3f388c0..6746d181b1 100644 --- a/src/Options/docs.js +++ b/src/Options/docs.js @@ -235,7 +235,7 @@ /** * @interface DatabaseOptions * @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 The MongoDB driver option to enable 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 {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. diff --git a/src/Options/index.js b/src/Options/index.js index 54a4aa86f7..0e387b7b4b 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -591,7 +591,7 @@ export interface FileUploadOptions { } export interface DatabaseOptions { - /* The MongoDB driver option to enable 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. + /* 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. :DEFAULT: false */ enableSchemaHooks: ?boolean; /* 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. */ From 37ce466e6234b0bf21304e4170ee61fe38293410 Mon Sep 17 00:00:00 2001 From: Colin Ulin Date: Wed, 29 Jan 2025 16:36:27 -0500 Subject: [PATCH 6/6] added autoSelectFamily and autoSelectFamilyAttemptTimeout --- spec/ParseConfigKey.spec.js | 2 ++ src/Options/Definitions.js | 12 ++++++++++++ src/Options/docs.js | 2 ++ src/Options/index.js | 4 ++++ 4 files changed, 20 insertions(+) diff --git a/spec/ParseConfigKey.spec.js b/spec/ParseConfigKey.spec.js index c5f01456f8..fe7556123b 100644 --- a/spec/ParseConfigKey.spec.js +++ b/spec/ParseConfigKey.spec.js @@ -84,6 +84,8 @@ describe('Config Keys', () => { 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 1573feaeca..a2696f44de 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -1043,6 +1043,18 @@ 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: diff --git a/src/Options/docs.js b/src/Options/docs.js index 6746d181b1..75b22daf80 100644 --- a/src/Options/docs.js +++ b/src/Options/docs.js @@ -234,6 +234,8 @@ /** * @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. diff --git a/src/Options/index.js b/src/Options/index.js index 0e387b7b4b..4cc5a551c3 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -610,6 +610,10 @@ export interface DatabaseOptions { 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 {