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

OpObserver's callback methods must not have return values

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.7.3
    • Affects Version/s: None
    • Component/s: Replication
    • Labels:
      None
    • Fully Compatible
    • Platforms 2018-01-29, Platforms 2018-02-12, Platforms 2018-02-26, Platforms 2018-03-12

      The OpObserverRegistry was introduced as an abstraction to allow decoupling making data modifications from the side effects, which need to happen as a result of these modifications, such as op log writes, retryable writes, etc.

      Some of the OpObserver's methods currently return the OpTime which resulted from logging the operation to the replication oplog. In addition, in certain cases, the OpTime resulting from an earlier OpObserver might be needed by a later one, which is the case with retryable writes.

      In order to support these requirements, the OpObserver(s) chain should have access to some common per-operation structure, where runtime information could be persisted.

      The specification is:

      • Add a decoration on the `OperationContext` and place it in the protected section of `OpObserver`. It should contain an `std::vector<OpTime> reservedOpTimes`.
      • Change all `OpObserverRegistry` methods to have a scoped guard, which clears that vector.
      • Change the `repl::logOp` call to invariant that this vector is empty and populate it with the set of timestamps, which it produced.
      • Change the `OpObserverRegistry's onDropCollection` and `onRenameCollection` methods to not call `_forEachObserver`, but instead loop and invariant that the return values of the chained calls are null `OpTimes` (`isNull()`) and instead end in:
        `if (reservedOpTimes.empty()) return OpTime();
        else { invariant(reservedOpTimes.size() == 1); return reservedOpTimes[0];}

        `
        Change `OpObserverImpl`'s `onDropCollection` and `onRenameCollection` methods to return null `OpTimes`.

            Assignee:
            adam.martin@mongodb.com ADAM Martin (Inactive)
            Reporter:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: