Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 731084 - net-wireless/unifi-5.14.17 forces mongodb downgrade to DB version 3.6
Summary: net-wireless/unifi-5.14.17 forces mongodb downgrade to DB version 3.6
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Ben Kohler
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-06 13:40 UTC by Joakim Tjernlund
Modified: 2022-02-07 20:05 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joakim Tjernlund 2020-07-06 13:40:35 UTC
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.
Comment 1 Conrad Kostecki gentoo-dev 2020-07-09 17:22:29 UTC
I can't confirm here? My Unifi works with a newer MongoDB. How does Unifi want's to downgrade?
Comment 2 Joakim Tjernlund 2020-07-09 20:47:02 UTC
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?
Comment 3 Ben Kohler gentoo-dev 2020-07-10 00:08:33 UTC
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.
Comment 4 Joakim Tjernlund 2020-07-10 07:14:53 UTC
(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
Comment 5 Ben Kohler gentoo-dev 2020-07-10 11:43:54 UTC
And you are simply upgrading mongodb-4.0* to 4.2*?
Comment 6 Ben Kohler gentoo-dev 2020-07-10 11:46:28 UTC
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?
Comment 7 Joakim Tjernlund 2020-07-10 12:29:40 UTC
(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
Comment 8 Ben Kohler gentoo-dev 2020-07-10 12:32:06 UTC
Does this happen if you manually start mongod pointed at the unifi db?
Comment 9 Joakim Tjernlund 2020-07-10 12:37:58 UTC
(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 ?
Comment 10 Ben Kohler gentoo-dev 2020-07-10 12:57:13 UTC
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
Comment 11 Ben Kohler gentoo-dev 2020-07-10 13:11:50 UTC
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
Comment 12 Joakim Tjernlund 2020-07-11 08:43:50 UTC
(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
Comment 13 Conrad Kostecki gentoo-dev 2020-07-11 09:42:39 UTC
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
Comment 14 Conrad Kostecki gentoo-dev 2020-07-11 09:59:44 UTC
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
Comment 15 Joakim Tjernlund 2020-07-13 20:28:26 UTC
(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.
Comment 16 Joakim Tjernlund 2020-07-19 07:04:06 UTC
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
Comment 17 Ben Kohler gentoo-dev 2020-07-20 16:13:18 UTC
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.
Comment 18 Conrad Kostecki gentoo-dev 2020-08-27 20:58:31 UTC
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.
Comment 19 Joël 2020-12-09 14:56:36 UTC
Hi Conrad,

Just curious: does your same trick (from Comment #14) also work with MongoDB 4.4?
Comment 20 Conrad Kostecki gentoo-dev 2021-09-05 13:38:20 UTC
(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.
Comment 21 Christian 2022-02-07 20:05:23 UTC
great stuff it even worked upgrading to 5.0