Skip to content

Commit 9430887

Browse files
authored
IGNITE-28099 Fix eviction warning to be logged per data region (#12953)
1 parent 4984f18 commit 9430887

2 files changed

Lines changed: 28 additions & 34 deletions

File tree

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
164164
/** Page size from memory configuration, may be set only for fake(standalone) IgniteCacheDataBaseSharedManager */
165165
private int pageSize;
166166

167-
/** First eviction was warned flag. */
168-
private volatile boolean firstEvictWarn;
169-
170167
/** Data storege metrics. */
171168
protected final DataStorageMetricsImpl dsMetrics;
172169

170+
/** */
171+
private final Object mux = new Object();
172+
173173
/**
174174
* @param ctx Kernal context.
175175
*/
@@ -1247,9 +1247,22 @@ public void ensureFreeSpace(DataRegion memPlc) throws IgniteCheckedException {
12471247
return;
12481248

12491249
while (memPlc.evictionTracker().evictionRequired()) {
1250-
memPlc.metrics().onPageEvictionsStarted();
1250+
boolean shouldLog = false;
12511251

1252-
warnFirstEvict(memPlc.config());
1252+
if (!memPlc.metrics().isEvictionsStarted()) {
1253+
synchronized (mux) {
1254+
if (!memPlc.metrics().isEvictionsStarted()) {
1255+
memPlc.metrics().onPageEvictionsStarted();
1256+
1257+
shouldLog = true;
1258+
}
1259+
}
1260+
}
1261+
1262+
if (shouldLog) {
1263+
U.warn(log, "Page-based evictions started." +
1264+
" Consider increasing 'maxSize' on Data Region configuration: " + memPlc.config().getName());
1265+
}
12531266

12541267
memPlc.evictionTracker().evictDataPage();
12551268

@@ -1587,26 +1600,6 @@ public void lastCheckpointInapplicableForWalRebalance(int grpId) {
15871600
// No-op.
15881601
}
15891602

1590-
/**
1591-
* Warns on first eviction.
1592-
* @param regCfg data region configuration.
1593-
*/
1594-
private void warnFirstEvict(DataRegionConfiguration regCfg) {
1595-
if (firstEvictWarn)
1596-
return;
1597-
1598-
// Do not move warning output to synchronized block (it causes warning in IDE).
1599-
synchronized (this) {
1600-
if (firstEvictWarn)
1601-
return;
1602-
1603-
firstEvictWarn = true;
1604-
}
1605-
1606-
U.warn(log, "Page-based evictions started." +
1607-
" Consider increasing 'maxSize' on Data Region configuration: " + regCfg.getName());
1608-
}
1609-
16101603
/**
16111604
* Checking existence of a warm-up configuration.
16121605
*

modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteDataStorageMetricsSelfTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,11 @@ public void testEvictionsStartedMetric() throws Exception {
532532

533533
String template = "Page-based evictions started. Consider increasing 'maxSize' on Data Region configuration: ";
534534

535-
LogListener lsnr = LogListener.matches(template + NO_PERSISTENCE_1).build();
535+
LogListener lsnr1 = LogListener.matches(template + NO_PERSISTENCE_1).build();
536+
LogListener lsnr2 = LogListener.matches(template + NO_PERSISTENCE_2).build();
536537

537-
listeningLog.registerListener(lsnr);
538+
listeningLog.registerListener(lsnr1);
539+
listeningLog.registerListener(lsnr2);
538540

539541
DataRegionMetrics memMetrics1 = ignite.dataRegionMetrics(NO_PERSISTENCE_1);
540542
DataRegionMetrics memMetrics2 = ignite.dataRegionMetrics(NO_PERSISTENCE_2);
@@ -550,25 +552,24 @@ public void testEvictionsStartedMetric() throws Exception {
550552

551553
String big = repeat('X', 256 * 1024);
552554

553-
int entryCnt = 0;
555+
int entryCntMax = 1_000_000;
554556

555-
for (int i = 0; i < 1_000_000 && !lsnr.check(); i++) {
557+
for (int i = 0; i < entryCntMax && !lsnr1.check(); i++)
556558
cacheNp1.put(i, new Person("first-" + i + "-" + big, "last-" + i + "-" + big));
557559

558-
entryCnt++;
559-
}
560-
561-
assertTrue(lsnr.check());
560+
assertTrue(lsnr1.check());
562561

563562
memMetrics1 = ignite.dataRegionMetrics(NO_PERSISTENCE_1);
564563
memMetrics2 = ignite.dataRegionMetrics(NO_PERSISTENCE_2);
565564

566565
assertTrue(memMetrics1.isEvictionsStarted());
567566
assertFalse(memMetrics2.isEvictionsStarted());
568567

569-
for (int i = 0; i < entryCnt + 10; i++)
568+
for (int i = 0; i < entryCntMax && !lsnr2.check(); i++)
570569
cacheNp2.put(i, new Person("first-" + i + "-" + big, "last-" + i + "-" + big));
571570

571+
assertTrue(lsnr2.check());
572+
572573
memMetrics1 = ignite.dataRegionMetrics(NO_PERSISTENCE_1);
573574
memMetrics2 = ignite.dataRegionMetrics(NO_PERSISTENCE_2);
574575

0 commit comments

Comments
 (0)