Bug 277990 - databases/mongodb50: mongodb SIGILL due to missing AVX instructions
Summary: databases/mongodb50: mongodb SIGILL due to missing AVX instructions
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Ronald Klop
URL:
Keywords: crash, regression
Depends on:
Blocks:
 
Reported: 2024-03-27 12:23 UTC by bllcha013
Modified: 2024-04-25 14:28 UTC (History)
1 user (show)

See Also:
ronald: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bllcha013 2024-03-27 12:23:40 UTC
Hello, after mongodb44 was replaced with mongodb50, my UniFi Controller wouldn't work anymore since MongoDB wasn't able to run due to my CPU lacking AVX instructions (signal 4 SIGILL on startup). The packages for mongodb50 (and newer) are built with AVX by default.

I managed to get it working again by building the mongodb50 port with the NO_AVX option.

Is it at all feasible to get a package flavor (for unifi and/or mongodb, I'm not sure which one it needs to be) without the AVX requirement?

In addition, not sure if this should go in a separate report or not, but UniFi Controller 8.1 officially supports MongoDB 7, is it possible for the unifi8 port to be changed to use mongodb70 instead of mongodb50? MongoDB 5.0 will be end of life soon in October 2024, while MongoDB 7.0 will be end of life much later in August 2026. Since UniFi officially supports it, wouldn't it would be a good idea to change to MongoDB 7.0?
Comment 1 Juraj Lutter freebsd_committer freebsd_triage 2024-03-27 12:27:13 UTC
This is more for the mongodb maintainer.

I've come across this in an installation in a VM running as Hyper-V guest.

My solution was to reset NUMA settings and turning off the CPU compatibility for the VM affected.
Comment 2 bllcha013 2024-03-27 13:44:44 UTC
(In reply to Juraj Lutter from comment #1)

I have just now figured out a decent solution in my case that I'm happy with (building from source by first installing dependencies with pkg so I only need to build mongodb itself). It seems from the MongoDB website that they don't support CPUs without AVX officially, so it's probably a better idea to rather leave this alone, especially being unsupported upstream.

Apologies for only finding this out now.

Just the mongodb50 -> mongodb70 thing remains, would it be recommended to close this and open a new bug for that?
Comment 3 Ronald Klop freebsd_committer freebsd_triage 2024-03-27 13:58:14 UTC
(In reply to bllcha013 from comment #2)
Do you have a pointer to the MongoDB doc about AVX support?

It is pretty easy to add a mongodb50-avx flavor. That is why unifi has an unifi8-externaldb flavor. Than unifi does not depend directly on the DB and you can do the setup yourself.

As for dependency on mongodb70. Mongodb supports upgrades between 1 major version. So taking care of the quarterly ports branches I propose:
Q2 has mongodb50 as dependency in unifi8.
During Q2 (e.g. the start of April) we change unifi8 to use mongodb60. That will get some QA before Q3.
Q3 has mongodb60 as dependency in unifi8.

So everybody is running supported versions until July 2025.

BTW: you can always install unifi8-externaldb and setup the DB yourself. I don't have the documentation about this available now, but that shouldn't be hard to find.
Comment 4 Ronald Klop freebsd_committer freebsd_triage 2024-03-27 14:12:42 UTC
Found some documentation about using a separate MongoDB with Unifi.

https://community.ui.com/questions/External-MongoDB-Server/d311a8f8-43b6-4aeb-859d-eefec9dc1bbc#answer/b8a080b0-d05a-493c-914c-c804709c8d4a

In your system.properties file:
db.mongo.local=false
db.mongo.uri=mongodb://ubnt:password@IP_ADDRESS:PORT/unifi-test
statdb.mongo.uri=mongodb://ubnt:password@IP_ADDRESS:PORT/unifi-test_stat
unifi.db.name=unifi-test
Comment 5 bllcha013 2024-03-27 14:24:29 UTC
(In reply to Ronald Klop from comment #3)

MongoDB documentation: https://www.mongodb.com/docs/manual/administration/production-notes/ "...requires use of the AVX instruction set..."

Knowing this, if "noavx" package flavors were to be introduced (mongodb50-noavx, mongodb60-noavx, mongodb70-noavx), maybe there should be a warning that it is not officially supported upstream.

For the dependency upgrade, that seems like a good plan to avoid situations where someone does an upgrade and it jumps 3 versions ahead and breaks their database (rather ease everyone over).
Comment 6 Juraj Lutter freebsd_committer freebsd_triage 2024-03-27 20:24:18 UTC
Can we either close or transfer this PR to someone more apropriate as this is not essentually a unifi problem?
Comment 7 Ronald Klop freebsd_committer freebsd_triage 2024-03-28 15:29:39 UTC
(In reply to Juraj Lutter from comment #6)
I took over the issue. You can unsub from cc lists yourself if you need to.
Comment 8 commit-hook freebsd_committer freebsd_triage 2024-04-25 11:55:22 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=1707c0aac83aaf892c07bfc05573d1efa8ec5724

commit 1707c0aac83aaf892c07bfc05573d1efa8ec5724
Author:     Ronald Klop <ronald@FreeBSD.org>
AuthorDate: 2024-04-25 11:44:44 +0000
Commit:     Ronald Klop <ronald@FreeBSD.org>
CommitDate: 2024-04-25 11:54:45 +0000

    databases/mongodb50: enable non-AVX CPUs by default

    By popular demand as this port is used by net-mgmt/unifi8.

    I couldn't find any information on the internet that the binary really
    does something which requires AVX. For example this discussion:
    https://github.com/turnkeylinux/tracker/issues/1724

    PR:     277990
    Requested by:   glebius@

 databases/mongodb50/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 9 Ronald Klop freebsd_committer freebsd_triage 2024-04-25 12:01:12 UTC
fix is committed
I don't run this on non-AVX so please report back if this does not work.
Thanks for your report.
Comment 10 Ronald Klop freebsd_committer freebsd_triage 2024-04-25 14:28:20 UTC
This page also describes that AVX is not necessary for correct working of MongoDB.

https://www.mongodb.com/community/forums/t/one-more-time-about-mongo-5-cpu-requirements/168858/2