I want to use transaction in mongodb but its told to replicaset can we perform transaction query with standalone mongodb if yes please share how to we can because when I try its give error

This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string

how to we perform translation without retryable writes.



This is not possible and clearly documented in the manual.

Ref: Retryable Writes

Retryable writes allow MongoDB drivers to automatically retry certain write operations a single time if they encounter network errors, or if they cannot find a healthy primary in the replica sets or sharded cluster.

Retryable writes have the following requirements:

Supported Deployment Topologies

Retryable writes require a replica set or sharded cluster, and do not support standalone instances.

Supported Storage Engine

Retryable writes require a storage engine supporting document-level locking, such as the WiredTiger or in-memory storage engines.

  • Thanks for response so I can't use transaction without replica set. can I set replica on cloud server (AWS ec2) with using one IP address? Apr 17 '20 at 12:32
  • Sorry, I do not have any experience with AWS. Apr 17 '20 at 13:46

You can convert your standalone deployment to a single node replica set. Follow the tutorial to Convert a Standalone to a Replica Set, but do not add any additional members.

This will allow you to use features which require a replica set deployment (for example, transactions in MongoDB 4.0+ and change streams in MongoDB 3.6+).

The main downsides of a single member deployment are that you don't get any of the usual replica set benefits such as data redundancy and fault tolerance. A replica set member also has some expected write overhead as compared to a standalone server because it has to maintain a replication oplog.

A production replica set deployment should have a minimum of three members. See Deploy a replica set in the MongoDB documentation for full details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.