overleaf icon indicating copy to clipboard operation
overleaf copied to clipboard

Mongo instance doesn't support transactions

Open holyfive opened this issue 1 year ago • 9 comments

Using this compose file on a fresh docker installation results in an ongoing restarting Sharelatex container, saying:

Mongo instance doesn't support transactions sharelatex | MongoServerError: Transaction numbers are only allowed on a replica set member or mongos sharelatex | at Connection.onMessage (/overleaf/services/web/node_modules/mongodb/lib/cmap/connection.js:231:30) sharelatex | at MessageStream. (/overleaf/services/web/node_modules/mongodb/lib/cmap/connection.js:61:60) sharelatex | at MessageStream.emit (node:events:517:28) sharelatex | at processIncomingData (/overleaf/services/web/node_modules/mongodb/lib/cmap/message_stream.js:125:16) sharelatex | at MessageStream._write (/overleaf/services/web/node_modules/mongodb/lib/cmap/message_stream.js:33:9) sharelatex | at writeOrBuffer (node:internal/streams/writable:392:12) sharelatex | at _write (node:internal/streams/writable:333:10) sharelatex | at Writable.write (node:internal/streams/writable:337:10) sharelatex | at Socket.ondata (node:internal/streams/readable:777:22) sharelatex | at Socket.emit (node:events:517:28) { sharelatex | ok: 0, sharelatex | code: 20, sharelatex | codeName: 'IllegalOperation', sharelatex | [Symbol(errorLabels)]: Set(0) {}

holyfive avatar Dec 05 '23 15:12 holyfive

I have the same error. I added command: --replSet rs0 on the mongo compose config and bypassed this error.

mongo:
        restart: always
        image: mongo:4.4
        command: --replSet rs0

But now I have this new error: :(

2023-12-06 01:02:05 Cannot connect to mongodb 2023-12-06 01:02:05 MongooseServerSelectionError: Server selection timed out after 60000 ms 2023-12-06 01:02:05 at Connection.openUri (/overleaf/services/web/node_modules/mongoose/lib/connection.js:825:32) 2023-12-06 01:02:05 at /overleaf/services/web/node_modules/mongoose/lib/index.js:414:10 2023-12-06 01:02:05 at /overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5 2023-12-06 01:02:05 at new Promise () 2023-12-06 01:01:01 Nginx: generating config file from template 2023-12-06 01:01:01 Nginx: reloading config 2023-12-06 01:01:01 * Reloading nginx configuration nginx 2023-12-06 01:01:01 ...done. 2023-12-06 01:01:01 Dec 6 07:01:01 267cf627e4a7 syslog-ng[167]: syslog-ng starting up; version='3.25.1' 2023-12-06 01:01:02 Checking can connect to mongo and redis 2023-12-06 01:01:04 Using default settings from /overleaf/services/web/config/settings.defaults.js 2023-12-06 01:01:04 Using settings from /etc/sharelatex/settings.js 2023-12-06 01:01:04 Set UV_THREADPOOL_SIZE=16 2023-12-06 01:02:05 at promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10) 2023-12-06 01:02:05 at Mongoose._promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/index.js:1288:10) 2023-12-06 01:02:05 at Mongoose.connect (/overleaf/services/web/node_modules/mongoose/lib/index.js:413:20) 2023-12-06 01:02:05 at Object. (/overleaf/services/web/app/src/infrastructure/Mongoose.js:19:36) 2023-12-06 01:02:05 at Module._compile (node:internal/modules/cjs/loader:1256:14) 2023-12-06 01:02:05 at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) { 2023-12-06 01:02:05 reason: TopologyDescription { 2023-12-06 01:02:05 type: 'Unknown', 2023-12-06 01:02:05 servers: Map(1) { 'mongo:27017' => [ServerDescription] }, 2023-12-06 01:02:05 stale: false, 2023-12-06 01:02:05 compatible: true, 2023-12-06 01:02:05 heartbeatFrequencyMS: 10000, 2023-12-06 01:02:05 localThresholdMS: 15, 2023-12-06 01:02:05 setName: null, 2023-12-06 01:02:05 maxElectionId: null, 2023-12-06 01:02:05 maxSetVersion: null, 2023-12-06 01:02:05 commonWireVersion: 0, 2023-12-06 01:02:05 logicalSessionTimeoutMinutes: null 2023-12-06 01:02:05 }, 2023-12-06 01:02:05 code: undefined 2023-12-06 01:02:05 }

jtrevinodev avatar Dec 06 '23 07:12 jtrevinodev

This worked for me like a charm~

https://github.com/overleaf/overleaf/issues/1120#issuecomment-1623295314

KeckigerKeks avatar Dec 10 '23 19:12 KeckigerKeks

Great advise, thanks a lot! Now I got it working too.

holyfive avatar Dec 11 '23 07:12 holyfive

I have the same error. I added command: --replSet rs0 on the mongo compose config and bypassed this error.

mongo:
        restart: always
        image: mongo:4.4
        command: --replSet rs0

