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

Remove recursion from SessionCatalogMigrationSource::_fetchNextNewWriteOplog

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Cluster Scalability
    • Cluster Scalability 06/24/24, Cluster Scalability 2024-07-08, Cluster Scalability 2024-07-22

      SessionCatalogMigrationSource::_fetchNextNewWriteOplog function can make recursive calls.

      Consider the following case:
      1. When oplog entries buffer is empty, it will fetch next oplog entry from the queue.
      2. If this entry is ApplyOps from a transaction, it will unwrap it into several entries using SessionCatalogMigrationSource::_extractOplogEntriesForRetryableApplyOps
      3. After unwrapping, it will make a recursive call. The assumption would be that because we just unwrapped a transaction, we should have an oplog entry in the buffer, so the recursion won't be deep.
      4. However, when unwrapping, we are checking if modified documents are actually a part of the chunk we are migrating in SessionCatalogMigrationSource::shouldSkipOplogEntry.
      5. So if the collection is getting a lot of write transactions, we might get a very deep recursive call, until we find a transaction that affects a migrated chunk.

      This is not theoretical, there are stack traces that fill most of kStackTraceFrameMax with _fetchNextNewWriteOplog.

      To avoid potential problem, I suggest re-writing this function to avoid recursion

            Assignee:
            kshitij.gupta@mongodb.com Kshitij Gupta
            Reporter:
            ivan.fefer@mongodb.com Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: