r-universe-org / help

Support and bug tracker for R-universe
https://docs.r-universe.dev/
9 stars 2 forks source link

Update mongodb #282

Closed jeroen closed 11 months ago

jeroen commented 1 year ago

Production currently runs mongodb 4. Tried to upgrade to mongodb 6 locally which gave the following db error:

{"t":{"$date":"2023-08-09T12:54:08.977+02:00"},"s":"I",  "c":"RECOVERY", "id":23987,   "ctx":"initandlisten","msg":"WiredTiger recoveryTimestamp","attr":{"recoveryTimestamp":{"$timestamp":{"t":0,"i":0}}}}
{"t":{"$date":"2023-08-09T12:54:08.991+02:00"},"s":"W",  "c":"CONTROL",  "id":22120,   "ctx":"initandlisten","msg":"Access control is not enabled for the database. Read and write access to data and configuration is unrestricted","tags":["startupWarnings"]}
{"t":{"$date":"2023-08-09T12:54:08.991+02:00"},"s":"W",  "c":"CONTROL",  "id":22184,   "ctx":"initandlisten","msg":"Soft rlimits for open file descriptors too low","attr":{"currentValue":256,"recommendedMinimum":64000},"tags":["startupWarnings"]}
{"t":{"$date":"2023-08-09T12:54:08.995+02:00"},"s":"F",  "c":"CONTROL",  "id":20573,   "ctx":"initandlisten","msg":"Wrong mongod version","attr":{"error":"UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: Location4926900: Invalid featureCompatibilityVersion document in admin.system.version: { _id: \"featureCompatibilityVersion\", version: \"4.4\" }. See https://docs.mongodb.com/master/release-notes/5.0-compatibility/#feature-compatibility. :: caused by :: Invalid feature compatibility version value, expected '5.0' or '5.3' or '6.0. See https://docs.mongodb.com/master/release-notes/5.0-compatibility/#feature-compatibility.). If the current featureCompatibilityVersion is below 5.0, see the documentation on upgrading at https://docs.mongodb.com/master/release-notes/5.0/#upgrade-procedures."}}
{"t":{"$date":"2023-08-09T12:54:08.996+02:00"},"s":"I",  "c":"REPL",     "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":15000}}

After wiping the db and starting over, everything seems to work afaict.

It looks like automatic md5 hashing is actually done in the mongo-node client, not the db? https://github.com/r-universe-org/help/issues/118

jeroen commented 1 year ago

It looks like for the production database featureCompatibilityVersion is set to "4.4": https://github.com/r-universe-org/production-server/blob/3a5c490152514b7a5de38b1eb42385a62be4ee4d/migrations/demo.js#L4-L5

This does not allow an direct upgrade to 6.0. The mongodb guide says:

To upgrade from a version earlier than the 5.0-series, you must successively upgrade major releases until you have upgraded to 5.0-series. For example, if you are running a 4.4-series, you must upgrade first to 5.0 before you can upgrade to 6.0.

jeroen commented 1 year ago

Perhaps the safest way is to start a new server. That also allows us to safely upgrade to ubuntu 22.04.

jeroen commented 11 months ago

It will be cheaper to use a separate disk for gridfs. To do this we would need to:

jeroen commented 11 months ago

For now just upgraded production to mongodb 6.0 without any other changes.