jorasmhj / db-mongo-migration

Mongo migration Library
MIT License
4 stars 2 forks source link

Detect Transaction Support #57

Closed mikejr83 closed 4 months ago

mikejr83 commented 6 months ago

Hello! So far I'm liking the straight forward nature of this implementation of migrations for Mongo.

We do all of our testing for Mongo on our local dev boxes. Most of us our using Docker Desktop running the mongo:4.2 image. I spun up a quick test to see if we could start integrating this into our workflow I got the following error:

npx mongo-migrate up
  __  __                               __  __ _                 _       
 |  \/  | ___  _ __   __ _  ___       |  \/  (_) __ _ _ __ __ _| |_ ___ 
 | |\/| |/ _ \| '_ \ / _` |/ _ \ _____| |\/| | |/ _` | '__/ _` | __/ _ \
 | |  | | (_) | | | | (_| | (_) |_____| |  | | | (_| | | | (_| | ||  __/
 |_|  |_|\___/|_| |_|\__, |\___/      |_|  |_|_|\__, |_|  \__,_|\__\___|
                     |___/                      |___/
Migrating:  1712064966476-test-migration.ts
Migrated:   1712064966476-test-migration.ts
C:\projects\docdb-migrations\node_modules\mongodb\lib\cmap\connection.js:281
                    throw new error_1.MongoServerError(document);
                          ^

MongoServerError: Transaction numbers are only allowed on a replica set member or mongos
    at Connection.sendCommand (C:\projects\docdb-migrations\node_modules\mongodb\lib\cmap\connection.js:281:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Connection.command (C:\projects\docdb-migrations\node_modules\mongodb\lib\cmap\connection.js:304:26)
    at async Server.command (C:\projects\docdb-migrations\node_modules\mongodb\lib\sdam\server.js:169:24)
    at async InsertOneOperation.execute (C:\projects\docdb-migrations\node_modules\mongodb\lib\operations\insert.js:46:21)
    at async executeOperation (C:\projects\docdb-migrations\node_modules\mongodb\lib\operations\execute_operation.js:126:16) {
  errorResponse: {
    ok: 0,
    errmsg: 'Transaction numbers are only allowed on a replica set member or mongos',
    code: 20,
    codeName: 'IllegalOperation'
  },
  ok: 0,
  code: 20,
  codeName: 'IllegalOperation',
  [Symbol(errorLabels)]: Set(0) {}
}

It appears that transactions are enabled by default. Is there a way we can disable that functionality when doing local tests against a simple simple mongo instance running in a container?

saroj-mhj commented 4 months ago

@mikejr83 Currently, we don't have that capability, but I recognize its importance and value. Rest assured, it's a priority for us, and we're actively working on implementing it. You can anticipate this functionality being included in the upcoming release.

jorasmhj commented 4 months ago

New version released with global transaction enable/disable option.