Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-24157 LastArchivedSegment metric for WAL archive #11794

Merged
merged 4 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/_docs/monitoring-metrics/new-metrics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ Register name: `io.datastorage`
|CheckpointTotalTime| long | Total duration of checkpoint
|CheckpointWalRecordFsyncHistogram| histogram | Histogram of the WAL fsync after logging ChTotalNodeseckpointRecord on begin of checkpoint duration in milliseconds.
|CheckpointWriteEntryHistogram| histogram | Histogram of entry buffer writing to file duration in milliseconds.
|LastArchivedSegment | long | Last archived segment index.
|LastCheckpointBeforeLockDuration| long | Duration of the checkpoint action before taken write lock in milliseconds.
|LastCheckpointCopiedOnWritePagesNumber| long | Number of pages copied to a temporary checkpoint buffer during the last checkpoint.
|LastCheckpointDataPagesNumber| long | Total number of data pages written during the last checkpoint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ public DataStorageMetricsImpl(
this::walTotalSize,
"Total size in bytes for storage wal files.");

mreg.register("LastArchivedSegment",
this::lastArchivedSegment,
"Last archived segment index.");

long[] cpBounds = new long[] {100, 500, 1000, 5000, 30000};

cpBeforeLockHistogram = mreg.histogram("CheckpointBeforeLockHistogram", cpBounds,
Expand Down Expand Up @@ -362,6 +366,16 @@ private int walArchiveSegments() {
return walMgr == null ? 0 : walMgr.walArchiveSegments();
}

/** @return Last archived segment index. */
private long lastArchivedSegment() {
if (!metricsEnabled)
return -1;

IgniteWriteAheadLogManager walMgr = this.wal;

return walMgr == null ? -1 : walMgr.lastArchivedSegment();
}

/**
* @return The average WAL fsync duration in microseconds over the last time interval.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public class IgniteDataStorageMetricsSelfTest extends GridCommonAbstractTest {
.setMaxSize(maxRegionSize)
.setPersistenceEnabled(true)
.setMetricsEnabled(true)
.setName(PERSISTENCE_REGION_1))
.setName(PERSISTENCE_REGION_1)
.setCdcEnabled(true))
.setDataRegionConfigurations(
new DataRegionConfiguration()
.setMaxSize(maxRegionSize)
Expand Down Expand Up @@ -538,6 +539,17 @@ private void checkWalArchiveAndTotalSize(IgniteEx igniteEx, boolean hasWalArchiv
totalSize += walMgr.totalSize(walFiles(router.getWalArchiveDir()));

assertEquals(totalSize, dsMetricRegistry(igniteEx).<LongGauge>findMetric("WalTotalSize").value());

long lastArchivedSegIdx = dsMetricRegistry(igniteEx).<LongGauge>findMetric("LastArchivedSegment").value();

if (router.hasArchive()) {
long cdcWalArchiveSegments = walFiles(walMgr.walCdcDirectory()).length;

// Count of segments = LastArchivedSegmentIndex + 1
assertEquals(cdcWalArchiveSegments, lastArchivedSegIdx + 1);
}
else
assertEquals(-1, lastArchivedSegIdx);
}

/**
Expand Down