Mongod configuration

Description:

It seems that custom configuration they can be passed through the replset.configuration (Custom Resource options - Percona Operator for MongoDB) is not really applied to mongod process.

Steps to Reproduce:

I have the following helm configuration file:

psmdb-db:
  secrets:
    users: mongodb-secrets
  replsets:
    - name: rs0
      size: 3
      configuration: |
        systemLog:
          quiet: true
        replication:
          oplogSizeMB: 15360
    ....

After the deployment I see that this also exists in custom resource:

$ kubectl -n mongodb get perconaservermongodb mongodb-psmdb-db -o yaml
...
replsets:
  - affinity: {}
    configuration: |
      systemLog:
        quiet: true
      replication:
        oplogSizeMB: 15360
    name: rs0
    nodeSelector:
...

but the stateful set doesn’t have this option:

$ kubectl get statefulset mongodb-psmdb-db-rs0 -n mongodb -o yaml

...
containers:
      - args:
        - --bind_ip_all
        - --auth
        - --dbpath=/data/db
        - --port=27017
        - --replSet=rs0
        - --storageEngine=wiredTiger
        - --relaxPermChecks
        - --sslAllowInvalidCertificates
        - --clusterAuthMode=x509
        - --shardsvr
        - --enableEncryption
        - --encryptionKeyFile=/etc/mongodb-encryption/encryption-key
        - --wiredTigerCacheSizeGB=5.55
        - --wiredTigerIndexPrefixCompression=true
        - --config=/etc/mongodb-config/mongod.conf
        command:
        - /opt/percona/ps-entry.sh
        env:
        - name: SERVICE_NAME
          value: mongodb-psmdb-db
        - name: NAMESPACE
          value: mongodb
        - name: MONGODB_PORT
          value: "27017"
        - name: MONGODB_REPLSET
          value: rs0
        envFrom:
        - secretRef:
            name: internal-mongodb-psmdb-db-users
            optional: false
        image: percona/percona-server-mongodb:6.0.9-7
        imagePullPolicy: Always
...

and the exact oplog size is 5GB:

rs0 [direct: primary] local> rs.printReplicationInfo()
actual oplog size
'5064.4248046875 MB'
---
configured oplog size
'5064.4248046875 MB'
---

I’m not very familiar with the operator code, but it seems that at the moment it only parses couple of arguments.

Version:

[Insert the version number of the software]

  • name: psmdb-operator
    version: 1.15.0
    repository: percona-helm-charts
  • name: psmdb-db
    version: 1.15.0
    repository: percona-helm-charts

Logs:

[If applicable, include any relevant log files or error messages]

Expected Result:

[What the user expected to see or happen before the issue occurred]
Expect oplog parameter passed to mongod:

--oplogSizeMB=...

Actual Result:

[What actually happened when the user encountered the issue]
No such parameter (also syslog is missing)

Additional Information:

[Include any additional information that could be helpful to diagnose the issue, such as browser or device information]

Hello @Sergey_Zelenov1 ,

as you can see there is this flag:

        - --config=/etc/mongodb-config/mongod.conf

This is where the configuration is stored.
If you exec into the container, you would see the file has these parameters and they are actually applied.

This is in my container:

$ cat /etc/mongodb-config/mongod.conf 
systemLog:
  quiet: true
replication:
  oplogSizeMB: 500

As for rs.printReplicationInfo() and the size not changing, have you tried to run replSetResizeOplog? As per mongodb docs:

Once the mongod has created the oplog for the first time, changing the replication.oplogSizeMB option will not affect the size of the oplog. To change the maximum oplog size after starting the mongod, use replSetResizeOplog. replSetResizeOplog enables you to resize the oplog dynamically without restarting the mongod process. To persist the changes made using replSetResizeOplog through a restart, update the value of oplogSizeMB.

1 Like

@Sergey_Pronin thank you very much! This indeed works as intended, apologies for not checking this place before raising the topic.
So, yes, basically changing the oplog size in the custom resource doesn’t change the actual size, but it helps with mongod restarts. The actual change should be applied directly in the DB (first on secondaries, then on primary).

Here is the documentation: https://www.mongodb.com/docs/manual/tutorial/change-oplog-size/