Skip to content

[Bug]: MongoDB crashes because ulimit is too low #10150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
CLOVIS-AI opened this issue Mar 28, 2025 · 4 comments
Open

[Bug]: MongoDB crashes because ulimit is too low #10150

CLOVIS-AI opened this issue Mar 28, 2025 · 4 comments
Labels

Comments

@CLOVIS-AI
Copy link

Module

MongoDB

Testcontainers version

1.19.8

Using the latest Testcontainers version?

Yes

Host OS

Linux

Host Arch

x86

Docker version

Docker version 28.0.1, build 068a01ea94

What happened?

MongoDB crashes while the tests are running.

Relevant log output

{"t":{"$date":"2025-03-28T10:47:39.000+00:00"},"s":"E",  "c":"ASSERT",   "id":23077,   "ctx":"ftdc","msg":"Assertion","attr":{"error":"Location13538: couldn't open [/proc/1/stat] Too many open files","file":"src/mongo/util/processinfo_linux.cpp","line":83}}
{"t":{"$date":"2025-03-28T10:47:39.282+00:00"},"s":"E",  "c":"WT",       "id":22435,   "ctx":"conn24","msg":"WiredTiger error message","attr":{"error":24,"message":{"ts_sec":1743158859,"ts_usec":282251,"thread":"1:0x7142a7603640","session_name":"WT_SESSION.create","category":"WT_VERB_DEFAULT","category_id":9,"verbose_level":"ERROR","verbose_level_id":-3,"msg":"__posix_directory_sync:135:/data/db/: directory-sync: open","error_str":"Too many open files","error_code":24}}}
{"t":{"$date":"2025-03-28T10:47:39.282+00:00"},"s":"E",  "c":"WT",       "id":22435,   "ctx":"conn24","msg":"WiredTiger error message","attr":{"error":24,"message":{"ts_sec":1743158859,"ts_usec":282319,"thread":"1:0x7142a7603640","session_name":"WT_SESSION.create","category":"WT_VERB_DEFAULT","category_id":9,"verbose_level":"ERROR","verbose_level_id":-3,"msg":"__posix_directory_sync:151:/data/db/collection-945-3757964622610459637.wt: directory-sync","error_str":"Too many open files","error_code":24}}}
{"t":{"$date":"2025-03-28T10:47:39.282+00:00"},"s":"E",  "c":"WT",       "id":22435,   "ctx":"conn24","msg":"WiredTiger error message","attr":{"error":-31804,"message":{"ts_sec":1743158859,"ts_usec":282337,"thread":"1:0x7142a7603640","session_name":"WT_SESSION.create","category":"WT_VERB_DEFAULT","category_id":9,"verbose_level":"ERROR","verbose_level_id":-3,"msg":"__posix_directory_sync:151:the process must exit and restart","error_str":"WT_PANIC: WiredTiger library panic","error_code":-31804}}}
{"t":{"$date":"2025-03-28T10:47:39.282+00:00"},"s":"F",  "c":"ASSERT",   "id":23089,   "ctx":"conn24","msg":"Fatal assertion","attr":{"msgid":50853,"file":"src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp","line":741}}
{"t":{"$date":"2025-03-28T10:47:39.282+00:00"},"s":"F",  "c":"ASSERT",   "id":23090,   "ctx":"conn24","msg":"\n\n***aborting after fassert() failure\n\n"}
{"t":{"$date":"2025-03-28T10:47:39.282+00:00"},"s":"F",  "c":"CONTROL",  "id":6384300, "ctx":"conn24","msg":"Writing fatal message","attr":{"message":"\n"}}
{"t":{"$date":"2025-03-28T10:47:39.282+00:00"},"s":"F",  "c":"CONTROL",  "id":6384300, "ctx":"conn24","msg":"Writing fatal message","attr":{"message":"Got signal: 6 (Aborted).\n"}}

Additional Information

MongoDB recommends setting ulimit -n 64000, which is much more than Docker's default of 1024.

In a docker-compose file, I can use:

        ulimits:
            nofile: 64000

to increase the file ulimit. However, I can't find a way to do so with testcontainers-java.

@eddumelendez
Copy link
Member

Use withCreateContainerCmdModifier

withCreateContainerCmdModifier(cmd -> cmd.getHostConfig().withUlimits())

@CLOVIS-AI
Copy link
Author

Thanks for the workaround! Now I guess all that's left to do is make this the default for MongoDBContainer. I could create a PR, if you want.

@eddumelendez
Copy link
Member

We are not having this issue, tests run with no issues on GHA Linux runners, so, not sure about having it as a default.

@CLOVIS-AI
Copy link
Author

How much data are you creating? It takes quite a few before the limits gets reached. You can see the number of 64000 recommended in the official documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants