how to solve this transaction error in mlab? [MongoError: Transaction numbers are … support document-level locking]

后端 未结 3 2198
北荒
北荒 2021-02-19 10:35

I\'m trying to do a simple transaction using mongoose. It worked totally fine on MongoDB Atlas, but in mlab I got such an error: Mon

相关标签:
3条回答
  • 2021-02-19 11:02

    This worked for me by adding retryWrites=false ;

    Current URL

     mongodb://<user>:<password>@ds0145508.mlab.com:11508/testdb
    

    New URL

    mongodb://<user>:<password>@ds0145508.mlab.com:11508/testdb?retryWrites=false 
    
    0 讨论(0)
  • 2021-02-19 11:04

    mlab.com runs mongodb 3.6, while the newest is 4.2.x and tools, db connectors, etc., want to use 4.x features.

    In short, mlab.com is outdated.

    0 讨论(0)
  • 2021-02-19 11:12

    I have same issue, then I contact mlab help, here is their reply:

    That error indicates your app/driver is attempting to use a feature that's not compatible with your Shared Cluster deployment, which employs the MMAPv1 storage einge. It's likely that you have retryable writes (https://docs.mongodb.com/manual/core/retryable-writes/) enabled. Can you try turning that feature off in the connection string (https://docs.mongodb.com/manual/reference/connection-string/#urioption.retryWrites), or directly from your driver settings?

    Please let us know if you continue to experience this error after turning off this feature.

    Based on this answer, I appended retryWrites=false in mongodb connection url, then it works well.

    0 讨论(0)
提交回复
热议问题