Skip to content

Commit c80f390

Browse files
authored
IGNITE-13776 BPlus tree lock retries limit reached with sqlOnHeapCacheEnabled (#8514)
1 parent 5230f39 commit c80f390

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,15 @@ public static class GridCacheDataStore implements CacheDataStore {
18481848
*/
18491849
private volatile long nextStoreCleanTimeNanos;
18501850

1851+
/** */
1852+
private GridQueryRowCacheCleaner rowCacheCleaner;
1853+
1854+
/**
1855+
* Mutex used to synchronise publication of initialized delegate link and actions that should change
1856+
* the delegate's state, so the delegate will not be in obsolete state.
1857+
*/
1858+
private final Object delegatePublicationMux = new Object();
1859+
18511860
/** */
18521861
private PartitionMetaStorage<SimpleDataRow> partStorage;
18531862

@@ -2141,7 +2150,11 @@ private CacheDataStore init0(boolean checkExists) throws IgniteCheckedException
21412150
pageMem.releasePage(grpId, partMetaId, partMetaPage);
21422151
}
21432152

2144-
delegate = delegate0;
2153+
synchronized (delegatePublicationMux) {
2154+
delegate0.setRowCacheCleaner(rowCacheCleaner);
2155+
2156+
delegate = delegate0;
2157+
}
21452158
}
21462159
catch (Throwable ex) {
21472160
U.error(log, "Unhandled exception during page store initialization. All further operations will " +
@@ -2543,6 +2556,10 @@ private Metas getOrAllocatePartitionMetas() throws IgniteCheckedException {
25432556
/** {@inheritDoc} */
25442557
@Override public void setRowCacheCleaner(GridQueryRowCacheCleaner rowCacheCleaner) {
25452558
try {
2559+
synchronized (delegatePublicationMux) {
2560+
this.rowCacheCleaner = rowCacheCleaner;
2561+
}
2562+
25462563
CacheDataStore delegate0 = init0(true);
25472564

25482565
if (delegate0 != null)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class RowStore {
5050
private final boolean persistenceEnabled;
5151

5252
/** Row cache cleaner. */
53-
private GridQueryRowCacheCleaner rowCacheCleaner;
53+
private volatile GridQueryRowCacheCleaner rowCacheCleaner;
5454

5555
/** */
5656
protected final CacheGroupContext grp;

modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2RowCacheSelfTest.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,42 @@
1717

1818
package org.apache.ignite.internal.processors.cache.index;
1919

20+
import java.util.Arrays;
21+
import java.util.Collection;
2022
import java.util.Collections;
2123
import java.util.HashSet;
2224
import java.util.List;
2325
import java.util.Map;
2426
import java.util.Random;
2527
import java.util.Set;
2628
import javax.cache.Cache;
29+
import org.apache.ignite.Ignite;
2730
import org.apache.ignite.IgniteCache;
2831
import org.apache.ignite.IgniteCheckedException;
2932
import org.apache.ignite.IgniteDataStreamer;
3033
import org.apache.ignite.cache.QueryEntity;
3134
import org.apache.ignite.cache.query.SqlFieldsQuery;
3235
import org.apache.ignite.cache.query.SqlQuery;
3336
import org.apache.ignite.cache.query.annotations.QuerySqlField;
37+
import org.apache.ignite.cluster.ClusterState;
3438
import org.apache.ignite.configuration.CacheConfiguration;
39+
import org.apache.ignite.configuration.DataRegionConfiguration;
40+
import org.apache.ignite.configuration.DataStorageConfiguration;
41+
import org.apache.ignite.configuration.IgniteConfiguration;
3542
import org.apache.ignite.internal.IgniteEx;
3643
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
3744
import org.apache.ignite.internal.processors.query.h2.H2RowCache;
3845
import org.apache.ignite.internal.processors.query.h2.opt.H2CacheRow;
3946
import org.apache.ignite.testframework.GridTestUtils;
4047
import org.jsr166.ConcurrentLinkedHashMap;
4148
import org.junit.Test;
49+
import org.junit.runner.RunWith;
50+
import org.junit.runners.Parameterized;
4251

4352
/**
4453
* Tests H2RowCacheRegistry.
4554
*/
55+
@RunWith(Parameterized.class)
4656
@SuppressWarnings({"unchecked", "ConstantConditions"})
4757
public class H2RowCacheSelfTest extends AbstractIndexingCommonTest {
4858
/** Keys count. */
@@ -51,18 +61,45 @@ public class H2RowCacheSelfTest extends AbstractIndexingCommonTest {
5161
/** Random generator. */
5262
private static final Random RND = new Random(System.currentTimeMillis());
5363

64+
/** */
65+
@Parameterized.Parameters(name = "persistenceEnabled={0}")
66+
public static Collection<Object[]> testParams() {
67+
return Arrays.asList(new Object[]{true}, new Object[]{false});
68+
}
69+
70+
/** */
71+
@Parameterized.Parameter
72+
public boolean persistenceEnabled;
73+
5474
/** {@inheritDoc} */
5575
@Override protected void beforeTest() throws Exception {
56-
startGrid();
76+
cleanPersistenceDir();
77+
78+
Ignite ignite = startGrid();
79+
80+
if (persistenceEnabled)
81+
ignite.cluster().state(ClusterState.ACTIVE);
5782
}
5883

5984
/** {@inheritDoc} */
6085
@Override protected void afterTest() throws Exception {
6186
stopAllGrids();
6287

88+
cleanPersistenceDir();
89+
6390
super.afterTest();
6491
}
6592

93+
/** {@inheritDoc} */
94+
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
95+
return super.getConfiguration(igniteInstanceName)
96+
.setDataStorageConfiguration(
97+
new DataStorageConfiguration().setDefaultDataRegionConfiguration(
98+
new DataRegionConfiguration().setPersistenceEnabled(persistenceEnabled)
99+
)
100+
);
101+
}
102+
66103
/**
67104
* @param name Cache name.
68105
* @param enableOnheapCache Enable on-heal SQL rows cache.

0 commit comments

Comments
 (0)