diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2018-01-02 12:35:46 -0500 |
---|---|---|
committer | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2018-01-02 12:35:46 -0500 |
commit | 071e4e8b7b3cee57bfa9b48c4320ca1abea7aa75 (patch) | |
tree | 1133d2d83f249c2d5db559292612922b06e1accd /jstests/libs | |
parent | aa49928e60f72eb10b7b30840152b100f615a06f (diff) | |
download | mongo-071e4e8b7b3cee57bfa9b48c4320ca1abea7aa75.tar.gz |
SERVER-32497 Cache error message used in the for-loop.
This avoids the expense of calling `tojson()` on the server's response
repeatedly.
Diffstat (limited to 'jstests/libs')
-rw-r--r-- | jstests/libs/override_methods/implicitly_retry_on_database_drop_pending.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/jstests/libs/override_methods/implicitly_retry_on_database_drop_pending.js b/jstests/libs/override_methods/implicitly_retry_on_database_drop_pending.js index 232f2621ba5..83a7e0739ba 100644 --- a/jstests/libs/override_methods/implicitly_retry_on_database_drop_pending.js +++ b/jstests/libs/override_methods/implicitly_retry_on_database_drop_pending.js @@ -102,12 +102,16 @@ } // We filter out operations that didn't produce a write error to avoid causing a - // duplicate key error when retrying the operations. + // duplicate key error when retrying the operations. We cache the error message + // for the assertion below to avoid the expense of serializing the server's + // response as a JSON string repeatedly. (There may be up to 1000 write errors + // in the server's response.) + const errorMsg = + "A write error was returned for an operation outside the list of" + + " operations executed: " + tojson(res); + for (let writeError of res.writeErrors) { - assert.lt(writeError.index, - opsExecuted.length, - "A write error was returned for an operation outside the list" + - " of operations executed: " + tojson(res)); + assert.lt(writeError.index, opsExecuted.length, errorMsg); opsToRetry.push(opsExecuted[writeError.index]); } } else if (res.ok === 1 || res.code !== ErrorCodes.DatabaseDropPending) { |