5

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.

Thanks

Priyanka Sankhala
  • 151
  • 1
  • 1
  • 3

2 Answers2

3

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.

Stennie
  • 10,345
  • 2
  • 31
  • 46
2

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.

SqlWorldWide
  • 13,687
  • 3
  • 30
  • 54