0

I'm using MongoDB docker (4.4.x) image as my DB for NestJS backend. One of the API is triggered by a webhook of my payment gateway. Since its a payment related DB ops, I use transactions for ACID. The problem is, after I start session, then transaction & try to find one document (the very first query in the transaction), It throws an error :

{
  "ok": 0,
  "code": 20,
  "codeName": "IllegalOperation",
  "name": "MongoError"
}

I then switched to the MongoDB Atlas dev server and the whole transaction works flawlessly. Which leads me to believe that, there is something wrong with my installation of mongo docker image.

My docker-compose.yaml file:

version: '3'
services:
    database:
        image: 'mongo'
        container_name: 'mongoDbDev'
        environment:
            - MONGO_INITDB_ROOT_USERNAME=root
            - MONGO_INITDB_ROOT_PASSWORD=789512346
        volumes:
            - ./mongo-volume:/data/db
        ports:
            - '27017:27017'

The mongo-volume directory is located in ~/Documents/Workspace/Docker/mongodb/

I tried this stackoverflow solution but did not work. Which TLDR; Changing permissions to the ./mongo-volume folder.

Additional info,

  1. I user docker-compose command without sudo (tried with sudo, did not work)
  2. I have to use docker with sudo command, post installation steps did not work for me
  • Hey @wetidod701 Mongo ACID Trxns will work on MongoDB Sharded clusters or replica sets, can you try creating a replica set? Also the server you connect through Mongodb Atlas is it a cluster you're connecting to? Thanks. – Saurabh Dec 30 '20 at 06:57
  • I'm using a standalone mongoDB docker instance and I think, yes, I'm using the M0 free tier MongoDB Atlas Cluster (is free tier a cluster?) as dev server. So all I gotta do is create a replica set? – wetidod701 Dec 30 '20 at 07:04
  • Indeed, you can refer to the docs for [Transactions](https://docs.mongodb.com/manual/core/transactions/). – Saurabh Dec 30 '20 at 08:12
  • Oh thanks, It completely went over my head. I'll check it out. – wetidod701 Dec 30 '20 at 08:32

0 Answers0