Tried to upgrade mongdb to 4.2 for my unifi install. That failed big time as unifi will force downgrade db version to 3.6 even though I manually had set it to 4.0 Unless a way to workaround this downgrade is found, I suggest unifi should mask mongodb 4.2 somehow.
I can't confirm here? My Unifi works with a newer MongoDB. How does Unifi want's to downgrade?
I get in mogodb.log after upgrading DB version to 4.0: mongod.log:2020-07-08T21:01:13.330+0200 I COMMAND [conn11] setting featureCompatibilityVersion to 4.0 mongod.log:2020-07-08T21:02:07.327+0200 I COMMAND [conn2] setting featureCompatibilityVersion to downgrading to 3.6 mongod.log:2020-07-08T21:02:07.327+0200 I COMMAND [conn2] setting featureCompatibilityVersion to 3.6 and my mongdb-4.2 does not like version 3.6 What do you get? What version of the DB do you have?
Generally speaking, it's your responsibility to keep your mongodb databases' featureCompatibilityVersion updated as you bump mongodb versions, there is a postinstall note about this on the mongodb emerge. However, I do think that some more specific instructions to help unifi users with this, would be appropriate. As far as I know, you have to manually start the mongod server, log in with a mongo client, and execute a command to raise the featurecompat version.
(In reply to Ben Kohler from comment #3) > Generally speaking, it's your responsibility to keep your mongodb databases' > featureCompatibilityVersion updated as you bump mongodb versions, there is a > postinstall note about this on the mongodb emerge. > > However, I do think that some more specific instructions to help unifi users > with this, would be appropriate. As far as I know, you have to manually > start the mongod server, log in with a mongo client, and execute a command > to raise the featurecompat version. That was exactly what I did. I rasied featurecompat to 4.0 and when I started unifi, it down graded featurecompat to 3.6
And you are simply upgrading mongodb-4.0* to 4.2*?
Maybe I should take 1 step back, are you unable to get unifi-5.14.17 to start up with featurecompat 4.0 and mongodb 4.0?
(In reply to Ben Kohler from comment #6) > Maybe I should take 1 step back, are you unable to get unifi-5.14.17 to > start up with featurecompat 4.0 and mongodb 4.0? Yes, that works. But then unifi downgrades to 3.6 again: I COMMAND [conn2] setting featureCompatibilityVersion to downgrading to 3.6 I COMMAND [conn2] setting featureCompatibilityVersion to 3.6
Does this happen if you manually start mongod pointed at the unifi db?
(In reply to Ben Kohler from comment #8) > Does this happen if you manually start mongod pointed at the unifi db? Not sure what you mean? Should I start service mongodb first ?
Stop the unifi service (so that its mongod instance stops), then manually run: mongod --config /usr/lib/unifi-video/conf/mongod-wt.conf This will help narrow down if it's something that unifi is doing when it connects to mongod, or if it's mongod itself that is causing the featurecompat issues
Sorry that is for the wrong unifi product, try this: bin/mongod --dbpath /usr/lib/unifi/data/db --port 27117 --unixSocketPrefix /usr/lib/unifi/run --logRotate reopen --logappend --logpath /usr/lib/unifi/logs/mongod.log --pidfilepath /usr/lib/unifi/run/mongod.pid --bind_ip 127.0.0.1
(In reply to Ben Kohler from comment #11) > Sorry that is for the wrong unifi product, try this: > > bin/mongod --dbpath /usr/lib/unifi/data/db --port 27117 --unixSocketPrefix > /usr/lib/unifi/run --logRotate reopen --logappend --logpath > /usr/lib/unifi/logs/mongod.log --pidfilepath /usr/lib/unifi/run/mongod.pid > --bind_ip 127.0.0.1 Tried that but when unifi started, it died. Also had to fix the DB owner after that since root had taken ownership
It's a long time ago, but if I remember correctly, I had to first downgrade to mongodb-4.0, set manually featureCompatibilityVersion to 4.0 my starting manually mongodb and start afterwards unifi. That did the trick, before I was able to update >=mongodb-4.2
Did just a small test, 0) stop unifi 1) su unifi -s /bin/bash (login as unifi user) 2) mongod --noauth --dbpath /var/lib/unifi/data/db (start mongodb) 3) run on a different shell the command 'mongo' (this will connect to started db) 4) run the following command on the interactive shell: db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) This should report on your system 3.6. 5) run the command: db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } ) This will set the setFeatureCompatibilityVersion to 4.0. 6) Don't start unifi yet. Update first mongodb to 4.2, repeat steps above and set setFeatureCompatibilityVersion to 4.2. After upgrading to 4.2, unifi can't anymore downgrade to 3.6. > 2020-03-18T19:33:26.379+0100 I COMMAND [conn2] command admin.$cmd command: > setFeatureCompatibilityVersion { setFeatureCompatibilityVersion: "3.6", > $readPreference: { mode: "secondaryPreferred" }, $db: "admin" } numYields:0 > ok:0 errMsg:"Invalid command argument. Expected '4.2' or '4.0', found 3.6 in: > { setFeatureCompatibilityVersion: \"3.6\", $readPreference: { mode: > \"secondaryPreferred\" }, $db: \"admin\" }. See http://dochub.mongodb.org > /core/4.0-feature-compatibility." errName:BadValue errCode:2 reslen:331 > locks:{ ParallelBatchWriterMode: { acquireCount: { r: 1 } }, > ReplicationStateTransition: { acquireCount: { w: 1 } }, Global: { > acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 }, > acquireWaitCount: { r: 1 }, timeAcquiringMicros: { r: 134398 } }, Collection: > { acquireCount: { r: 2 } }, Mutex: { acquireCount: { r: 1, W: 1 } } } > protocol:op_query 134ms
(In reply to Conrad Kostecki from comment #14) > Did just a small test, > 0) stop unifi > 1) su unifi -s /bin/bash (login as unifi user) > 2) mongod --noauth --dbpath /var/lib/unifi/data/db (start mongodb) > 3) run on a different shell the command 'mongo' (this will connect to > started db) > > 4) run the following command on the interactive shell: > db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) > This should report on your system 3.6. > > 5) run the command: db.adminCommand( { setFeatureCompatibilityVersion: "4.0" > } ) > This will set the setFeatureCompatibilityVersion to 4.0. > > 6) Don't start unifi yet. Update first mongodb to 4.2, repeat steps above > and set setFeatureCompatibilityVersion to 4.2. > > After upgrading to 4.2, unifi can't anymore downgrade to 3.6. > > > 2020-03-18T19:33:26.379+0100 I COMMAND [conn2] command admin.$cmd command: > > setFeatureCompatibilityVersion { setFeatureCompatibilityVersion: "3.6", > > $readPreference: { mode: "secondaryPreferred" }, $db: "admin" } numYields:0 > > ok:0 errMsg:"Invalid command argument. Expected '4.2' or '4.0', found 3.6 in: > > { setFeatureCompatibilityVersion: \"3.6\", $readPreference: { mode: > > \"secondaryPreferred\" }, $db: \"admin\" }. See http://dochub.mongodb.org > > /core/4.0-feature-compatibility." errName:BadValue errCode:2 reslen:331 > > locks:{ ParallelBatchWriterMode: { acquireCount: { r: 1 } }, > > ReplicationStateTransition: { acquireCount: { w: 1 } }, Global: { > > acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 }, > > acquireWaitCount: { r: 1 }, timeAcquiringMicros: { r: 134398 } }, Collection: > > { acquireCount: { r: 2 } }, Mutex: { acquireCount: { r: 1, W: 1 } } } > > protocol:op_query 134ms That would probably work but does not feel very safe.
To be a bit more verbose, unifi has very old java part for mongo: mongo-java-driver-3.4.3.jar and spring-data-mongodb-1.10.23 Feels a bit unsafe to trick it into DB 4.2 with these old drivers
I'm not sure where we are "tricking" anything, these kinds of featurecompat upgrades have been needed all along. Whether gentoo should be restricting the mongodb version to something specific, to play nice with those old java parts, seems like a separate issue.
Well, i think, that we can close here. While it has indeed older drivers, I haven't observed any problems with a newer mongodb. I am running multiple instances of unifi with newer mongodb. > That would probably work but does not feel very safe. While I can't speak for other, I can just says, that this is just running fine and I haven't observed any problems. Let's just hope, unifi will upgrade in future to newer libs and mongodb.
Hi Conrad, Just curious: does your same trick (from Comment #14) also work with MongoDB 4.4?
(In reply to Joël from comment #19) > Hi Conrad, > > Just curious: does your same trick (from Comment #14) also work with MongoDB > 4.4? Yes, it does.
great stuff it even worked upgrading to 5.0