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

Enforce constraints on "multi-timestamp" transactions

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0
    • Affects Version/s: None
    • Component/s: Storage
    • None
    • Fully Compatible
    • Execution Team 2020-07-13, Execution Team 2020-08-24, Execution Team 2020-09-21, Execution Team 2020-10-05, Execution Team 2020-10-19
    • 0

      While MongoDB's storage API historically allowed for composing smaller write units of work into bigger ones by nesting WriteUnitOfWork RAII types, since the addition of user-level timestamping, not all transactions are safely composable in this way. Consider the following example:

      # A single MongoDB crud transaction will:
      #  1) Write A
      #  2) SetTimestamp T
      #  3) Write B
      # Intending for timestamp T to apply to both A and B. Concatenating
      # two crud operations gives:
      #  1) Write A
      #  2) SetTimestamp T
      #  3) Write B
      #  4) Write C
      #  5) SetTimestamp T+1
      #  6) Write D
      # Intending for timestamp T to apply to write's A and B, and T+1
      # to apply to C and D. But is that what happens?
      #
      # It turns out the writes to B and C are visible at T, however A
      # and D are not.
      | Writer               | Reader           |
      |----------------------+------------------|
      | Begin                |                  |
      | Write A 1            |                  |
      | Timestamp :commit 10 |                  |
      | Write B 1            |                  |
      | Write C 1            |                  |
      | Timestamp :commit 20 |                  |
      | Write D 1            |                  |
      | Commit               |                  |
      |                      | Begin :readAt 15 |
      |                      | Read A           |
      |                      | Read B           |
      |                      | Read C           |
      |                      | Read D           |
      

      The invariant that I think makes sense to suss out the typical pattern that goes bad (said two different ways):

      • If a transaction sets multiple timestamps, the first timestamp must be set prior to any writes
      • If a transaction writes a document before setting a timestamp, it must not set multiple timestamps.

            Assignee:
            gregory.wlodarek@mongodb.com Gregory Wlodarek
            Reporter:
            daniel.gottlieb@mongodb.com Daniel Gottlieb (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: