Skip to content

Commit

Permalink
IGNITE-24157 Added LastArchivedSegment metric (#11794)
Browse files Browse the repository at this point in the history
  • Loading branch information
maksaska authored Jan 28, 2025
1 parent 3f0c010 commit f47b67c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
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

0 comments on commit f47b67c

Please sign in to comment.