Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-66751

Upsert stage should use generic yield machinery instead of writeConflictRetry

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Execution Team 2023-02-20, Execution Team 2023-02-06, Execution EMEA Team 2023-06-26, Execution EMEA Team 2023-07-10, Execution EMEA Team 2023-07-24, Execution EMEA Team 2023-08-07

      Running

      resmoke --suites=concurrency jstests/concurrency/fsm_workloads/CRUD_and_commands_with_createindexes.js
      

      with this diff

      diff --git a/src/mongo/db/concurrency/exception_util.h b/src/mongo/db/concurrency/exception_util.h
      index 6cfe238ca7d..63243009bac 100644
      --- a/src/mongo/db/concurrency/exception_util.h
      +++ b/src/mongo/db/concurrency/exception_util.h
      @@ -34,6 +34,7 @@
       #include "mongo/db/operation_context.h"
       #include "mongo/util/assert_util.h"
       #include "mongo/util/fail_point.h"
      +#include "mongo/util/stacktrace.h"
       
       namespace mongo {
       
      @@ -124,6 +125,10 @@ auto writeConflictRetry(OperationContext* opCtx, StringData opStr, StringData ns
           int attemptsTempUnavailable = 0;
           while (true) {
               try {
      +            if (opCtx->lockState()->isLocked()) {
      +                printStackTrace();
      +            }
      +
                   return f();
               } catch (WriteConflictException const&) {
                   CurOp::get(opCtx)->debug().additiveMetrics.incrementWriteConflicts(1);
      

      Shows that this writeConflictRetry is run with locks acquired at some earlier point. This is problematic because if a WriteConflictException is thrown, the locks and ticket will be held in logWriteConflictAndBackoff, which sleeps.

       

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            gregory.wlodarek@mongodb.com Gregory Wlodarek
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: