bitnami / containers

Bitnami container images
https://bitnami.com
Other
3.03k stars 4.38k forks source link

Primary node slow to start #68147

Open mmimica opened 5 days ago

mmimica commented 5 days ago

Name and Version

bitnami/mongodb:7.0.11

What architecture are you using?

amd64

What steps will reproduce the bug?

The container I'm using for test purposes takes almost a minute to start: $ docker run -it -e MONGODB_ROOT_PASSWORD=password-123 -e MONGODB_REPLICA_SET_MODE=primary -e MONGODB_REPLICA_SET_KEY=replicasetkey123 -p 27017:27017 bitnami/mongodb:latest

mongodb 11:18:52.37 INFO  ==> 
mongodb 11:18:52.37 INFO  ==> Welcome to the Bitnami mongodb container
mongodb 11:18:52.37 INFO  ==> Subscribe to project updates by watching https://github.com/bitnami/containers
mongodb 11:18:52.37 INFO  ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
mongodb 11:18:52.37 INFO  ==> Upgrade to Tanzu Application Catalog for production environments to access custom-configured and pre-packaged software components. Gain enhanced features, including Software Bill of Materials (SBOM), CVE scan result reports, and VEX documents. To learn more, visit https://bitnami.com/enterprise
mongodb 11:18:52.37 INFO  ==> 
mongodb 11:18:52.37 INFO  ==> ** Starting MongoDB setup **
mongodb 11:18:52.38 INFO  ==> Validating settings in MONGODB_* env vars...
mongodb 11:18:52.41 INFO  ==> Initializing MongoDB...
mongodb 11:18:52.46 INFO  ==> Writing keyfile for replica set authentication...
mongodb 11:18:52.47 INFO  ==> Deploying MongoDB from scratch...
MongoNetworkError: connect ECONNREFUSED 172.17.0.2:27017
mongodb 11:18:52.81 INFO  ==> Creating users...
mongodb 11:18:52.81 INFO  ==> Creating root user...
Current Mongosh Log ID: 667e9c1c2d46190dca597192
Connecting to:      mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&tlsAllowInvalidHostnames=true&appName=mongosh+2.2.9
Using MongoDB:      7.0.11
Using Mongosh:      2.2.9

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.

test> db.getSiblingDB('admin').createUser({ user: 'root', pwd: 'password-123', roles: [{role: 'root', db: 'admin'}] })
{ ok: 1 }
test> 
 mongodb 11:19:33.10 INFO  ==> Users created
mongodb 11:19:33.13 INFO  ==> Enabling authentication...
mongodb 11:19:33.16 INFO  ==> Configuring MongoDB replica set...
mongodb 11:19:33.16 INFO  ==> Stopping MongoDB...

What is the expected behavior?

The database to become available on port 27017 within a few seconds.

What do you see instead?

What is it doing there and how do I make it faster?

carrodher commented 2 days ago

You can add the BITNAMI_DEBUG=true env var to see the different steps being executed during the initialization, just in case that provides some hints about the specific step that is taking longer in your case.

mmimica commented 1 day ago

Sure thing.

$ docker run -it -e MONGODB_ROOT_PASSWORD=password-123 -e MONGODB_REPLICA_SET_MODE=primary -e MONGODB_REPLICA_SET_KEY=replicasetkey123 -e BITNAMI_DEBUG=true -p 27017:27017 bitnami/mongodb:latest
mongodb 09:31:45.22 INFO  ==> 
mongodb 09:31:45.22 INFO  ==> Welcome to the Bitnami mongodb container
mongodb 09:31:45.22 INFO  ==> Subscribe to project updates by watching https://github.com/bitnami/containers
mongodb 09:31:45.22 INFO  ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
mongodb 09:31:45.22 INFO  ==> Upgrade to Tanzu Application Catalog for production environments to access custom-configured and pre-packaged software components. Gain enhanced features, including Software Bill of Materials (SBOM), CVE scan result reports, and VEX documents. To learn more, visit https://bitnami.com/enterprise
mongodb 09:31:45.22 INFO  ==> 
mongodb 09:31:45.22 DEBUG ==> Copying files from /opt/bitnami/mongodb/conf.default to /opt/bitnami/mongodb/conf
mongodb 09:31:45.23 INFO  ==> ** Starting MongoDB setup **
mongodb 09:31:45.24 INFO  ==> Validating settings in MONGODB_* env vars...
mongodb 09:31:45.44 INFO  ==> Initializing MongoDB...
mongodb 09:31:45.48 INFO  ==> Writing keyfile for replica set authentication...
mongodb 09:31:45.49 INFO  ==> Deploying MongoDB from scratch...
mongodb 09:31:45.49 DEBUG ==> Starting MongoDB in background...
{"t":{"$date":"2024-07-02T09:31:45.513Z"},"s":"I",  "c":"CONTROL",  "id":5760901, "ctx":"main","msg":"Applied --setParameter options","attr":{"serverParameters":{"enableLocalhostAuthBypass":{"default":true,"value":true}}}}
about to fork child process, waiting until server is ready for connections.
forked process: 55
child process started successfully, parent exiting
MongoNetworkError: connect ECONNREFUSED 172.17.0.2:27017
mongodb 09:31:45.93 INFO  ==> Creating users...
mongodb 09:31:45.93 INFO  ==> Creating root user...
Current Mongosh Log ID: 6683c902f5a1058988597192
Connecting to:      mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&tlsAllowInvalidHostnames=true&appName=mongosh+2.2.9
Using MongoDB:      7.0.11
Using Mongosh:      2.2.9

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.

test> db.getSiblingDB('admin').createUser({ user: 'root', pwd: 'password-123', roles: [{role: 'root', db: 'admin'}] })
{ ok: 1 }
test> mongodb 09:32:06.20 INFO  ==> Users created
mongodb 09:32:06.21 INFO  ==> Enabling authentication...
mongodb 09:32:06.23 INFO  ==> Configuring MongoDB replica set...
mongodb 09:32:06.23 INFO  ==> Stopping MongoDB...
mongodb 09:32:07.24 DEBUG ==> Starting MongoDB in background...
carrodher commented 1 day ago

According to that, it's taking just ~20 seconds to start:

mmimica commented 19 hours ago

And 20 second is not unacceptable by your standards?

carrodher commented 18 hours ago

I think 20 seconds is acceptable to deploy the MongoDB container, having said that, if you're interested in contributing a solution, we welcome you to create a pull request. The Bitnami team is excited to review your submission and offer feedback. You can find the contributing guidelines here.

Your contribution will greatly benefit the community. Feel free to reach out if you have any questions or need assistance.