This is an automated email from the ASF dual-hosted git repository.
wernerdv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new e54b0336b20 IGNITE-29216 Add metric for CacheVersionConflictResolver
resolution failures (#13753)
e54b0336b20 is described below
commit e54b0336b20f745a806d4b6c66ae4df1feda9141
Author: Dmitry Werner <[email protected]>
AuthorDate: Tue Nov 3 00:55:34 2026 +0800
IGNITE-29216 Add metric for CacheVersionConflictResolver resolution
failures (#13753)
---
.../change-data-capture/overview.adoc | 6 +++++
docs/_docs/monitoring-metrics/new-metrics.adoc | 3 ++-
.../processors/cache/CacheMetricsImpl.java | 14 ++++++++++++
.../processors/cache/GridCacheContext.java | 3 +++
.../version/GridCacheVersionConflictContext.java | 15 +++++++++++++
.../metric/CacheMetricsConflictResolverTest.java | 26 +++++++++++++++++-----
6 files changed, 60 insertions(+), 7 deletions(-)
diff --git
a/docs/_docs/extensions-and-integrations/change-data-capture/overview.adoc
b/docs/_docs/extensions-and-integrations/change-data-capture/overview.adoc
index 3ef17e7ff98..4bf4e4b5d99 100644
--- a/docs/_docs/extensions-and-integrations/change-data-capture/overview.adoc
+++ b/docs/_docs/extensions-and-integrations/change-data-capture/overview.adoc
@@ -75,6 +75,7 @@ IMPORTANT: This approach does not replicate any updates or
removals from the des
.Algorithm:
.. Changes from the "local" cluster are always win. Any replicated data can be
overridden locally.
+.. If the entry is freshly created (there is no previous version of it) then
the new entry is used.
.. If both old and new entry are from the same cluster then entry versions
comparison is used to determine the order.
.. Conflict resolution failed. Update will be ignored. Failure will be logged.
@@ -87,8 +88,10 @@ IMPORTANT: This approach does not replicate the removals
from the destination cl
.Algorithm:
.. Changes from the "local" cluster are always win. Any replicated data can be
overridden locally.
+.. If the entry is freshly created (there is no previous version of it) then
the new entry is used.
.. If both old and new entry are from the same cluster then entry versions
comparison is used to determine the order.
.. If `conflictResolveField` is provided then field values comparison is used
to determine the order.
+.. If the field values are equal and both entries hold the same value then the
update is ignored and is not considered a failure.
.. Conflict resolution failed. Update will be ignored. Failure will be logged.
==== Custom conflict resolution rules
@@ -100,6 +103,9 @@ You should consider the nature of your transactions, the
rate of change of your
Custom conflict resolver can be set via `conflictResolver` and allows to
compare or merge the conflict data in any required way.
+==== Conflict resolution metrics
+To monitor conflict resolution, use the `ConflictResolverAcceptedCount`,
`ConflictResolverRejectedCount`, `ConflictResolverMergedCount` and
`ConflictResolverFailedCount` metrics from the `cache.{cache_name}`
link:monitoring-metrics/new-metrics#caches[metric registry].
+
=== Configuration example
Configuration is done via Ignite node plugin:
diff --git a/docs/_docs/monitoring-metrics/new-metrics.adoc
b/docs/_docs/monitoring-metrics/new-metrics.adoc
index b055dc40695..ad5c1a0d52b 100644
--- a/docs/_docs/monitoring-metrics/new-metrics.adoc
+++ b/docs/_docs/monitoring-metrics/new-metrics.adoc
@@ -114,6 +114,7 @@ Register name: `cache.{cache_name}.{near}`
|CommitTime | histogram | Commit time in nanoseconds.
|CommitTimeTotal | long | The total time of commit, in nanoseconds.
|ConflictResolverAcceptedCount | long | Conflict resolver accepted entries
count.
+|ConflictResolverFailedCount | long | Conflict resolver failed resolutions
count.
|ConflictResolverMergedCount | long | Conflict resolver merged entries count.
|ConflictResolverRejectedCount | long | Conflict resolver rejected entries
count.
|EntryProcessorHits | long | The total number of invocations on keys, which
exist in cache.
@@ -169,7 +170,7 @@ Register name: `cache.{cache_name}.{near}`
|TxKeyCollisions | string | Tx key collisions. Show keys and collisions queue
size. Due transactional payload some keys become hot. Metric shows
corresponding keys.
|===
-NOTE: `ConflictResolver*` metrics are registered only when a conflict resolver
is configured for the cache. `IsCacheAffinityConfigurationMdcSafe` and
`IsCachePartitionDistributionSafe` are registered on server nodes only, and
only when the node has a data center ID.
+NOTE: `ConflictResolver*` metrics are registered only when a conflict resolver
is configured for the cache. Entries counted by `ConflictResolverFailedCount`
are also counted by `ConflictResolverRejectedCount`.
`IsCacheAffinityConfigurationMdcSafe` and `IsCachePartitionDistributionSafe`
are registered on server nodes only, and only when the node has a data center
ID.
== Cache Groups
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
index 96944115989..b7489c90bed 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
@@ -250,6 +250,9 @@ public class CacheMetricsImpl implements CacheMetrics {
/** Conflict resolver merged entries count. */
private LongAdderMetric rslvrMergedCnt;
+ /** Conflict resolver failed resolutions count. */
+ private LongAdderMetric rslvrFailedCnt;
+
/** Affinity configuration MDC safe metric. */
private volatile Boolean affCfgMdcSafe;
@@ -781,6 +784,9 @@ public class CacheMetricsImpl implements CacheMetrics {
if (rslvrMergedCnt != null)
rslvrMergedCnt.reset();
+
+ if (rslvrFailedCnt != null)
+ rslvrFailedCnt.reset();
}
/** {@inheritDoc} */
@@ -1792,6 +1798,11 @@ public class CacheMetricsImpl implements CacheMetrics {
rslvrMergedCnt.increment();
}
+ /** */
+ public void incrementResolverFailedCount() {
+ rslvrFailedCnt.increment();
+ }
+
/** Registers metrics for conflict resolver. */
public void registerResolverMetrics() {
rslvrAcceptedCnt =
mreg.longAdderMetric("ConflictResolverAcceptedCount",
@@ -1802,6 +1813,9 @@ public class CacheMetricsImpl implements CacheMetrics {
rslvrMergedCnt = mreg.longAdderMetric("ConflictResolverMergedCount",
"Conflict resolver merged entries count");
+
+ rslvrFailedCnt = mreg.longAdderMetric("ConflictResolverFailedCount",
+ "Conflict resolver failed resolutions count");
}
/** Registers metric for partition distribution. */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 68843a88050..10ca046d700 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1578,6 +1578,9 @@ public class GridCacheContext<K, V> implements
Externalizable {
else
cache().metrics0().incrementResolverMergedCount();
+ if (ctx.isResolveFailed())
+ cache().metrics0().incrementResolverFailedCount();
+
if (ctx.isManualResolve())
drMgr.onReceiveCacheConflictResolved(ctx.isUseNew(),
ctx.isUseOld(), ctx.isMerge());
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContext.java
index 42ea4bff9d2..aae2953b4dc 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContext.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContext.java
@@ -54,6 +54,9 @@ public class GridCacheVersionConflictContext<K, V> {
/** Manual resolve flag. */
private boolean manualResolve;
+ /** Resolve failed flag. */
+ private boolean resolveFailed;
+
/**
* Constructor.
*
@@ -172,6 +175,18 @@ public class GridCacheVersionConflictContext<K, V> {
return manualResolve;
}
+ /** Forces the cache to ignore the new entry and marks that the conflict
could not be resolved. */
+ public void markResolveFailed() {
+ useOld();
+
+ resolveFailed = true;
+ }
+
+ /** @return {@code True} if the conflict could not be resolved. */
+ public boolean isResolveFailed() {
+ return resolveFailed;
+ }
+
/**
* @return Value to merge (if any).
*/
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/metric/CacheMetricsConflictResolverTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/metric/CacheMetricsConflictResolverTest.java
index b2385935fcc..87c6a79a46b 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/metric/CacheMetricsConflictResolverTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/metric/CacheMetricsConflictResolverTest.java
@@ -64,34 +64,43 @@ public class CacheMetricsConflictResolverTest extends
GridCommonAbstractTest {
IgniteCache<Object, Object> cache =
ign.getOrCreateCache(DEFAULT_CACHE_NAME);
- checkMetrics(0, 0, 0);
+ checkMetrics(0, 0, 0, 0);
TestCacheVersionConflictResolver.plc = ResolvePolicy.USE_NEW;
cache.put(0, 0);
- checkMetrics(1, 0, 0);
+ checkMetrics(1, 0, 0, 0);
TestCacheVersionConflictResolver.plc = ResolvePolicy.USE_OLD;
cache.put(0, 0);
- checkMetrics(1, 1, 0);
+ checkMetrics(1, 1, 0, 0);
TestCacheVersionConflictResolver.plc = ResolvePolicy.MERGE;
cache.put(0, 0);
- checkMetrics(1, 1, 1);
+ checkMetrics(1, 1, 1, 0);
+
+ TestCacheVersionConflictResolver.plc = ResolvePolicy.FAIL;
+
+ cache.put(0, 1);
+
+ assertEquals(0, cache.get(0));
+
+ checkMetrics(1, 2, 1, 1);
}
/** */
- private void checkMetrics(int expAccepted, int expRejected, int expMerged)
{
+ private void checkMetrics(int expAccepted, int expRejected, int expMerged,
int expFailed) {
MetricRegistryImpl mreg =
grid(0).context().metric().registry(cacheMetricsRegistryName(DEFAULT_CACHE_NAME,
false));
assertEquals(expAccepted,
mreg.<LongMetric>findMetric("ConflictResolverAcceptedCount").value());
assertEquals(expRejected,
mreg.<LongMetric>findMetric("ConflictResolverRejectedCount").value());
assertEquals(expMerged,
mreg.<LongMetric>findMetric("ConflictResolverMergedCount").value());
+ assertEquals(expFailed,
mreg.<LongMetric>findMetric("ConflictResolverFailedCount").value());
}
/** */
@@ -112,6 +121,8 @@ public class CacheMetricsConflictResolverTest extends
GridCommonAbstractTest {
res.useNew();
else if (plc == ResolvePolicy.USE_OLD)
res.useOld();
+ else if (plc == ResolvePolicy.FAIL)
+ res.markResolveFailed();
else
res.merge(
newEntry.value(ctx),
@@ -141,6 +152,9 @@ public class CacheMetricsConflictResolverTest extends
GridCommonAbstractTest {
USE_NEW,
/** Merge. */
- MERGE
+ MERGE,
+
+ /** Mark the resolution as failed. */
+ FAIL
}
}