From 2bc705ced0eee7bd8c9a797fbfbbeb56f7d1ed72 Mon Sep 17 00:00:00 2001 From: Dan Aprahamian Date: Thu, 21 Feb 2019 14:34:08 -0500 Subject: [PATCH] feat(withTransaction): retry transaction commit on wtimeout Fixes NODE-1877 --- lib/sessions.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/sessions.js b/lib/sessions.js index 77699217f..129633b92 100644 --- a/lib/sessions.js +++ b/lib/sessions.js @@ -271,7 +271,6 @@ class ClientSession extends EventEmitter { } const MAX_WITH_TRANSACTION_TIMEOUT = 120000; -const WRITE_CONCERN_FAILED_CODE = 64; const UNSATISFIABLE_WRITE_CONCERN_CODE = 100; const UNKNOWN_REPL_WRITE_CONCERN_CODE = 79; const NON_DETERMINISTIC_WRITE_CONCERN_ERRORS = new Set([ @@ -284,10 +283,6 @@ function hasNotTimedOut(startTime, max) { return Date.now() - startTime < max; } -function isWriteConcernTimeoutError(err) { - return err.code === WRITE_CONCERN_FAILED_CODE && !!(err.errInfo && err.errInfo.wtimeout === true); -} - function isUnknownTransactionCommitResult(err) { return ( !NON_DETERMINISTIC_WRITE_CONCERN_ERRORS.has(err.codeName) && @@ -299,7 +294,7 @@ function isUnknownTransactionCommitResult(err) { function attemptTransactionCommit(session, startTime, fn, options) { return session.commitTransaction().catch(err => { if (err instanceof MongoError && hasNotTimedOut(startTime, MAX_WITH_TRANSACTION_TIMEOUT)) { - if (err.hasErrorLabel('UnknownTransactionCommitResult') && !isWriteConcernTimeoutError(err)) { + if (err.hasErrorLabel('UnknownTransactionCommitResult')) { return attemptTransactionCommit(session, startTime, fn, options); }