But now I have this new error: :(

2023-12-06 01:02:05 Cannot connect to mongodb 2023-12-06 01:02:05 MongooseServerSelectionError: Server selection timed out after 60000 ms 2023-12-06 01:02:05 at Connection.openUri (/overleaf/services/web/node_modules/mongoose/lib/connection.js:825:32) 2023-12-06 01:02:05 at /overleaf/services/web/node_modules/mongoose/lib/index.js:414:10 2023-12-06 01:02:05 at /overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5 2023-12-06 01:02:05 at new Promise () 2023-12-06 01:01:01 Nginx: generating config file from template 2023-12-06 01:01:01 Nginx: reloading config 2023-12-06 01:01:01 * Reloading nginx configuration nginx 2023-12-06 01:01:01 ...done. 2023-12-06 01:01:01 Dec 6 07:01:01 267cf627e4a7 syslog-ng[167]: syslog-ng starting up; version='3.25.1' 2023-12-06 01:01:02 Checking can connect to mongo and redis 2023-12-06 01:01:04 Using default settings from /overleaf/services/web/config/settings.defaults.js 2023-12-06 01:01:04 Using settings from /etc/sharelatex/settings.js 2023-12-06 01:01:04 Set UV_THREADPOOL_SIZE=16 2023-12-06 01:02:05 at promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10) 2023-12-06 01:02:05 at Mongoose._promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/index.js:1288:10) 2023-12-06 01:02:05 at Mongoose.connect (/overleaf/services/web/node_modules/mongoose/lib/index.js:413:20) 2023-12-06 01:02:05 at Object. (/overleaf/services/web/app/src/infrastructure/Mongoose.js:19:36) 2023-12-06 01:02:05 at Module._compile (node:internal/modules/cjs/loader:1256:14) 2023-12-06 01:02:05 at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) { 2023-12-06 01:02:05 reason: TopologyDescription { 2023-12-06 01:02:05 type: 'Unknown', 2023-12-06 01:02:05 servers: Map(1) { 'mongo:27017' => [ServerDescription] }, 2023-12-06 01:02:05 stale: false, 2023-12-06 01:02:05 compatible: true, 2023-12-06 01:02:05 heartbeatFrequencyMS: 10000, 2023-12-06 01:02:05 localThresholdMS: 15, 2023-12-06 01:02:05 setName: null, 2023-12-06 01:02:05 maxElectionId: null, 2023-12-06 01:02:05 maxSetVersion: null, 2023-12-06 01:02:05 commonWireVersion: 0, 2023-12-06 01:02:05 logicalSessionTimeoutMinutes: null 2023-12-06 01:02:05 }, 2023-12-06 01:02:05 code: undefined 2023-12-06 01:02:05 }

I'm also receiving this issue and tried to follow the comment on 1120 but I still had a time out error. Is there another fix out there?

For context I'm trying to set this up on unraid so I'm not 100% familiar with the docker compose file in the comment but I believe I did the same thing on the unraid docker management to the best that I could.

RafaelCenzano avatar Jan 22 '24 08:01 RafaelCenzano

is it the same error that you cited?

from my perspective, he didn't add the one-time container to start up mongodb:

mongoinit:
    image: mongo:4.4
    # this container will exit after executing the command
    restart: "no"
    depends_on:
      mongo:
        condition: service_healthy
    entrypoint:
      [
        "mongo",
        "--host",
        "mongo:27017",
        "--eval",
        'rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] })',
      ]

please provide us at least a logfile next time~

KeckigerKeks avatar Jan 22 '24 16:01 KeckigerKeks

Yes, same error. You are correct I didn't realize that was a separate container. I'm not sure how to run a separate container like this on Unraid since it operates using templates and single docker containers instead of docker-compose files. Is there a way I can do it manually one time via the console, if not that is no problem and not an issue to be discussed here.

RafaelCenzano avatar Jan 22 '24 17:01 RafaelCenzano

Hello everyone.

I managed to get it running in my Ubuntu Server 22.04.3.

I used a different image for my mongodb though.

Here's my docker-compose.yml: leonamtv/overleaf-leo-config/docker-compose.yml

Part that fixed the issue:

    mongo:
        image: bitnami/mongodb:5.0
        container_name: mongo
        restart: always
        ports:
            - "27017:27017"
        volumes:
            - ~/mongo_data:/data/db
        healthcheck:
            test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
            interval: 10s
            timeout: 10s
            retries: 5
        environment:
            MONGODB_REPLICA_SET_MODE: primary
            ALLOW_EMPTY_PASSWORD: 'yes'

I hope that helps!

Regards!

leonamtv avatar Feb 13 '24 19:02 leonamtv

Hello everyone.

I managed to get it running in my Ubuntu Server 22.04.3.

I used a different image for my mongodb though.

Here's my docker-compose.yml: leonamtv/overleaf-leo-config/docker-compose.yml

Part that fixed the issue:

    mongo:
        image: bitnami/mongodb:5.0
        container_name: mongo
        restart: always
        ports:
            - "27017:27017"
        volumes:
            - ~/mongo_data:/data/db
        healthcheck:
            test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
            interval: 10s
            timeout: 10s
            retries: 5
        environment:
            MONGODB_REPLICA_SET_MODE: primary
            ALLOW_EMPTY_PASSWORD: 'yes'

I hope that helps!

Regards!

works like a charm.

enriquewph avatar May 04 '24 02:05 enriquewph

Hello everyone. I managed to get it running in my Ubuntu Server 22.04.3. I used a different image for my mongodb though. Here's my docker-compose.yml: leonamtv/overleaf-leo-config/docker-compose.yml Part that fixed the issue:

    mongo:
        image: bitnami/mongodb:5.0
        container_name: mongo
        restart: always
        ports:
            - "27017:27017"
        volumes:
            - ~/mongo_data:/data/db
        healthcheck:
            test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
            interval: 10s
            timeout: 10s
            retries: 5
        environment:
            MONGODB_REPLICA_SET_MODE: primary
            ALLOW_EMPTY_PASSWORD: 'yes'

I hope that helps! Regards!

works like a charm.

It also works for me.

isCopyman avatar Jun 03 '24 11:06 isCopyman

Hello,

The Overleaf Toolkit is our recommended method for deploying Overleaf Community Edition and Server Pro now. It will automatically create the MongoDB replica set for you. We've also prepared a migration guide in the Toolkit docs.

Greetings, Jakob

das7pad avatar Aug 28 '24 16:08 das7pad