Skip to content

Commit 3906137

Browse files
committed
Add transaction handling for non-replica set MongoDB connections
1 parent 057dec4 commit 3906137

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Database/Adapter/Mongo.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ public function withTransaction(callable $callback): mixed
125125

126126
public function startTransaction(): bool
127127
{
128+
129+
// If the database is not a replica set, we can't use transactions
130+
if (!$this->client->isReplicaSet()) {
131+
return false;
132+
}
133+
128134
try {
129135
if ($this->inTransaction === 0) {
130136
if (!$this->sessionId) {

0 commit comments

Comments
 (0)