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

Determine if lock acquisition can happen inside of the writeConflictRetry in find_and_modify.cpp

    • Type: Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Execution Team 2022-08-22, Execution Team 2022-09-05

      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:
            jordi.olivares-provencio@mongodb.com Jordi Olivares Provencio
            Reporter:
            gregory.wlodarek@mongodb.com Gregory Wlodarek
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: