[SERVER-72885] Are change events of a single transaction always grouped together? Created: 17/Jan/23  Updated: 18/Jan/23  Resolved: 18/Jan/23

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

Type: Question Priority: Major - P3
Reporter: Kiruphasankaran Nataraj Assignee: Yuan Fang
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-72718 Not able to identify the transaction ... Closed
Related
related to SERVER-72718 Not able to identify the transaction ... Closed
Participants:

 Description   

The change event associated with a transaction comes with a lsid and a txnNumber which helps to uniquely identify a transaction. When executing transactions from multiple clients concurrently, is it guaranteed that the change events of a transaction are always grouped together?



 Comments   
Comment by Yuan Fang [ 18/Jan/23 ]

Hi kirupha2000@gmail.com,

Thank you for bringing this to our attention and providing a detailed explanation. To quickly answer your question, change events of a single transaction in MongoDB are not guaranteed to always be grouped together. Thus, the second scenario in your comment is possible.

For more information, please refer to SERVER-72718, as I have already addressed a similar question you posted there. I will be closing this ticket as it duplicates SERVER-72718. Thank you for your understanding.

Regards,
Yuan

Comment by Kiruphasankaran Nataraj [ 18/Jan/23 ]

This is in the context of Change Streams. While opening a Change Stream on a MongoDB deployment, is it guaranteed that the change events of a transaction always appear together without any interleaving operations even if multiple clients execute multiple transactions on the same deployment concurrently?

For example, if two transactions are executed with 4 inserts, say Txn1 and Txn2, currently the change events as observed as follows (lsid and txnNumber values are assumed for simplicity):

  • lsid: 123          txnNumber: 1
  • lsid: 123          txnNumber: 1
  • lsid: 123          txnNumber: 1
  • lsid: 123          txnNumber: 1
  • lsid: 123          txnNumber: 2
  • lsid: 123          txnNumber: 2
  • lsid: 123          txnNumber: 2
  • lsid: 123          txnNumber: 2

For the change events associated with a single transaction, the lsid and txnNumber is the same and the above example shows the change events associated with each individual transaction being grouped together.

Is there a possibility of the change events of a transaction appearing interleaved or mixed within the change events of another transaction? For example, is there a possibility of the change events appearing as follows:

  • lsid: 123          txnNumber: 1
  • lsid: 123          txnNumber: 2
  • lsid: 123          txnNumber: 1
  • lsid: 123          txnNumber: 1
  • lsid: 123          txnNumber: 2
  • lsid: 123          txnNumber: 1
  • lsid: 123          txnNumber: 2
  • lsid: 123          txnNumber: 2
Generated at Thu Feb 08 06:23:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.