...
Capturing from the buffer (transaction threadswal-sync-thread)
- In wal-sync-thread (the only reader of mmap WAL), under the lock that synchronizes preparing ReadSegment and rolling the WAL segment, to guarantee there are no changes in the underlying buffer.
- Offers a deep copy of flushing ReadSegments to the CdcWorker.
- CdcWorker checks remaining capacity and the buffer size
- If the size fits the capacity then store the offered buffer data into the Queue.
- Otherwise:
- remove from the queue tail segments to free space for the offered buffer
- store the head of the offered buffer as nextHead (WALPointer)
- It captures data from the Queue while nextHead is not reached.
- Switch to the archiveMode.
...