Skip to content

Commit 45579c2

Browse files
committed
store recoveryToken for loadBalanced topology
1 parent c2c9c2c commit 45579c2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/libmongoc/src/mongoc/mongoc-cluster.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,16 @@ _in_sharded_txn (const mongoc_client_session_t *session)
501501
MONGOC_TOPOLOGY_SHARDED;
502502
}
503503

504+
static bool
505+
_in_sharded_or_loadbalanced_txn (const mongoc_client_session_t *session)
506+
{
507+
return session && _mongoc_client_session_in_txn_or_ending (session) &&
508+
(_mongoc_topology_get_type (session->client->topology) ==
509+
MONGOC_TOPOLOGY_SHARDED ||
510+
_mongoc_topology_get_type (session->client->topology) ==
511+
MONGOC_TOPOLOGY_LOAD_BALANCED);
512+
}
513+
504514
static void
505515
_handle_txn_error_labels (bool cmd_ret,
506516
const bson_error_t *cmd_err,
@@ -655,7 +665,7 @@ mongoc_cluster_run_command_monitored (mongoc_cluster_t *cluster,
655665

656666
_handle_txn_error_labels (retval, error, cmd, reply);
657667

658-
if (retval && _in_sharded_txn (cmd->session) &&
668+
if (retval && _in_sharded_or_loadbalanced_txn (cmd->session) &&
659669
bson_iter_init_find (&iter, reply, "recoveryToken")) {
660670
bson_destroy (cmd->session->recovery_token);
661671
if (BSON_ITER_HOLDS_DOCUMENT (&iter)) {

0 commit comments

Comments
 (0)