[SERVER-32497] implicitly_retry_on_database_drop_pending.js calls tojson() inside of a loop Created: 01/Jan/18  Updated: 30/Oct/23  Resolved: 02/Jan/18

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 3.6.2, 3.7.1

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Max Hirschhorn
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
related to SERVER-33034 Change assertion functions to accept ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.6
Sprint: TIG 2018-1-15
Participants:
Linked BF Score: 0

 Description   

Depending on the number of write errors in the server's response, we may spend >10 minutes in the for-loop to filter out successful write operations due to serializing the server's response as a JSON string. This leads to the assert.soon() timeout expiring without actually ever being able to perform a single retry.

// We filter out operations that didn't produce a write error to avoid causing a
// duplicate key error when retrying the operations.
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));
    opsToRetry.push(opsExecuted[writeError.index]);
}

We should change the way the assertion is written to avoid calling tojson(res) so many times.



 Comments   
Comment by Githook User [ 02/Jan/18 ]

Author:

{'name': 'Max Hirschhorn', 'username': 'visemet', 'email': 'max.hirschhorn@mongodb.com'}

Message: SERVER-32497 Cache error message used in the for-loop.

This avoids the expense of calling `tojson()` on the server's response
repeatedly.

(cherry picked from commit 071e4e8b7b3cee57bfa9b48c4320ca1abea7aa75)
Branch: v3.6
https://github.com/mongodb/mongo/commit/941c074c7f83ed78c106c19c84920ae1bd7aba2b

Comment by Githook User [ 02/Jan/18 ]

Author:

{'name': 'Max Hirschhorn', 'username': 'visemet', 'email': 'max.hirschhorn@mongodb.com'}

Message: SERVER-32497 Cache error message used in the for-loop.

This avoids the expense of calling `tojson()` on the server's response
repeatedly.
Branch: master
https://github.com/mongodb/mongo/commit/071e4e8b7b3cee57bfa9b48c4320ca1abea7aa75

Generated at Thu Feb 08 04:30:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.