...
- Explicit stop ignite-cdc.sh
- Explicit stop OnlineCDC
Restart OnlineCDC after buffer overflow:
- Try to switch Ignite from BACKGROUND to ONLINE mode:
- ./control.sh --cdc online --try-switch-to-online
- Command will return immediately, but doesn't guarantee success of the switch. User should check logs and metrics here.
User interface
Ignite
IgniteConfiguration#OnlineCdcConfiguration
- CdcConsumer, keepBinary.DataStorageConfiguration#onlineCdcBufSize
- by default (walSegments * walSegmentSize). it’s now 640 MB by default. - All non-archived segments are fitted in memory. If OnlineCDC requires more space than it, it looks like ordinary CDC process should be used instead.
DataRegionConfiguration#cdcMode
- BACKGROUND, ONLINE (default is BACKGROUND)BACKGROUND
- make hard links of archived segments into cdc directory, that is watched by the background ignite-cdc process.ONLINE
- OnlineCDC enabled + still do BACKGROUND mode job.
- Logs:
- initialization (amount of records read during the restore)
- failure
- buffer is full
- switch from BACKGROUND to ONLINE mode.
- Metrics:Metrics:
- ordinary cdc metrics (count of wal segments, wal entries)
- current buffer size
- status of CDC (on/off)
- last committed WALPointer
- lag between buffer and WAL archive (segments)
- lag between WAL and CDC consumer (milliseconds).
...
control.sh
- CdcOnline subcommand
- ./control.sh --
enable/disable.- cdc online [ --enable ] [ --disable ] [ --try-switch-to-online ]
Segments
Note, there is a confusion of using “segment” word:
...
- Checks metadata (mappings, binary_meta, caches - can check inside Ignite, not reading files), prepare updates if any.
- Polls the Queue, transforms ReadSegment data to Iterator<CdcEvent>, pushes them to CdcConsumer.
- If CdcConsumer#onEvents returns true:
- Persists CdcConsumerState.
- Write
OnlineCdcRecord
record to WAL with the WALPointer.
- Optimization: transform segment buffers to CdcEvents in background (to reduce the buffer usage). CdcConsumer should be async then?
Try switch BACKGROUND to ONLINE mode:
- User sends the command to switch modes
- Ignite does initialization - CdcWorker, buffer
- Writes
TryStartOnlineCdcRecord
into WAL and rollover current segment(since this record OnlineCdc becomes active again). - Ignite monitors the CDC directory, awaits while segment with the record cleaned - it means ignite-cdc.sh reach the record and stops capturing the data.
- If buffer is not overflowed in this moment - Ignite enables CDCConsumer and starts sending the records
- Otherwise, ordinal stop is invoked (with writing StopOnlineCdc record)
Code Block |
---|
|
Code Block |
---|
language | java |
---|
title | WAL records |
---|
|
OnlineCdcRecord extends WALRecord {
private WALPointer last;
}
StopOnlineCdcRecord extends WALRecord {
private WALPointer last;
}
TryStartOnlineCdcRecord extends WALRecord {
} |
ignite-cdc in BACKUP mode
- Parses WAL records, looking for
OnlineCdcRecord
and StopOnlineCdcRecord
- For
OnlineCdcRecord
- clears obsolete links from CDC directory - For
StopOnlineCdcRecord
- switch to ACTIVE mode, start capturing from the last WALPointer (from previous OnlineCdcRecord).
ignite-cdc in ACTIVE mode
- Capturing WAL records
- Looking for
TryStartOnlineCdcRecord
- after reaching it, persist CdcConsumerState locally, switch to BACKUP mode.
Meta Storage
- Online CDC status - ON / OFF
- Committed pointer (confirmed by CdcConsumer).
...