| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- --- a/services/web/modules/server-ce-scripts/scripts/check-mongodb.mjs
- +++ b/services/web/modules/server-ce-scripts/scripts/check-mongodb.mjs
- @@ -7,6 +7,7 @@ import {
- const { ObjectId } = mongodb
- const MIN_MONGO_VERSION = [6, 0]
- +const MIN_MONGO_FEATURE_COMPATIBILITY_VERSION = [6, 0]
- async function main() {
- let mongoClient
- @@ -18,6 +19,7 @@ async function main() {
- }
- await checkMongoVersion(mongoClient)
- + await checkFeatureCompatibilityVersion(mongoClient)
- try {
- await testTransactions(mongoClient)
- @@ -53,6 +55,41 @@ async function checkMongoVersion(mongoClient) {
- }
- }
- +async function checkFeatureCompatibilityVersion(mongoClient) {
- + const {
- + featureCompatibilityVersion: { version },
- + } = await mongoClient
- + .db()
- + .admin()
- + .command({ getParameter: 1, featureCompatibilityVersion: 1 })
- + const [major, minor] = version.split('.').map(v => parseInt(v))
- + const [minMajor, minMinor] = MIN_MONGO_FEATURE_COMPATIBILITY_VERSION
- +
- + if (major < minMajor || (major === minMajor && minor < minMinor)) {
- + const minVersion = MIN_MONGO_FEATURE_COMPATIBILITY_VERSION.join('.')
- + console.error(`
- +The MongoDB server has featureCompatibilityVersion=${version}, but Overleaf requires at least version ${minVersion}.
- +
- +Open a mongo shell:
- +- Overleaf Toolkit deployments: $ bin/mongo
- +- Legacy docker-compose.yml deployments: $ docker exec -it mongo mongosh localhost/sharelatex
- +
- +In the mongo shell:
- +> db.adminCommand( { setFeatureCompatibilityVersion: "${minMajor}.${minMinor}" } )
- +
- +Verify the new value:
- +> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
- + ...
- + {
- + featureCompatibilityVersion: { version: ${minMajor}.${minMinor}' },
- +...
- +
- +Aborting.
- +`)
- + process.exit(1)
- + }
- +}
- +
- main()
- .then(() => {
- console.error('Mongodb is up.')
|