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

Remove recursion from SessionCatalogMigrationSource::_fetchNextNewWriteOplog

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: 6.0 Required, 7.0 Required, 8.0 Required
    • Component/s: None
    • Cluster Scalability
    • Fully Compatible
    • Cluster Scalability Priorities, Cluster Scalability 06/24/24, Cluster Scalability 2024-07-08

      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:
            cheahuychou.mao@mongodb.com Cheahuychou Mao
            Reporter:
            ivan.fefer@mongodb.com Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: