[SERVER-48771] Enforce constraints on "multi-timestamp" transactions Created: 12/Jun/20  Updated: 29/Oct/23  Resolved: 02/Oct/20

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Improvement Priority: Major - P3
Reporter: Daniel Gottlieb (Inactive) Assignee: Gregory Wlodarek
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-45354 In renameCollectionAcrossDBs, writes ... Closed
Problem/Incident
Related
related to SERVER-64225 Change stream preImage writes on a pr... Closed
related to SERVER-55394 Renaming a collection across database... Closed
related to SERVER-72723 support rollback for multi-oplog batc... Closed
related to SERVER-71655 relax multi-timestamp constraint for ... Closed
is related to SERVER-48772 Dropping multiple indexes incorrectly... Closed
is related to SERVER-51746 Fix the application name for tenant m... Closed
is related to SERVER-51747 Tenant collection cloner calling Stor... Closed
is related to SERVER-52602 OplogBufferCollection calling Storage... Closed
is related to WT-6388 Fix-up out-of-order updates in the hi... Closed
is related to SERVER-51301 Have no-op writes for recording pre/p... Investigating
Backwards Compatibility: Fully Compatible
Sprint: 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
Participants:
Linked BF Score: 0

 Description   

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.


 Comments   
Comment by Githook User [ 02/Oct/20 ]

Author:

{'name': 'Gregory Wlodarek', 'email': 'gregory.wlodarek@mongodb.com', 'username': 'GWlodarek'}

Message: SERVER-48771 Enforce constraints on multi timestamp storage transactions
Branch: master
https://github.com/mongodb/mongo/commit/3027686e373b074bd4c3acca01b19f7173937cf2

Comment by Githook User [ 02/Oct/20 ]

Author:

{'name': 'Tommaso Tocci', 'email': 'tommaso.tocci@mongodb.com', 'username': 'toto-dev'}

Message: Revert "SERVER-48771 Enforce constraints on multi timestamp storage transactions"

This reverts commit 0760780e4afa55be377c2a1a47b43e29132478df.
Branch: master
https://github.com/mongodb/mongo/commit/e74a37aa35b12f4151d2faadad0991f31d897065

Comment by Githook User [ 02/Oct/20 ]

Author:

{'name': 'Gregory Wlodarek', 'email': 'gregory.wlodarek@mongodb.com', 'username': 'GWlodarek'}

Message: SERVER-48771 Enforce constraints on multi timestamp storage transactions
Branch: master
https://github.com/mongodb/mongo/commit/0760780e4afa55be377c2a1a47b43e29132478df

Comment by Githook User [ 02/Oct/20 ]

Author:

{'name': 'Gregory Wlodarek', 'email': 'gregory.wlodarek@mongodb.com', 'username': 'GWlodarek'}

Message: SERVER-48771 Fix multi timestamp constraint violations on storage transactions
Branch: master
https://github.com/mongodb/mongo/commit/bd60c43f3ba4917f6c0e5efb63efc8279cba6af9

Generated at Thu Feb 08 05:18:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.