Skip to content

Commit b077992

Browse files
committed
Bug 39023215 - [38914458->14.1.2.0.6] RFA : Parallel queries to the cache return inconsistent results in 14c latest versions.
[git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v14.1.2.0/": change = 119059]
1 parent 28bc3ec commit b077992

File tree

26 files changed

+413
-156
lines changed

26 files changed

+413
-156
lines changed

prj/coherence-core-components/src/main/java/com/tangosol/coherence/component/util/daemon/queueProcessor/service/grid/partitionedService/PartitionedCache.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -10320,7 +10320,7 @@ public boolean recoverPartition(int iPartition, com.oracle.coherence.persistence
1032010320
finally
1032110321
{
1032210322
// schedule an index update
10323-
if (cRecovered > 0 && isIndexed() && getDaemonPool().isStarted())
10323+
if (cRecovered > 0 && getDaemonPool().isStarted())
1032410324
{
1032510325
scheduleIndexUpdate(iPartition, com.tangosol.util.MapEvent.ENTRY_INSERTED);
1032610326
}
@@ -12004,7 +12004,7 @@ protected synchronized void updateIndexPartition(Map<Integer, AtomicInteger> par
1200412004
{
1200512005
partsCounter.computeIfPresent(nPartition, (k, v) ->
1200612006
{
12007-
if (v.decrementAndGet() <= 1)
12007+
if (v.decrementAndGet() <= 0)
1200812008
{
1200912009
return null;
1201012010
}

prj/coherence-core/src/main/java/com/tangosol/internal/util/PartitionedIndexMap.java

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -79,18 +79,30 @@ public PartitionedIndexMap(BackingMapContext ctx,
7979
*/
8080
public <E> MapIndex<K, V, E> get(ValueExtractor<V, E> extractor)
8181
{
82-
int nPart = f_partitions == null
83-
? f_mapPartitioned.keySet().stream().findFirst().orElse(-1)
84-
: f_partitions.rnd();
82+
MapIndex<K, V, E> mapIndexSample = null;
8583

86-
MapIndex<K, V, E> mapIndex = getMapIndex(nPart, extractor);
87-
if (mapIndex != null)
84+
if (f_partitions != null && f_partitions.cardinality() == 1)
8885
{
89-
return f_partitions != null && f_partitions.cardinality() == 1
90-
? mapIndex // optimize for single partition
91-
: new PartitionedIndex(extractor, mapIndex.isOrdered(), mapIndex.getComparator());
86+
int nPart = f_partitions.next(0);
87+
return getMapIndex(nPart, extractor);
9288
}
93-
return null;
89+
90+
for (int nPart : getPartitions())
91+
{
92+
MapIndex<K, V, E> mapIndex = getMapIndex(nPart, extractor);
93+
if (mapIndex != null)
94+
{
95+
mapIndexSample = mapIndex;
96+
break;
97+
}
98+
}
99+
100+
if (mapIndexSample == null)
101+
{
102+
return null;
103+
}
104+
105+
return new PartitionedIndex(extractor, mapIndexSample.isOrdered(), mapIndexSample.getComparator());
94106
}
95107

96108
/**
@@ -218,10 +230,10 @@ public boolean isOrdered()
218230
@Override
219231
public boolean isPartial()
220232
{
221-
for (Map<ValueExtractor<V, ?>, MapIndex<K, V, ?>> mapPart : f_mapPartitioned.values())
233+
for (int nPart : getPartitions())
222234
{
223-
MapIndex<K, V, ?> mapIndex = mapPart.get(f_extractor);
224-
if (mapIndex != null && mapIndex.isPartial())
235+
MapIndex<K, V, ?> mapIndex = getMapIndex(nPart, f_extractor);
236+
if (mapIndex == null || mapIndex.isPartial())
225237
{
226238
return true;
227239
}

prj/coherence-core/src/main/java/com/tangosol/util/filter/BetweenFilter.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -23,6 +23,7 @@
2323
import java.util.NavigableMap;
2424

2525
import static com.tangosol.util.filter.ExtractorFilter.ensureSafeSet;
26+
import static com.tangosol.util.filter.ExtractorFilter.isInapplicableIndex;
2627

2728
/**
2829
* Filter which compares the result of a method invocation with a value for
@@ -259,9 +260,10 @@ public Filter applyIndex(Map mapIndexes, Set setKeys)
259260

260261
MapIndex index = (MapIndex) mapIndexes.get(getValueExtractor());
261262

262-
if (index == null)
263+
if (isInapplicableIndex(index))
263264
{
264-
// there is no relevant index; evaluate individual entries
265+
// there is no relevant index, or partitioned index is incomplete;
266+
// fall back to entry-by-entry evaluation
265267
return this;
266268
}
267269
else if (index.getIndexContents().isEmpty())
@@ -301,9 +303,9 @@ else if (index.getIndexContents().isEmpty())
301303
public int calculateEffectiveness(Map mapIndexes, Set setKeys)
302304
{
303305
MapIndex index = (MapIndex) mapIndexes.get(getValueExtractor());
304-
if (index == null)
306+
if (isInapplicableIndex(index))
305307
{
306-
// there is no relevant index
308+
// there is no relevant index, or partitioned index is incomplete
307309
return -1;
308310
}
309311

@@ -440,6 +442,7 @@ protected void applySortedIndex(MapIndex index, Set setKeys, NavigableMap<E, Set
440442
}
441443

442444
NavigableMap<E, Set<?>> mapRange = mapContents.subMap(getLowerBound(), isLowerBoundInclusive(), getUpperBound(), isUpperBoundInclusive());
445+
443446
Collection colKeysToRetain = new HashSet<>();
444447

445448
for (Map.Entry<E, Set<?>> entry : mapRange.entrySet())
@@ -497,4 +500,5 @@ else if (!getLowerFilter().evaluateExtracted(hiValue) || (loValue != null && !ge
497500

498501
return null;
499502
}
503+
500504
}

prj/coherence-core/src/main/java/com/tangosol/util/filter/ContainsAllFilter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -153,9 +153,9 @@ public String toStringValue()
153153
public int calculateEffectiveness(Map mapIndexes, Set setKeys)
154154
{
155155
MapIndex index = (MapIndex) mapIndexes.get(getValueExtractor());
156-
if (index == null)
156+
if (isInapplicableIndex(index))
157157
{
158-
// there is no relevant index
158+
// there is no relevant index, or partitioned index is incomplete
159159
return -1;
160160
}
161161
else
@@ -202,9 +202,10 @@ else if (setMatches == null)
202202
public Filter applyIndex(Map mapIndexes, Set setKeys)
203203
{
204204
MapIndex index = (MapIndex) mapIndexes.get(getValueExtractor());
205-
if (index == null)
205+
if (isInapplicableIndex(index))
206206
{
207-
// there is no relevant index
207+
// there is no relevant index, or partitioned index is incomplete;
208+
// fall back to entry-by-entry evaluation
208209
return this;
209210
}
210211
else

prj/coherence-core/src/main/java/com/tangosol/util/filter/ContainsAnyFilter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -157,9 +157,9 @@ public String toStringValue()
157157
public int calculateEffectiveness(Map mapIndexes, Set setKeys)
158158
{
159159
MapIndex index = (MapIndex) mapIndexes.get(getValueExtractor());
160-
if (index == null)
160+
if (isInapplicableIndex(index))
161161
{
162-
// there is no relevant index
162+
// there is no relevant index, or partitioned index is incomplete
163163
return -1;
164164
}
165165
else
@@ -192,9 +192,10 @@ public int calculateEffectiveness(Map mapIndexes, Set setKeys)
192192
public Filter applyIndex(Map mapIndexes, Set setKeys)
193193
{
194194
MapIndex index = (MapIndex) mapIndexes.get(getValueExtractor());
195-
if (index == null)
195+
if (isInapplicableIndex(index))
196196
{
197-
// there is no relevant index
197+
// there is no relevant index, or partitioned index is incomplete;
198+
// fall back to entry-by-entry evaluation
198199
return this;
199200
}
200201
else

prj/coherence-core/src/main/java/com/tangosol/util/filter/ContainsFilter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2023, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -121,9 +121,9 @@ else if (extracted instanceof Object[])
121121
public int calculateEffectiveness(Map mapIndexes, Set setKeys)
122122
{
123123
MapIndex index = (MapIndex) mapIndexes.get(getValueExtractor());
124-
if (index == null)
124+
if (isInapplicableIndex(index))
125125
{
126-
// there is no relevant index
126+
// there is no relevant index, or partitioned index is incomplete
127127
return -1;
128128
}
129129
else
@@ -139,9 +139,10 @@ public int calculateEffectiveness(Map mapIndexes, Set setKeys)
139139
public Filter applyIndex(Map mapIndexes, Set setKeys)
140140
{
141141
MapIndex index = (MapIndex) mapIndexes.get(getValueExtractor());
142-
if (index == null)
142+
if (isInapplicableIndex(index))
143143
{
144-
// there is no relevant index
144+
// there is no relevant index, or partitioned index is incomplete;
145+
// fall back to entry-by-entry evaluation
145146
return this;
146147
}
147148
else

prj/coherence-core/src/main/java/com/tangosol/util/filter/EqualsFilter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2023, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -86,9 +86,9 @@ protected boolean evaluateExtracted(E extracted)
8686
public int calculateEffectiveness(Map mapIndexes, Set setKeys)
8787
{
8888
MapIndex index = (MapIndex) mapIndexes.get(getValueExtractor());
89-
if (index == null)
89+
if (isInapplicableIndex(index))
9090
{
91-
// there is no relevant index
91+
// there is no relevant index, or partitioned index is incomplete
9292
return -1;
9393
}
9494
else
@@ -104,9 +104,10 @@ public int calculateEffectiveness(Map mapIndexes, Set setKeys)
104104
public Filter applyIndex(Map mapIndexes, Set setKeys)
105105
{
106106
MapIndex index = (MapIndex) mapIndexes.get(getValueExtractor());
107-
if (index == null)
107+
if (isInapplicableIndex(index))
108108
{
109-
// there is no relevant index
109+
// there is no relevant index, or partitioned index is incomplete;
110+
// fall back to entry-by-entry evaluation
110111
return this;
111112
}
112113
else

prj/coherence-core/src/main/java/com/tangosol/util/filter/ExtractorFilter.java

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2026, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -161,7 +161,7 @@ protected E extract(T o)
161161
public int calculateEffectiveness(Map mapIndexes, Set setKeys)
162162
{
163163
MapIndex index = (MapIndex) mapIndexes.get(getValueExtractor());
164-
return index == null
164+
return isInapplicableIndex(index)
165165
? -1
166166
: setKeys.size();
167167
}
@@ -173,8 +173,10 @@ public int calculateEffectiveness(Map mapIndexes, Set setKeys)
173173
public Filter applyIndex(Map mapIndexes, Set setKeys)
174174
{
175175
MapIndex<?, ?, E> index = (MapIndex) mapIndexes.get(getValueExtractor());
176-
if (index == null)
176+
if (isInapplicableIndex(index))
177177
{
178+
// there is no relevant index, or partitioned index is incomplete;
179+
// fall back to entry-by-entry evaluation
178180
return this;
179181
}
180182

@@ -259,6 +261,34 @@ protected static Set ensureSafeSet(Set set)
259261
return set == null ? Collections.emptySet() : set;
260262
}
261263

264+
/**
265+
* Return {@code true} if the index cannot be used for optimization.
266+
*
267+
* @param index the index to test
268+
*
269+
* @return {@code true} if the index cannot be used for optimization
270+
*/
271+
protected static boolean isInapplicableIndex(MapIndex index)
272+
{
273+
return index == null || isIncompletePartitionedIndex(index);
274+
}
275+
276+
/**
277+
* Return {@code true} if the specified index is a partitioned composite
278+
* index in an incomplete state (e.g. at least one partition is missing the
279+
* corresponding per-partition index).
280+
*
281+
* @param index the index to test
282+
*
283+
* @return {@code true} if the index is an incomplete partitioned index
284+
*/
285+
protected static boolean isIncompletePartitionedIndex(MapIndex index)
286+
{
287+
return index != null
288+
&& "com.tangosol.internal.util.PartitionedIndexMap$PartitionedIndex".equals(index.getClass().getName())
289+
&& index.isPartial();
290+
}
291+
262292
// ----- constants ------------------------------------------------------
263293

264294
/**

0 commit comments

Comments
 (0)