From 872a69829281eaa4ff38f926ad70c051a51700cb Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Wed, 24 Apr 2024 23:21:53 +0300 Subject: [PATCH 01/24] IGNITE-21835 Cleanup CacheDataRowAdapter#RowData --- .../cache/IgniteCacheOffheapManagerImpl.java | 2 +- .../persistence/CacheDataRowAdapter.java | 42 +------------------ .../processors/cache/tree/DataRow.java | 10 +---- 3 files changed, 4 insertions(+), 50 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java index edfe8d0bc7503..f1b0f215335b9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java @@ -913,7 +913,7 @@ private long allocateForTree() throws IgniteCheckedException { @Override protected boolean onHasNext() throws IgniteCheckedException { if (cur == null) - cur = data.cursor(CacheDataRowAdapter.RowData.FULL_WITH_HINTS); + cur = data.cursor(); if (next != null) return true; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java index 735d2ac630f0f..1f761da547987 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java @@ -50,7 +50,6 @@ import static org.apache.ignite.internal.pagemem.PageIdUtils.itemId; import static org.apache.ignite.internal.pagemem.PageIdUtils.pageId; import static org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter.RowData.KEY_ONLY; -import static org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter.RowData.LINK_WITH_HEADER; import static org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO.T_DATA; import static org.apache.ignite.internal.util.GridUnsafe.wrapPointer; @@ -386,12 +385,6 @@ protected IncompleteObject readIncomplete( return null; } - - // Assume that row header is always located entirely on the very first page. - hdrLen = readHeader(sharedCtx, pageAddr, data.offset(), rowData); - - if (rowData == LINK_WITH_HEADER) - return null; } ByteBuffer buf = wrapPointer(pageAddr, pageSize); @@ -412,20 +405,6 @@ protected IncompleteObject readIncomplete( return incomplete; } - /** - * Reads row header (i.e. MVCC info) which should be located on the very first page od data. - * - * @param sharedCtx Shared context. - * @param addr Address. - * @param off Offset - * @param rowData Required row data. - * @return Number of bytes read. - */ - protected int readHeader(GridCacheSharedContext sharedCtx, long addr, int off, RowData rowData) { - // No-op. - return 0; - } - /** * @param sharedCtx Cache shared context. * @param coctx Cache object context. @@ -532,11 +511,6 @@ protected void readFullRow( ) throws IgniteCheckedException { int off = 0; - off += readHeader(sharedCtx, addr, off, rowData); - - if (rowData == LINK_WITH_HEADER) - return; - if (readCacheId) { cacheId = PageUtils.getInt(addr, off); @@ -549,7 +523,7 @@ protected void readFullRow( int len = PageUtils.getInt(addr, off); off += 4; - if (rowData != RowData.NO_KEY && rowData != RowData.NO_KEY_WITH_HINTS) { + if (rowData != RowData.NO_KEY) { byte type = PageUtils.getByte(addr, off); off++; @@ -935,19 +909,7 @@ public enum RowData { KEY_ONLY, /** */ - NO_KEY, - - /** */ - LINK_ONLY, - - /** */ - LINK_WITH_HEADER, - - /** Force instant hints actualization for rebalance (to avoid races with vacuum). */ - FULL_WITH_HINTS, - - /** Force instant hints actualization for update operation with history (to avoid races with vacuum). */ - NO_KEY_WITH_HINTS + NO_KEY } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java index f8d2ac05a4c6e..362a0d9e15aac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java @@ -51,8 +51,7 @@ protected DataRow(CacheGroupContext grp, int hash, long link, int part, RowData try { // We can not init data row lazily outside of entry lock because underlying buffer can be concurrently cleared. - if (rowData != RowData.LINK_ONLY) - initFromLink(grp, rowData, skipVer); + initFromLink(grp, rowData, skipVer); } catch (IgniteCheckedException e) { throw new IgniteException(e); @@ -84,13 +83,6 @@ public DataRow(KeyCacheObject key, CacheObject val, GridCacheVersion ver, int pa verReady = true; } - /** - * @param link Link. - */ - protected DataRow(long link) { - super(link); - } - /** * */ From d7c39b236db13671ebe6e911328c04e92a226a13 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Thu, 25 Apr 2024 22:01:45 +0300 Subject: [PATCH 02/24] IGNITE-21835 WIP: remove MvccUtils. --- .../internal/sql/SqlCommandProcessor.java | 21 ------------------- .../processors/query/h2/CommandProcessor.java | 2 -- 2 files changed, 23 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlCommandProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlCommandProcessor.java index 698d2a6261329..7eb95e51033f5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlCommandProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlCommandProcessor.java @@ -32,8 +32,6 @@ import org.apache.ignite.internal.ServiceMXBeanImpl; import org.apache.ignite.internal.TransactionsMXBeanImpl; import org.apache.ignite.internal.processors.cache.GridCacheContextInfo; -import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal; -import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils; import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode; import org.apache.ignite.internal.processors.query.GridQueryProperty; import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor; @@ -309,8 +307,6 @@ private void runCommandNativeDdl(SqlCommand cmd) { try { isDdlOnSchemaSupported(cmd.schemaName()); - finishActiveTxIfNecessary(); - if (cmd instanceof SqlCreateIndexCommand) { SqlCreateIndexCommand cmd0 = (SqlCreateIndexCommand)cmd; @@ -430,21 +426,4 @@ else if (cmd instanceof SqlDropUserCommand) { throw new IgniteSQLException(e.getMessage(), e); } } - - /** - * Commits active transaction if exists. - * - * @throws IgniteCheckedException If failed. - */ - protected void finishActiveTxIfNecessary() throws IgniteCheckedException { - try (GridNearTxLocal tx = MvccUtils.tx(ctx)) { - if (tx == null) - return; - - if (!tx.isRollbackOnly()) - tx.commit(); - else - tx.rollback(); - } - } } diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/CommandProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/CommandProcessor.java index 263e10207eb74..d56a96fb02dfc 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/CommandProcessor.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/CommandProcessor.java @@ -240,8 +240,6 @@ private void runCommandH2(String sql, GridSqlStatement cmdH2) { IgniteInternalFuture fut = null; try { - finishActiveTxIfNecessary(); - if (cmdH2 instanceof GridSqlCreateTable) { GridSqlCreateTable cmd = (GridSqlCreateTable)cmdH2; From 6155aa40d9be7f2d2a5dcbe3ce9f77d6780b348e Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Tue, 7 May 2024 19:43:56 +0300 Subject: [PATCH 03/24] IGNITE-21835 Remove MvccUtils. --- .../cache/DdlTransactionCalciteSelfTest.java | 30 ++ .../testsuites/IntegrationTestSuite.java | 2 + .../processors/cache/mvcc/MvccUtils.java | 64 ---- .../cache/DdlTransactionSelfTest.java | 209 ++++++++++++ .../cache/DdlTransactionIndexingSelfTest.java | 32 ++ .../cache/DdlTransactionSelfTest.java | 323 ------------------ .../IgniteBinaryCacheQueryTestSuite.java | 4 +- 7 files changed, 275 insertions(+), 389 deletions(-) create mode 100644 modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionCalciteSelfTest.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java create mode 100644 modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionIndexingSelfTest.java delete mode 100644 modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionCalciteSelfTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionCalciteSelfTest.java new file mode 100644 index 0000000000000..e0011a1d83f31 --- /dev/null +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionCalciteSelfTest.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; +import org.apache.ignite.configuration.QueryEngineConfiguration; + +/** */ +public class DdlTransactionCalciteSelfTest extends DdlTransactionSelfTest { + /** {@inheritDoc} */ + @Override protected QueryEngineConfiguration getQueryEngineConfiguration() { + return new CalciteQueryEngineConfiguration() + .setDefault(true); + } +} diff --git a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java index 5ab4bd46e01b2..fa1ca919b9873 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java +++ b/modules/calcite/src/test/java/org/apache/ignite/testsuites/IntegrationTestSuite.java @@ -17,6 +17,7 @@ package org.apache.ignite.testsuites; +import org.apache.ignite.internal.processors.cache.DdlTransactionCalciteSelfTest; import org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessorTest; import org.apache.ignite.internal.processors.query.calcite.CancelTest; import org.apache.ignite.internal.processors.query.calcite.DateTimeTest; @@ -133,6 +134,7 @@ JoinRehashIntegrationTest.class, IndexWithSameNameCalciteTest.class, AuthorizationIntegrationTest.class, + DdlTransactionCalciteSelfTest.class, }) public class IntegrationTestSuite { } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java deleted file mode 100644 index 4c7f3954a65a9..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccUtils.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.mvcc; - -import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal; -import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; -import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager; -import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; -import org.apache.ignite.transactions.TransactionUnsupportedConcurrencyException; -import org.jetbrains.annotations.Nullable; - -/** - * Utils for MVCC. - */ -public class MvccUtils { - /** - * @param ctx Grid kernal context. - * @return Currently started user transaction, or {@code null} if none started. - * @throws TransactionUnsupportedConcurrencyException If transaction mode is not supported when MVCC is enabled. - */ - @Nullable public static GridNearTxLocal tx(GridKernalContext ctx) { - return tx(ctx, null); - } - - /** - * @param ctx Grid kernal context. - * @param txId Transaction ID. - * @return Currently started user transaction, or {@code null} if none started. - * @throws TransactionUnsupportedConcurrencyException If transaction mode is not supported when MVCC is enabled. - */ - @Nullable public static GridNearTxLocal tx(GridKernalContext ctx, @Nullable GridCacheVersion txId) { - IgniteTxManager tm = ctx.cache().context().tm(); - - IgniteInternalTx tx0 = txId == null ? tm.tx() : tm.tx(txId); - - GridNearTxLocal tx = tx0 != null && tx0.user() ? (GridNearTxLocal)tx0 : null; - - if (tx != null) { - if (!tx.pessimistic()) { - tx.setRollbackOnly(); - - throw new TransactionUnsupportedConcurrencyException("Only pessimistic transactions are supported when MVCC is enabled."); - } - } - - return tx; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java new file mode 100644 index 0000000000000..b779af8ef131e --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java @@ -0,0 +1,209 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import java.util.List; +import javax.cache.CacheException; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.query.FieldsQueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.QueryEngineConfiguration; +import org.apache.ignite.configuration.SqlConfiguration; +import org.apache.ignite.configuration.TransactionConfiguration; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.X; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.apache.ignite.transactions.Transaction; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; +import org.apache.ignite.transactions.TransactionState; +import org.junit.Test; + +import static org.apache.ignite.testframework.GridTestUtils.assertThrows; + +/** + * + */ +public abstract class DdlTransactionSelfTest extends GridCommonAbstractTest { + /** Create table request. */ + public static final String CREATE_TABLE = "CREATE TABLE " + + "person (id int, name varchar, age int, company varchar, city varchar, primary key (id, name, city))" + + "WITH " + + "\"cache_name=test_cache,template=PARTITIONED,atomicity=TRANSACTIONAL,affinity_key=city\""; + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setTransactionConfiguration(new TransactionConfiguration() + .setDefaultTxIsolation(TransactionIsolation.REPEATABLE_READ) + .setDefaultTxConcurrency(TransactionConcurrency.PESSIMISTIC) + .setDefaultTxTimeout(5000)); + + cfg.setCacheConfiguration(getCacheConfiguration()); + + cfg.setSqlConfiguration(new SqlConfiguration() + .setQueryEnginesConfiguration(getQueryEngineConfiguration())); + + return cfg; + } + + /** */ + protected abstract QueryEngineConfiguration getQueryEngineConfiguration(); + + /** + * @return Cache configuration. + */ + private CacheConfiguration getCacheConfiguration() { + return defaultCacheConfiguration() + .setBackups(1) + .setNearConfiguration(null); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testDdlRequestFailsInsideTxMultinodeClient() throws Exception { + startGridsMultiThreaded(4, false); + + Ignite node = startClientGrid(4); + + awaitPartitionMapExchange(); + + doTestDdlFailsInsideTx(node); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testDdlRequestFailsInsideTxMultinode() throws Exception { + Ignite node = startGridsMultiThreaded(4); + + doTestDdlFailsInsideTx(node); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testDdlRequestFailsInsideTx() throws Exception { + Ignite node = startGrid(); + + doTestDdlFailsInsideTx(node); + } + + /** */ + private void doTestDdlFailsInsideTx(Ignite node) { + IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); + + try (Transaction tx = node.transactions().txStart()) { + cache.putAll(F.asMap(1, 1, 2, 2, 3, 3)); + + String errMsg = "Cannot start/stop cache within lock or transaction [cacheNames=test_cache, " + + "operation=dynamicStartCache]"; + + Throwable cacheEx = assertThrows( + log, + () -> cache.query(new SqlFieldsQuery(CREATE_TABLE) + .setSchema("PUBLIC")) + .getAll(), + CacheException.class, + errMsg); + + assertTrue(X.hasCause(cacheEx, errMsg, IgniteException.class)); + + assertTrue(tx.state() != TransactionState.COMMITTED); + } + } + + /** + * @throws Exception If failed. + */ + @Test + public void testDdlRequestWithoutTxMultinodeClient() throws Exception { + startGridsMultiThreaded(4, false); + + Ignite node = startClientGrid(4); + + awaitPartitionMapExchange(); + + doTestDdlWithoutTx(node); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testDdlRequestWithoutTxMultinode() throws Exception { + Ignite node = startGridsMultiThreaded(4); + + doTestDdlWithoutTx(node); + } + + /** + * @throws Exception If failed. + */ + @Test + public void testDdlRequestWithoutTx() throws Exception { + Ignite node = startGrid(); + + doTestDdlWithoutTx(node); + } + + /** */ + private void doTestDdlWithoutTx(Ignite node) { + IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); + + cache.putAll(F.asMap(1, 1, 2, 2, 3, 3)); + + try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery(CREATE_TABLE).setSchema("PUBLIC"))) { + assertNotNull(cur); + + List> rows = cur.getAll(); + + assertEquals(1, rows.size()); + + assertEquals(0L, rows.get(0).get(0)); + } + + try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery("SELECT * FROM person") + .setSchema("PUBLIC")) + ) { + assertNotNull(cur); + + List> rows = cur.getAll(); + + assertEquals(0, rows.size()); + } + + assertEquals(1, cache.get(1)); + assertEquals(2, cache.get(2)); + assertEquals(3, cache.get(3)); + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionIndexingSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionIndexingSelfTest.java new file mode 100644 index 0000000000000..adadfd02c8564 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionIndexingSelfTest.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.configuration.QueryEngineConfiguration; +import org.apache.ignite.indexing.IndexingQueryEngineConfiguration; + +/** + * + */ +public class DdlTransactionIndexingSelfTest extends DdlTransactionSelfTest { + /** {@inheritDoc} */ + @Override protected QueryEngineConfiguration getQueryEngineConfiguration() { + return new IndexingQueryEngineConfiguration() + .setDefault(true); + } +} diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java deleted file mode 100644 index 50c650b01128e..0000000000000 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache; - -import java.util.List; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.query.FieldsQueryCursor; -import org.apache.ignite.cache.query.SqlFieldsQuery; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.TransactionConfiguration; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.transactions.Transaction; -import org.apache.ignite.transactions.TransactionConcurrency; -import org.apache.ignite.transactions.TransactionIsolation; -import org.apache.ignite.transactions.TransactionState; -import org.junit.Test; - -/** - * - */ -public class DdlTransactionSelfTest extends GridCommonAbstractTest { - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - stopAllGrids(); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - - cfg.setTransactionConfiguration(new TransactionConfiguration() - .setDefaultTxIsolation(TransactionIsolation.REPEATABLE_READ) - .setDefaultTxConcurrency(TransactionConcurrency.PESSIMISTIC) - .setDefaultTxTimeout(5000)); - - cfg.setCacheConfiguration(getCacheConfiguration()); - - return cfg; - } - - /** - * @return Cache configuration. - */ - private CacheConfiguration getCacheConfiguration() { - CacheConfiguration ccfg = defaultCacheConfiguration(); - - ccfg.setNearConfiguration(null); - - return ccfg; - } - - /** - * @throws Exception If failed. - */ - @Test - public void testTxIsCommittedOnDdlRequestMultinodeClient() throws Exception { - startGridsMultiThreaded(4, false); - - Ignite node = startClientGrid(4); - - awaitPartitionMapExchange(); - - IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); - - try (Transaction tx = node.transactions().txStart()) { - cache.putAll(F.asMap(1, 1, 2, 2, 3, 3)); - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery( - "CREATE TABLE " + - " person (id int, name varchar, age int, company varchar, city varchar, primary key (id, name, city))" + - "WITH " + - " \"template=PARTITIONED,atomicity=TRANSACTIONAL,affinity_key=city\"").setSchema("PUBLIC"))) { - - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(1, rows.size()); - - assertEquals(0L, rows.get(0).get(0)); - } - - assertTrue(tx.state() == TransactionState.COMMITTED); - } - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery("SELECT * FROM person").setSchema("PUBLIC"))) { - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(0, rows.size()); - } - - assertEquals(1, cache.get(1)); - assertEquals(2, cache.get(2)); - assertEquals(3, cache.get(3)); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testTxIsCommittedOnDdlRequestMultinode() throws Exception { - Ignite node = startGridsMultiThreaded(4); - - IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); - - try (Transaction tx = node.transactions().txStart()) { - cache.putAll(F.asMap(1, 1, 2, 2, 3, 3)); - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery( - "CREATE TABLE " + - " person (id int, name varchar, age int, company varchar, city varchar, primary key (id, name, city))" + - "WITH " + - " \"template=PARTITIONED,atomicity=TRANSACTIONAL,affinity_key=city\"").setSchema("PUBLIC"))) { - - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(1, rows.size()); - - assertEquals(0L, rows.get(0).get(0)); - } - - assertTrue(tx.state() == TransactionState.COMMITTED); - } - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery("SELECT * FROM person").setSchema("PUBLIC"))) { - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(0, rows.size()); - } - - assertEquals(1, cache.get(1)); - assertEquals(2, cache.get(2)); - assertEquals(3, cache.get(3)); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testTxIsCommittedOnDdlRequest() throws Exception { - Ignite node = startGrid(); - - IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); - - try (Transaction tx = node.transactions().txStart()) { - cache.putAll(F.asMap(1, 1, 2, 2, 3, 3)); - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery( - "CREATE TABLE " + - " person (id int, name varchar, age int, company varchar, city varchar, primary key (id, name, city))" + - "WITH " + - " \"template=PARTITIONED,atomicity=TRANSACTIONAL,affinity_key=city\"").setSchema("PUBLIC"))) { - - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(1, rows.size()); - - assertEquals(0L, rows.get(0).get(0)); - } - - assertTrue(tx.state() == TransactionState.COMMITTED); - } - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery("SELECT * FROM person").setSchema("PUBLIC"))) { - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(0, rows.size()); - } - - assertEquals(1, cache.get(1)); - assertEquals(2, cache.get(2)); - assertEquals(3, cache.get(3)); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testDdlRequestWithoutTxMultinodeClient() throws Exception { - startGridsMultiThreaded(4, false); - - Ignite node = startClientGrid(4); - - awaitPartitionMapExchange(); - - IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); - - cache.putAll(F.asMap(1, 1, 2, 2, 3, 3)); - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery( - "CREATE TABLE " + - " person (id int, name varchar, age int, company varchar, city varchar, primary key (id, name, city))" + - "WITH " + - " \"template=PARTITIONED,atomicity=TRANSACTIONAL,affinity_key=city\"").setSchema("PUBLIC"))) { - - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(1, rows.size()); - - assertEquals(0L, rows.get(0).get(0)); - } - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery("SELECT * FROM person").setSchema("PUBLIC"))) { - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(0, rows.size()); - } - - assertEquals(1, cache.get(1)); - assertEquals(2, cache.get(2)); - assertEquals(3, cache.get(3)); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testDdlRequestWithoutTxMultinode() throws Exception { - Ignite node = startGridsMultiThreaded(4); - - IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); - - cache.putAll(F.asMap(1, 1, 2, 2, 3, 3)); - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery( - "CREATE TABLE " + - " person (id int, name varchar, age int, company varchar, city varchar, primary key (id, name, city))" + - "WITH " + - " \"template=PARTITIONED,atomicity=TRANSACTIONAL,affinity_key=city\"").setSchema("PUBLIC"))) { - - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(1, rows.size()); - - assertEquals(0L, rows.get(0).get(0)); - } - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery("SELECT * FROM person").setSchema("PUBLIC"))) { - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(0, rows.size()); - } - - assertEquals(1, cache.get(1)); - assertEquals(2, cache.get(2)); - assertEquals(3, cache.get(3)); - } - - /** - * @throws Exception If failed. - */ - @Test - public void testDdlRequestWithoutTx() throws Exception { - Ignite node = startGrid(); - - IgniteCache cache = node.cache(DEFAULT_CACHE_NAME); - - cache.putAll(F.asMap(1, 1, 2, 2, 3, 3)); - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery( - "CREATE TABLE " + - " person (id int, name varchar, age int, company varchar, city varchar, primary key (id, name, city))" + - "WITH " + - " \"template=PARTITIONED,atomicity=TRANSACTIONAL,affinity_key=city\"").setSchema("PUBLIC"))) { - - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(1, rows.size()); - - assertEquals(0L, rows.get(0).get(0)); - } - - try (FieldsQueryCursor> cur = cache.query(new SqlFieldsQuery("SELECT * FROM person").setSchema("PUBLIC"))) { - assertNotNull(cur); - - List> rows = cur.getAll(); - - assertEquals(0, rows.size()); - } - - assertEquals(1, cache.get(1)); - assertEquals(2, cache.get(2)); - assertEquals(3, cache.get(3)); - } -} diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java index d1e124e6038b2..0c84f0ed9415a 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java @@ -22,7 +22,7 @@ import org.apache.ignite.internal.processors.cache.AffinityKeyNameAndValueFieldNameConflictTest; import org.apache.ignite.internal.processors.cache.CacheOffheapBatchIndexingMultiTypeTest; import org.apache.ignite.internal.processors.cache.CacheQueryBuildValueTest; -import org.apache.ignite.internal.processors.cache.DdlTransactionSelfTest; +import org.apache.ignite.internal.processors.cache.DdlTransactionIndexingSelfTest; import org.apache.ignite.internal.processors.cache.GridCacheCrossCacheQuerySelfTest; import org.apache.ignite.internal.processors.cache.GridCacheLazyQueryPartitionsReleaseTest; import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexDisabledSelfTest; @@ -339,7 +339,7 @@ H2DynamicIndexingComplexServerTransactionalPartitionedNoBackupsTest.class, H2DynamicIndexingComplexServerTransactionalReplicatedTest.class, - DdlTransactionSelfTest.class, + DdlTransactionIndexingSelfTest.class, }) public class IgniteBinaryCacheQueryTestSuite { From ca3c6ab0cafc2b6dc29aa0ecff5470aebf20fe59 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Wed, 8 May 2024 12:56:09 +0300 Subject: [PATCH 04/24] IGNITE-21835 Remove MVCC_TX_RECOVERY_PROTOCOL_V2 feature. --- .../main/java/org/apache/ignite/IgniteSystemProperties.java | 4 ++-- .../main/java/org/apache/ignite/internal/IgniteFeatures.java | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java index f13f3288a2d2c..d8b89ec87f1a6 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java @@ -1554,12 +1554,12 @@ public final class IgniteSystemProperties { /** * When set to {@code true}, Ignite will allow execute DML operation (MERGE|INSERT|UPDATE|DELETE) - * within transaction for non MVCC mode. + * within transaction. * * Default is {@code false}. */ @SystemProperty("When set to true, Ignite will allow executing DML operation " + - "(MERGE|INSERT|UPDATE|DELETE) within transactions for non MVCC mode") + "(MERGE|INSERT|UPDATE|DELETE) within transactions") public static final String IGNITE_ALLOW_DML_INSIDE_TRANSACTION = "IGNITE_ALLOW_DML_INSIDE_TRANSACTION"; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteFeatures.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteFeatures.java index b38c9392608de..fb377796dd01a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteFeatures.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteFeatures.java @@ -126,9 +126,6 @@ public enum IgniteFeatures { /** Force rebuild, list or request indexes rebuild status from control script. */ INDEXES_MANIPULATIONS_FROM_CONTROL_SCRIPT(42), - /** Optimization of recovery protocol for cluster which doesn't contain MVCC caches. */ - MVCC_TX_RECOVERY_PROTOCOL_V2(44), - /** Pk index keys are applied in correct order. */ SPECIFIED_SEQ_PK_KEYS(45), From e2b67480e2fdad4cb83b76c26b281350fc794fcf Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Wed, 8 May 2024 13:52:10 +0300 Subject: [PATCH 05/24] IGNITE-21835 Remove MarshalledDataEntry. --- .../pagemem/wal/record/LazyDataEntry.java | 18 ++++---- .../wal/record/MarshalledDataEntry.java | 45 ------------------- .../reader/StandaloneWalRecordsIterator.java | 6 +-- .../db/wal/reader/IgniteWalReaderTest.java | 4 +- 4 files changed, 14 insertions(+), 59 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MarshalledDataEntry.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java index 45bd54a7325ae..5819496c4caca 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java @@ -31,7 +31,7 @@ * Represents Data Entry ({@link #key}, {@link #val value}) pair update {@link #op operation}.
* This Data entry was not converted to key, value pair during record deserialization. */ -public class LazyDataEntry extends DataEntry implements MarshalledDataEntry { +public class LazyDataEntry extends DataEntry { /** */ private GridCacheSharedContext cctx; @@ -126,23 +126,23 @@ public LazyDataEntry( return val; } - /** {@inheritDoc} */ - @Override public byte getKeyType() { + /** @return Data Entry Key type code. See {@link CacheObject} for built-in value type codes */ + public byte getKeyType() { return keyType; } - /** {@inheritDoc} */ - @Override public byte[] getKeyBytes() { + /** @return Key value bytes. */ + public byte[] getKeyBytes() { return keyBytes; } - /** {@inheritDoc} */ - @Override public byte getValType() { + /** @return Data Entry Value type code. See {@link CacheObject} for built-in value type codes */ + public byte getValType() { return valType; } - /** {@inheritDoc} */ - @Override public byte[] getValBytes() { + /** @return Value value bytes. */ + public byte[] getValBytes() { return valBytes; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MarshalledDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MarshalledDataEntry.java deleted file mode 100644 index c977d527941e9..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MarshalledDataEntry.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.pagemem.wal.record; - -import org.apache.ignite.internal.processors.cache.CacheObject; - -/** - * Interface for Data Entry record that was not converted to key, value pair during record deserialization. - */ -public interface MarshalledDataEntry { - /** - * @return Data Entry Key type code. See {@link CacheObject} for built-in value type codes. - */ - byte getKeyType(); - - /** - * @return Key value bytes. - */ - byte[] getKeyBytes(); - - /** - * @return Data Entry Value type code. See {@link CacheObject} for built-in value type codes. - */ - byte getValType(); - - /** - * @return Value value bytes. - */ - byte[] getValBytes(); -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java index f4572547f6535..7246379dabe2b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java @@ -28,7 +28,7 @@ import org.apache.ignite.internal.pagemem.wal.record.DataEntry; import org.apache.ignite.internal.pagemem.wal.record.DataRecord; import org.apache.ignite.internal.pagemem.wal.record.FilteredRecord; -import org.apache.ignite.internal.pagemem.wal.record.MarshalledDataEntry; +import org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry; import org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry; import org.apache.ignite.internal.pagemem.wal.record.WALRecord; import org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType; @@ -431,8 +431,8 @@ private boolean checkBounds(long idx) { final CacheObject val; boolean keepBinary = this.keepBinary || !fakeCacheObjCtx.kernalContext().marshallerContext().initialized(); - if (dataEntry instanceof MarshalledDataEntry) { - final MarshalledDataEntry lazyDataEntry = (MarshalledDataEntry)dataEntry; + if (dataEntry instanceof LazyDataEntry) { + final LazyDataEntry lazyDataEntry = (LazyDataEntry)dataEntry; key = processor.toKeyCacheObject(fakeCacheObjCtx, lazyDataEntry.getKeyType(), diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java index 70ab8acf91e20..6d9fa97c9b7d2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java @@ -62,7 +62,7 @@ import org.apache.ignite.internal.pagemem.wal.WALIterator; import org.apache.ignite.internal.pagemem.wal.record.DataEntry; import org.apache.ignite.internal.pagemem.wal.record.DataRecord; -import org.apache.ignite.internal.pagemem.wal.record.MarshalledDataEntry; +import org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry; import org.apache.ignite.internal.pagemem.wal.record.TxRecord; import org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry; import org.apache.ignite.internal.pagemem.wal.record.UnwrappedDataEntry; @@ -1662,7 +1662,7 @@ private Map iterateAndCountDataRecord( unwrappedKeyObj = unwrapDataEntry.unwrappedKey(); unwrappedValObj = unwrapDataEntry.unwrappedValue(); } - else if (entry instanceof MarshalledDataEntry) { + else if (entry instanceof LazyDataEntry) { unwrappedKeyObj = null; unwrappedValObj = null; //can't check value From 783c7f56ea71da132eca88a3d8c3c8ad26027385 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Wed, 8 May 2024 14:21:08 +0300 Subject: [PATCH 06/24] IGNITE-21835 Remove UnwrappedDataEntry. --- .../internal/cdc/WalRecordsConsumer.java | 4 +- .../pagemem/wal/record/UnwrapDataEntry.java | 20 +++++++--- .../wal/record/UnwrappedDataEntry.java | 39 ------------------- .../db/wal/reader/IgniteWalReaderTest.java | 5 +-- 4 files changed, 19 insertions(+), 49 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrappedDataEntry.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cdc/WalRecordsConsumer.java b/modules/core/src/main/java/org/apache/ignite/internal/cdc/WalRecordsConsumer.java index 00c76babb7625..3b111d50a197e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/cdc/WalRecordsConsumer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/cdc/WalRecordsConsumer.java @@ -32,7 +32,7 @@ import org.apache.ignite.internal.pagemem.wal.record.DataEntry; import org.apache.ignite.internal.pagemem.wal.record.DataRecord; import org.apache.ignite.internal.pagemem.wal.record.TimeStampRecord; -import org.apache.ignite.internal.pagemem.wal.record.UnwrappedDataEntry; +import org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry; import org.apache.ignite.internal.pagemem.wal.record.WALRecord; import org.apache.ignite.internal.processors.cache.GridCacheOperation; import org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer; @@ -91,7 +91,7 @@ public class WalRecordsConsumer { /** Event transformer. */ static final IgniteClosure CDC_EVENT_TRANSFORMER = e -> { - UnwrappedDataEntry ue = (UnwrappedDataEntry)e; + UnwrapDataEntry ue = (UnwrapDataEntry)e; return new CdcEventImpl( ue.unwrappedKey(), diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java index cba9f37928628..e535e22f0b8d4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java @@ -29,7 +29,7 @@ /** * Data Entry for automatic unwrapping key and value from Data Entry */ -public class UnwrapDataEntry extends DataEntry implements UnwrappedDataEntry { +public class UnwrapDataEntry extends DataEntry { /** Cache object value context. Context is used for unwrapping objects. */ private final CacheObjectValueContext cacheObjValCtx; @@ -68,8 +68,13 @@ public UnwrapDataEntry( this.keepBinary = keepBinary; } - /** {@inheritDoc} */ - @Override public Object unwrappedKey() { + /** + * Unwraps key from cache key object into primitive boxed type or source class. If client classes were used in + * key, call of this method requires classes to be available in classpath. + * + * @return Key which was placed into cache. Or null if failed to convert. + */ + public Object unwrappedKey() { try { return unwrapKey(key, keepBinary, cacheObjValCtx); } @@ -81,8 +86,13 @@ public UnwrapDataEntry( } } - /** {@inheritDoc} */ - @Override public Object unwrappedValue() { + /** + * Unwraps value from cache value object into primitive boxed type or source class. If client classes were + * used in key, call of this method requires classes to be available in classpath. + * + * @return Value which was placed into cache. Or null for delete operation or for failure. + */ + public Object unwrappedValue() { try { return unwrapValue(val, keepBinary, cacheObjValCtx); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrappedDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrappedDataEntry.java deleted file mode 100644 index b3a20b9ca0525..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrappedDataEntry.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.pagemem.wal.record; - -/** - * Interface for Data Entry for automatic unwrapping key and value from Data Entry - */ -public interface UnwrappedDataEntry { - /** - * Unwraps key value from cache key object into primitive boxed type or source class. If client classes were used in - * key, call of this method requires classes to be available in classpath. - * - * @return Key which was placed into cache. Or null if failed to convert. - */ - Object unwrappedKey(); - - /** - * Unwraps value value from cache value object into primitive boxed type or source class. If client classes were - * used in key, call of this method requires classes to be available in classpath. - * - * @return Value which was placed into cache. Or null for delete operation or for failure. - */ - Object unwrappedValue(); -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java index 6d9fa97c9b7d2..29940f84b484a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java @@ -65,7 +65,6 @@ import org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry; import org.apache.ignite.internal.pagemem.wal.record.TxRecord; import org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry; -import org.apache.ignite.internal.pagemem.wal.record.UnwrappedDataEntry; import org.apache.ignite.internal.pagemem.wal.record.WALRecord; import org.apache.ignite.internal.processors.cache.CacheObject; import org.apache.ignite.internal.processors.cache.GridCacheOperation; @@ -1657,8 +1656,8 @@ private Map iterateAndCountDataRecord( Object unwrappedKeyObj; Object unwrappedValObj; - if (entry instanceof UnwrappedDataEntry) { - UnwrappedDataEntry unwrapDataEntry = (UnwrappedDataEntry)entry; + if (entry instanceof UnwrapDataEntry) { + UnwrapDataEntry unwrapDataEntry = (UnwrapDataEntry)entry; unwrappedKeyObj = unwrapDataEntry.unwrappedKey(); unwrappedValObj = unwrapDataEntry.unwrappedValue(); } From e80c5d74ec6bfae7723bc5f6a41b53011723a535 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Wed, 8 May 2024 18:11:09 +0300 Subject: [PATCH 07/24] IGNITE-21835 WIP: CacheContinuousQueryManager, CacheGroupContext, GridCacheContext. --- .../processors/cache/CacheGroupContext.java | 18 ------------------ .../processors/cache/GridCacheContext.java | 10 ---------- .../CacheContinuousQueryManager.java | 10 ---------- 3 files changed, 38 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java index 1f4f0da29f001..6bafa748172ee 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java @@ -1028,24 +1028,6 @@ public void onPartitionCounterUpdate(int cacheId, } } - /** - * @return {@code True} if there is at least one cache with registered CQ exists in this group. - */ - public boolean hasContinuousQueryCaches() { - List> contQryCaches; - - listenerLock.readLock().lock(); - - try { - contQryCaches = this.contQryCaches; - - return !F.isEmpty(contQryCaches); - } - finally { - listenerLock.readLock().unlock(); - } - } - /** * @throws IgniteCheckedException If failed. */ 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 2c15eee871263..fbf11bf85a185 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 @@ -83,7 +83,6 @@ import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager; import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager; import org.apache.ignite.internal.processors.cache.store.CacheStoreManager; -import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager; @@ -2288,15 +2287,6 @@ public void statisticsEnabled(boolean statisticsEnabled) { near().dht().context().statisticsEnabled = statisticsEnabled; } - /** - * @param tx Transaction. - * @return {@code True} if it is need to notify continuous query listeners. - */ - public boolean hasContinuousQueryListeners(@Nullable IgniteInternalTx tx) { - return grp.sharedGroup() ? grp.hasContinuousQueryCaches() : - contQryMgr.notifyContinuousQueries(tx) && !F.isEmpty(contQryMgr.updateListeners(false, false)); - } - /** * Apply changes from {@link SchemaAddQueryEntityOperation}. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java index 085eae0b42b99..a3c00ef848492 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java @@ -66,7 +66,6 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicAbstractUpdateFuture; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; -import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx; import org.apache.ignite.internal.processors.continuous.GridContinuousHandler; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; import org.apache.ignite.internal.util.GridLongList; @@ -209,15 +208,6 @@ protected GridTimeoutProcessor.CancelableTask getCancelableTask() { } } - /** - * @param tx Transaction. - * @return {@code True} if should notify continuous query manager. - */ - public boolean notifyContinuousQueries(@Nullable IgniteInternalTx tx) { - return cctx.isReplicated() || - (!cctx.isNear() && !(tx != null && tx.onePhaseCommit() && !tx.local())); - } - /** * @param lsnrs Listeners to notify. * @param key Entry key. From 378aa8a953ad76b52254c3f9ad1812cc435fbee7 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Wed, 8 May 2024 19:14:27 +0300 Subject: [PATCH 08/24] IGNITE-21835 WIP: CacheInvokeEntry, GridDhtColocatedCache, GridCacheAdapter. --- .../processors/cache/CacheInvokeEntry.java | 11 +---------- .../processors/cache/GridCacheAdapter.java | 15 +++++---------- .../dht/colocated/GridDhtColocatedCache.java | 9 +++------ 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java index cb79a55879244..e7dbbad0916f1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java @@ -116,15 +116,6 @@ public CacheInvokeEntry(KeyCacheObject keyObj, op = hadVal ? Operation.UPDATE : Operation.CREATE; } - /** - * Entry processor operation. - * - * @return Operation. - */ - public Operation op() { - return op; - } - /** * @return Return origin value, before modification. */ @@ -167,7 +158,7 @@ public GridCacheEntryEx entry() { /** * */ - public static enum Operation { + private static enum Operation { /** */ NONE, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index ba441890df4cd..70032fcbfff94 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -1783,11 +1783,6 @@ protected abstract IgniteInternalFuture> getAllAsync( final boolean needVer ); - /** */ - protected GridNearTxLocal checkCurrentTx() { - return ctx.tm().threadLocalTx(ctx); - } - /** {@inheritDoc} */ @Override public final V getAndPut(K key, V val) throws IgniteCheckedException { return getAndPut(key, val, null); @@ -3603,7 +3598,7 @@ public FutureHolder lastAsyncFuture() { @Nullable private T syncOp(SyncOp op) throws IgniteCheckedException { checkJta(); - GridNearTxLocal tx = checkCurrentTx(); + GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx); if (tx == null || tx.implicit()) { lastAsyncFuture().await(); @@ -3723,7 +3718,7 @@ private IgniteInternalFuture asyncOp(final AsyncOp op) { if (log.isDebugEnabled()) log.debug("Performing async op: " + op); - GridNearTxLocal tx = checkCurrentTx(); + GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx); CacheOperationContext opCtx = ctx.operationContextPerCall(); @@ -4241,7 +4236,7 @@ private IgniteInternalFuture getWithRepairAsync( IgniteInternalFuture orig, Function> repair, Supplier> retry) { - final GridNearTxLocal tx = checkCurrentTx(); + final GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx); final CacheOperationContext opCtx = ctx.operationContextPerCall(); GridFutureAdapter fut = new GridFutureAdapter<>(); @@ -4320,7 +4315,7 @@ private IgniteInternalFuture repairTxAsync( boolean skipVals) { assert ctx.transactional(); - final GridNearTxLocal orig = checkCurrentTx(); + final GridNearTxLocal orig = ctx.tm().threadLocalTx(ctx); assert orig == null || orig.optimistic() || orig.readCommitted() || /*contains*/ skipVals : "Pessimistic non-read-committed 'get' should be fixed inside its own tx, the only exception is 'contains' " + @@ -4336,7 +4331,7 @@ private IgniteInternalFuture repairTxAsync( try (Transaction tx = ctx.grid().transactions().txStart(PESSIMISTIC, SERIALIZABLE)) { get((K)key, null, !ctx.keepBinary(), false); // Repair. - final GridNearTxLocal tx0 = checkCurrentTx(); + final GridNearTxLocal tx0 = ctx.tm().threadLocalTx(ctx); final IgniteTxKey txKey = ctx.txKey(ctx.toCacheKeyObject(key)); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java index db5a00126179c..6d548ab56d487 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java @@ -189,14 +189,13 @@ public GridDistributedCacheEntry entryExx( final boolean needVer) { ctx.checkSecurity(SecurityPermission.CACHE_READ); - GridNearTxLocal tx = checkCurrentTx(); + GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx); final CacheOperationContext opCtx = ctx.operationContextPerCall(); final boolean recovery = opCtx != null && opCtx.recovery(); final ReadRepairStrategy readRepairStrategy = opCtx != null ? opCtx.readRepairStrategy() : null; - // Get operation bypass Tx in Mvcc mode. if (tx != null && !tx.implicit() && !skipTx) { return asyncOp(tx, new AsyncOp() { @Override public IgniteInternalFuture op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) { @@ -293,7 +292,7 @@ public GridDistributedCacheEntry entryExx( warnIfUnordered(keys, BulkOperation.GET); - GridNearTxLocal tx = checkCurrentTx(); + GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx); final CacheOperationContext opCtx = ctx.operationContextPerCall(); @@ -340,7 +339,7 @@ public GridDistributedCacheEntry entryExx( tx).multi(); } - IgniteInternalFuture> fut = loadAsync( + return loadAsync( ctx.cacheKeysView(keys), opCtx == null || !opCtx.skipStore(), forcePrimary, @@ -354,8 +353,6 @@ public GridDistributedCacheEntry entryExx( false, null ); - - return fut; } /** From 9854ab29c74b9cd90b31e81d72f70a97c8e20922 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Tue, 14 May 2024 20:02:46 +0300 Subject: [PATCH 09/24] IGNITE-21835 WIP: TxCounters, PartitionUpdateCountersMessage, GridDhtPartitionSupplier. --- .../dht/PartitionUpdateCountersMessage.java | 13 --------- .../preloader/GridDhtPartitionSupplier.java | 27 +++++-------------- .../cache/transactions/TxCounters.java | 25 ----------------- 3 files changed, 6 insertions(+), 59 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/PartitionUpdateCountersMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/PartitionUpdateCountersMessage.java index b35cf6d372918..0c49966b92177 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/PartitionUpdateCountersMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/PartitionUpdateCountersMessage.java @@ -109,19 +109,6 @@ public long initialCounter(int idx) { return GridUnsafe.getLong(data, off); } - /** - * @param idx Item number. - * @param value Initial partition counter. - */ - public void initialCounter(int idx, long value) { - if (idx >= size) - throw new ArrayIndexOutOfBoundsException(); - - long off = GridUnsafe.BYTE_ARR_OFF + idx * ITEM_SIZE + 4; - - GridUnsafe.putLong(data, off, value); - } - /** * @param idx Item number. * @return Update counter delta. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java index 573a428ab6aa4..a213543178543 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java @@ -370,10 +370,13 @@ public void handleDemandMessage(int topicId, UUID nodeId, GridDhtPartitionDemand if (!remainingParts.contains(part)) continue; - GridCacheEntryInfo info = extractEntryInfo(row); + GridCacheEntryInfo info = new GridCacheEntryInfo(); - if (info == null) - continue; + info.key(row.key()); + info.cacheId(row.cacheId()); + info.value(row.value()); + info.version(row.version()); + info.expireTime(row.expireTime()); supplyMsg.addEntry0(part, iter.historical(part), info, grp.shared(), grp.cacheObjectContext()); @@ -519,24 +522,6 @@ else if (iter.isPartitionMissing(p)) { } } - /** - * Extracts entry info from row. - * - * @param row Cache data row. - * @return Entry info. - */ - private GridCacheEntryInfo extractEntryInfo(CacheDataRow row) { - GridCacheEntryInfo info = new GridCacheEntryInfo(); - - info.key(row.key()); - info.cacheId(row.cacheId()); - info.value(row.value()); - info.version(row.version()); - info.expireTime(row.expireTime()); - - return info; - } - /** * Sends supply message to demand node. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxCounters.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxCounters.java index cd13883e51bb1..2b7bb021727c3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxCounters.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxCounters.java @@ -39,21 +39,6 @@ public class TxCounters { /** Final update counters for cache partitions in the end of transaction */ private volatile Map updCntrs; - /** - * Accumulates size change for cache partition. - * - * @param cacheId Cache id. - * @param part Partition id. - * @param delta Size delta. - */ - public void accumulateSizeDelta(int cacheId, int part, long delta) { - AtomicLong accDelta = accumulator(sizeDeltas, cacheId, part); - - // here AtomicLong is used more as a container, - // every instance is assumed to be accessed in thread-confined manner - accDelta.set(accDelta.get() + delta); - } - /** * @return Map of size changes for cache partitions made by transaction. */ @@ -93,16 +78,6 @@ public void incrementUpdateCounter(int cacheId, int part) { accumulator(updCntrsAcc, cacheId, part).incrementAndGet(); } - /** - * @param cacheId Cache id. - * @param part Partition number. - */ - public void decrementUpdateCounter(int cacheId, int part) { - long acc = accumulator(updCntrsAcc, cacheId, part).decrementAndGet(); - - assert acc >= 0; - } - /** * @param accMap Map to obtain accumulator from. * @param cacheId Cache id. From ca05cb0bdb537007a476fe46ad18578dcf28be20 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Wed, 15 May 2024 14:46:56 +0300 Subject: [PATCH 10/24] IGNITE-21835 Remove queryUpdate flag. --- .../distributed/GridDistributedTxMapping.java | 49 ------------------- .../GridDistributedTxPrepareRequest.java | 22 --------- .../dht/GridDhtTxFinishFuture.java | 2 +- .../dht/GridDhtTxPrepareFuture.java | 10 ++-- .../GridNearPessimisticTxPrepareFuture.java | 2 - .../near/GridNearTxFinishFuture.java | 4 +- .../near/GridNearTxPrepareFutureAdapter.java | 2 +- .../cache/transactions/IgniteTxHandler.java | 4 +- 8 files changed, 10 insertions(+), 85 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxMapping.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxMapping.java index 44fc03655b388..a5f780743ac60 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxMapping.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxMapping.java @@ -18,13 +18,8 @@ package org.apache.ignite.internal.processors.cache.distributed; import java.util.Collection; -import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashSet; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry; import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey; @@ -40,17 +35,10 @@ * Transaction node mapping. */ public class GridDistributedTxMapping { - /** */ - private static final AtomicReferenceFieldUpdater BACKUPS_FIELD_UPDATER - = AtomicReferenceFieldUpdater.newUpdater(GridDistributedTxMapping.class, Set.class, "backups"); - /** Mapped node. */ @GridToStringExclude private final ClusterNode primary; - /** Mapped backup nodes. */ - private volatile Set backups; - /** Entries. */ @GridToStringInclude private final Collection entries; @@ -58,9 +46,6 @@ public class GridDistributedTxMapping { /** Explicit lock flag. */ private boolean explicitLock; - /** Query update flag. */ - private boolean queryUpdate; - /** DHT version. */ private GridCacheVersion dhtVer; @@ -147,20 +132,6 @@ public Collection entries() { return F.view(entries, CU.FILTER_NEAR_CACHE_ENTRY); } - /** - * @return {@code True} if mapping was created for a query update. - */ - public boolean queryUpdate() { - return queryUpdate; - } - - /** - * Sets query update flag to {@code true}. - */ - public void markQueryUpdate() { - queryUpdate = true; - } - /** * @return {@code True} if lock is explicit. */ @@ -294,26 +265,6 @@ public boolean empty() { return entries.isEmpty(); } - /** - * @param newBackups Backups to be added to this mapping. - */ - public void addBackups(Collection newBackups) { - if (newBackups == null) - return; - - if (backups == null) - BACKUPS_FIELD_UPDATER.compareAndSet(this, null, Collections.newSetFromMap(new ConcurrentHashMap<>())); - - backups.addAll(newBackups); - } - - /** - * @return Mapped backup nodes. - */ - public Set backups() { - return backups != null ? backups : Collections.emptySet(); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDistributedTxMapping.class, this, "node", primary.id()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 96eeee20b4b71..2d6da9c33d9a7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -78,9 +78,6 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage /** */ public static final int STORE_WRITE_THROUGH_FLAG_MASK = 0x20; - /** */ - public static final int QUERY_UPDATE_FLAG_MASK = 0x40; - /** Collection to message converter. */ private static final C1, UUIDCollectionMessage> COL_TO_MSG = new C1, UUIDCollectionMessage>() { @Override public UUIDCollectionMessage apply(Collection uuids) { @@ -255,25 +252,6 @@ public void storeWriteThrough(boolean storeWriteThrough) { flags &= ~STORE_WRITE_THROUGH_FLAG_MASK; } - /** - * - * @return Flag indicating whether it is a query update. - */ - public boolean queryUpdate() { - return (flags & QUERY_UPDATE_FLAG_MASK) != 0; - } - - /** - * - * @param queryUpdate Query update value. - */ - public void queryUpdate(boolean queryUpdate) { - if (queryUpdate) - flags = (byte)(flags | QUERY_UPDATE_FLAG_MASK); - else - flags &= ~QUERY_UPDATE_FLAG_MASK; - } - /** * @return IO policy. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java index 143c3aa04dc1a..72155efe99b2d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java @@ -445,7 +445,7 @@ private boolean finish(boolean commit, GridDistributedTxMapping nearMapping = nearMap.get(n.id()); - if (!dhtMapping.queryUpdate() && dhtMapping.empty() && nearMapping != null && nearMapping.empty()) + if (dhtMapping.empty() && nearMapping != null && nearMapping.empty()) // Nothing to send. continue; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java index 0840711eeaadb..814a8c6ea9471 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java @@ -1076,7 +1076,7 @@ public void prepare(GridNearTxPrepareRequest req) { assert req != null; try (MTC.TraceSurroundings ignored = MTC.supportContinual(span = cctx.kernalContext().tracing().create(TX_DHT_PREPARE, MTC.span()))) { - if (tx.empty() && !req.queryUpdate()) { + if (tx.empty()) { tx.setRollbackOnly(); onDone((GridNearTxPrepareResponse)null); @@ -1394,7 +1394,7 @@ private void sendPrepareRequests() { // Create mini futures. for (GridDistributedTxMapping dhtMapping : tx.dhtMap().values()) { - assert !dhtMapping.empty() || dhtMapping.queryUpdate(); + assert !dhtMapping.empty(); ClusterNode n = dhtMapping.primary(); @@ -1406,7 +1406,7 @@ private void sendPrepareRequests() { Collection dhtWrites = dhtMapping.writes(); - if (!dhtMapping.queryUpdate() && F.isEmpty(dhtWrites) && F.isEmpty(nearWrites)) + if (F.isEmpty(dhtWrites) && F.isEmpty(nearWrites)) continue; MiniFuture fut = new MiniFuture(n.id(), ++miniId, dhtMapping, nearMapping); @@ -1433,8 +1433,6 @@ private void sendPrepareRequests() { retVal, cctx.tm().txHandler().filterUpdateCountersForBackupNode(tx, n)); - req.queryUpdate(dhtMapping.queryUpdate()); - int idx = 0; for (IgniteTxEntry entry : dhtWrites) { @@ -1940,7 +1938,7 @@ void onResult(GridDhtTxPrepareResponse res) { } } - if (!dhtMapping.queryUpdate() && dhtMapping.empty()) { + if (dhtMapping.empty()) { dhtMap.remove(nodeId); if (log.isDebugEnabled()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java index 2aa76f9bcbf48..cf8c48d75f433 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java @@ -240,8 +240,6 @@ private GridNearTxPrepareRequest createRequest(Map> txNod tx.activeCachesDeploymentEnabled(), tx.txState().recovery()); - req.queryUpdate(m.queryUpdate()); - for (IgniteTxEntry txEntry : writes) { if (txEntry.op() == TRANSFORM) req.addDhtVersion(txEntry.txKey(), null); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java index 0f83b2bf5f1ed..f86c4e01eb580 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java @@ -739,11 +739,11 @@ private void finish(Iterable mappings, boolean commit) private void finish(int miniId, GridDistributedTxMapping m, boolean commit) { ClusterNode n = m.primary(); - assert !m.empty() || m.queryUpdate() : m + " " + tx.state(); + assert !m.empty() : m + " " + tx.state(); CacheWriteSynchronizationMode syncMode = tx.syncMode(); - if (m.explicitLock() || m.queryUpdate()) + if (m.explicitLock()) syncMode = FULL_SYNC; GridNearTxFinishRequest req = new GridNearTxFinishRequest( diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java index 24ef5b65fbbaf..eac1bb81d3c12 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java @@ -262,7 +262,7 @@ else if (txEntry.cached().detached()) { txEntry.ttl(CU.toTtl(expiry.getExpiryForAccess())); } - if (m.queryUpdate() || !m.empty()) { + if (!m.empty()) { // This step is very important as near and DHT versions grow separately. cctx.versions().onReceived(nodeId, res.dhtVersion()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java index 8df92671e3486..75c4411b9d4ef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java @@ -1654,7 +1654,7 @@ private void sendReply(UUID nodeId, GridDhtTxFinishRequest req, boolean committe GridDhtTxPrepareRequest req, GridDhtTxPrepareResponse res ) throws IgniteCheckedException { - if (req.queryUpdate() || !F.isEmpty(req.writes())) { + if (!F.isEmpty(req.writes())) { GridDhtTxRemote tx = ctx.tm().tx(req.version()); if (tx == null) { @@ -1843,7 +1843,7 @@ private void sendReply(UUID nodeId, GridDhtTxFinishRequest req, boolean committe res.invalidPartitionsByCacheId(tx.invalidPartitions()); - if (!req.queryUpdate() && tx.empty() && req.last()) { + if (tx.empty() && req.last()) { tx.skipCompletedVersions(req.skipCompletedVersion()); tx.rollbackRemoteTx(); From f6ea8c82e49f32f8a3125d20ac5056e3a7263234 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Wed, 15 May 2024 19:07:22 +0300 Subject: [PATCH 11/24] IGNITE-21835 WIP: GridNearPessimisticTxPrepareFuture, remove PartitionUpdateCounterMvccImpl. --- .../cache/PartitionUpdateCounterMvccImpl.java | 60 ------------------- .../GridNearPessimisticTxPrepareFuture.java | 4 +- 2 files changed, 1 insertion(+), 63 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PartitionUpdateCounterMvccImpl.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PartitionUpdateCounterMvccImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PartitionUpdateCounterMvccImpl.java deleted file mode 100644 index 5c1b2844a1e19..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PartitionUpdateCounterMvccImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache; - -import java.util.TreeMap; - -/** - * Update counter implementation for MVCC mode. - */ -public class PartitionUpdateCounterMvccImpl extends PartitionUpdateCounterTrackingImpl { - /** - * @param grp Group. - */ - public PartitionUpdateCounterMvccImpl(CacheGroupContext grp) { - super(grp); - } - - /** {@inheritDoc} */ - @Override public long reserve(long delta) { - return next(delta); - } - - /** {@inheritDoc} */ - @Override public long reserved() { - return get(); - } - - /** {@inheritDoc} */ - @Override protected PartitionUpdateCounterTrackingImpl createInstance() { - return new PartitionUpdateCounterMvccImpl(grp); - } - - /** {@inheritDoc} */ - @Override public PartitionUpdateCounter copy() { - PartitionUpdateCounterMvccImpl copy = new PartitionUpdateCounterMvccImpl(grp); - - copy.lwm.set(lwm.get()); - copy.first = first; - copy.queue = new TreeMap<>(queue); - copy.initCntr = initCntr; - copy.reservedCntr.set(reservedCntr.get()); - - return copy; - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java index cf8c48d75f433..76a45612e85fd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java @@ -294,8 +294,6 @@ private void preparePessimistic() { boolean hasNearCache = false; - Map> txNodes; - GridDhtTxMapping txMapping = new GridDhtTxMapping(); for (IgniteTxEntry txEntry : tx.allEntries()) { @@ -333,7 +331,7 @@ private void preparePessimistic() { txMapping.addMapping(nodes); } - txNodes = txMapping.transactionNodes(); + Map> txNodes = txMapping.transactionNodes(); tx.transactionNodes(txNodes); From 4ad0efc8589ac4599d9b49015f89e6c11a199d60 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Thu, 16 May 2024 18:49:06 +0300 Subject: [PATCH 12/24] IGNITE-21835 WIP: CacheContinuousQueryHandler, remove TransactionUnsupportedConcurrencyException. --- .../CacheContinuousQueryHandler.java | 27 -------------- .../processors/odbc/SqlListenerUtils.java | 3 -- ...actionUnsupportedConcurrencyException.java | 35 ------------------- .../resources/META-INF/classnames.properties | 1 - 4 files changed, 66 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/transactions/TransactionUnsupportedConcurrencyException.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java index 113ab77368029..665cf6cc029fc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java @@ -465,9 +465,6 @@ public void keepBinary(boolean keepBinary) { if (cctx == null) return; - if (!needNotify(false, cctx, -1, -1, evt)) - return; - // skipPrimaryCheck is set only when listen locally for replicated cache events. assert !skipPrimaryCheck || (cctx.isReplicated() && ctx.localNodeId().equals(nodeId)); @@ -577,9 +574,6 @@ public void keepBinary(boolean keepBinary) { if (skipCtx == null) skipCtx = new CounterSkipContext(part, cntr, topVer); - if (!needNotify(true, cctx, part, cntr, null)) - return skipCtx; - if (loc) { assert !locOnly; @@ -666,27 +660,6 @@ private String taskName() { @Override public boolean isPrimaryOnly() { return locOnly && !skipPrimaryCheck; } - - /** - * Checks whether it is need to notify listeners. - * - * @param skipEvt {@code True} if this is a skip counter event. - * @param cctx Cache context. - * @param part Partition id. - * @param cntr Update counter. - * @param evt CQ event. - * @return {@code True} if notification should happen immediately, or {@code false} if it should be delayed. - */ - private boolean needNotify(boolean skipEvt, - GridCacheContext cctx, - int part, - long cntr, - CacheContinuousQueryEvent evt) { - assert !skipEvt || evt == null; - assert skipEvt || part == -1 && cntr == -1; // part == -1 && cntr == -1 means skip counter. - - return true; - } }; CacheContinuousQueryManager mgr = manager(ctx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerUtils.java index c5c8d53651593..891496426a542 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerUtils.java @@ -32,7 +32,6 @@ import org.apache.ignite.internal.processors.query.IgniteSQLException; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.transactions.TransactionDuplicateKeyException; -import org.apache.ignite.transactions.TransactionUnsupportedConcurrencyException; import org.jetbrains.annotations.Nullable; /** @@ -298,8 +297,6 @@ public static int exceptionToSqlErrorCode(Throwable e) { return IgniteQueryErrorCode.QUERY_CANCELED; if (e instanceof TransactionDuplicateKeyException) return IgniteQueryErrorCode.DUPLICATE_KEY; - if (e instanceof TransactionUnsupportedConcurrencyException) - return IgniteQueryErrorCode.UNSUPPORTED_OPERATION; if (e instanceof IgniteSQLException) return ((IgniteSQLException)e).statusCode(); else diff --git a/modules/core/src/main/java/org/apache/ignite/transactions/TransactionUnsupportedConcurrencyException.java b/modules/core/src/main/java/org/apache/ignite/transactions/TransactionUnsupportedConcurrencyException.java deleted file mode 100644 index c8ce9bca957b0..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/transactions/TransactionUnsupportedConcurrencyException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.transactions; - -/** - * Exception thrown whenever transaction concurrency level is not supported. - */ -public class TransactionUnsupportedConcurrencyException extends TransactionException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates new exception with given error message. - * - * @param msg Error message. - */ - public TransactionUnsupportedConcurrencyException(String msg) { - super(msg); - } -} diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index b189027478386..91efdc09cdccb 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -2433,5 +2433,4 @@ org.apache.ignite.transactions.TransactionOptimisticException org.apache.ignite.transactions.TransactionRollbackException org.apache.ignite.transactions.TransactionState org.apache.ignite.transactions.TransactionTimeoutException -org.apache.ignite.transactions.TransactionUnsupportedConcurrencyException org.apache.ignite.util.AttributeNodeFilter From fc0704f7cd3c95e2b2866bf628ad6f58911232ed Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Thu, 16 May 2024 21:31:29 +0300 Subject: [PATCH 13/24] IGNITE-21835 WIP: IgniteTxManager, DmlDistributedPlanInfo. --- .../cache/transactions/IgniteTxManager.java | 30 ------------------- .../query/h2/dml/DmlDistributedPlanInfo.java | 15 +--------- .../query/h2/dml/UpdatePlanBuilder.java | 2 +- 3 files changed, 2 insertions(+), 45 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 0c382675b4938..5c30d4a5e0445 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -688,7 +688,6 @@ private boolean isCompleted(IgniteInternalTx tx) { * @param concurrency Concurrency. * @param isolation Isolation. * @param timeout transaction timeout. - * @param mvccOp Whether this transaction is being started via SQL API or not, or {@code null} if unknown. * @param txSize Expected transaction size. * @param lb Label. * @return New transaction. @@ -1732,35 +1731,6 @@ public void fastFinishTx(GridNearTxLocal tx, boolean commit, boolean clearThread } } - /** - * Removes Tx from manager. Can be used only if there were no updates. - * - * @param tx Transaction to finish. - */ - public void forgetTx(IgniteInternalTx tx) { - assert tx != null; - - if (transactionMap(tx).remove(tx.xidVersion(), tx)) { - // 1. Remove from per-thread storage. - clearThreadMap(tx); - - // 2. Unregister explicit locks. - if (!tx.alternateVersions().isEmpty()) - for (GridCacheVersion ver : tx.alternateVersions()) - idMap.remove(ver); - - // 3. Remove Near-2-DHT mappings. - if (tx instanceof GridCacheMappedVersion) - mappedVers.remove(((GridCacheMappedVersion)tx).mappedVersion()); - - // 4. Clear context. - resetContext(); - - // 5. Complete finish future. - tx.state(UNKNOWN); - } - } - /** * Tries to minimize damage from partially-committed transaction. * diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlDistributedPlanInfo.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlDistributedPlanInfo.java index bf1f2ddbd29fa..f7af9e6df1b3a 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlDistributedPlanInfo.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlDistributedPlanInfo.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.query.h2.dml; import java.util.List; -import org.apache.ignite.internal.sql.optimizer.affinity.PartitionResult; /** * Additional information about distributed update plan. @@ -30,20 +29,15 @@ public final class DmlDistributedPlanInfo { /** Identifiers of caches involved in update (used for cluster nodes mapping). */ private final List cacheIds; - /** Derived partitions info. */ - private final PartitionResult derivedParts; - /** * Constructor. * @param replicatedOnly Whether all caches are replicated. * @param cacheIds List of cache identifiers. - * @param derivedParts PartitionNode tree to calculate derived partition * (reference to PartitionNode#apply(java.lang.Object...)). */ - public DmlDistributedPlanInfo(boolean replicatedOnly, List cacheIds, PartitionResult derivedParts) { + public DmlDistributedPlanInfo(boolean replicatedOnly, List cacheIds) { this.replicatedOnly = replicatedOnly; this.cacheIds = cacheIds; - this.derivedParts = derivedParts; } /** @@ -59,11 +53,4 @@ public boolean isReplicatedOnly() { public List getCacheIds() { return cacheIds; } - - /** - * @return Query derived partitions info. - */ - public PartitionResult derivedPartitions() { - return derivedParts; - } } diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java index 68b7daeb9d8ff..c3b26a13adbbe 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java @@ -986,7 +986,7 @@ private static DmlDistributedPlanInfo checkPlanCanBeDistributed( H2Utils.checkQuery(idx, cacheIds, qry.tables()); - return new DmlDistributedPlanInfo(qry.isReplicatedOnly(), cacheIds, qry.derivedPartitions()); + return new DmlDistributedPlanInfo(qry.isReplicatedOnly(), cacheIds); } else return null; From 4a31f07d03992f491869c35da623c29d641f7fe0 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Fri, 17 May 2024 18:27:40 +0300 Subject: [PATCH 14/24] IGNITE-21835 WIP: Remove C++ MVCC SQL status codes. --- .../cpp/odbc/include/ignite/odbc/common_types.h | 14 +------------- modules/platforms/cpp/odbc/src/common_types.cpp | 6 ------ .../cpp/odbc/src/diagnostic/diagnostic_record.cpp | 12 ------------ 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h b/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h index c2158ab485af5..a8fe79dd8fc21 100644 --- a/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h +++ b/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h @@ -95,15 +95,9 @@ namespace ignite /** Invalid cursor state. */ S24000_INVALID_CURSOR_STATE, - /** Invalid transaction state. */ - S25000_INVALID_TRANSACTION_STATE, - /** Invalid schema name. */ S3F000_INVALID_SCHEMA_NAME, - /** Serialization failure. */ - S40001_SERIALIZATION_FAILURE, - /** Syntax error or access violation. */ S42000_SYNTAX_ERROR_OR_ACCESS_VIOLATION, @@ -380,13 +374,7 @@ namespace ignite ENTRY_PROCESSING = 4005, /** Cache not found. */ - CACHE_NOT_FOUND = 4006, - - /** Transaction is already completed. */ - TRANSACTION_COMPLETED = 5004, - - /** Transaction serialization error. */ - TRANSACTION_SERIALIZATION_ERROR = 5005 + CACHE_NOT_FOUND = 4006 }; }; diff --git a/modules/platforms/cpp/odbc/src/common_types.cpp b/modules/platforms/cpp/odbc/src/common_types.cpp index 72b3cc6602309..ea8a23dcb5371 100644 --- a/modules/platforms/cpp/odbc/src/common_types.cpp +++ b/modules/platforms/cpp/odbc/src/common_types.cpp @@ -157,12 +157,6 @@ namespace ignite case ResponseStatus::COLUMN_ALREADY_EXISTS: return SqlState::S42S21_COLUMN_ALREADY_EXISTS; - case ResponseStatus::TRANSACTION_COMPLETED: - return SqlState::S25000_INVALID_TRANSACTION_STATE; - - case ResponseStatus::TRANSACTION_SERIALIZATION_ERROR: - return SqlState::S40001_SERIALIZATION_FAILURE; - case ResponseStatus::CACHE_NOT_FOUND: case ResponseStatus::NULL_TABLE_DESCRIPTOR: case ResponseStatus::CONVERSION_FAILED: diff --git a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp index d3a369242f998..7b82b4090cd93 100644 --- a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp +++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp @@ -79,15 +79,9 @@ namespace /** SQL state 24000 constant. */ const std::string STATE_24000 = "24000"; - /** SQL state 25000 constant. */ - const std::string STATE_25000 = "25000"; - /** SQL state 3F000 constant. */ const std::string STATE_3F000 = "3F000"; - /** SQL state 40001 constant. */ - const std::string STATE_40001 = "40001"; - /** SQL state 42000 constant. */ const std::string STATE_42000 = "42000"; @@ -311,15 +305,9 @@ namespace ignite case SqlState::S24000_INVALID_CURSOR_STATE: return STATE_24000; - case SqlState::S25000_INVALID_TRANSACTION_STATE: - return STATE_25000; - case SqlState::S3F000_INVALID_SCHEMA_NAME: return STATE_3F000; - case SqlState::S40001_SERIALIZATION_FAILURE: - return STATE_40001; - case SqlState::S42000_SYNTAX_ERROR_OR_ACCESS_VIOLATION: return STATE_42000; From 4c9b9b24230225357304c34585e311cacb99e889 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Tue, 21 May 2024 00:44:50 +0300 Subject: [PATCH 15/24] IGNITE-21835 WIP: Remove IgnitePageStoreManager#initialize, CacheEntryInfoCollection, GridDhtLockFuture, GridDhtCacheAdapter --- .../pagemem/store/IgnitePageStoreManager.java | 12 -------- .../cache/CacheEntryInfoCollection.java | 12 -------- .../cache/distributed/dht/DhtLockFuture.java | 30 ------------------- .../distributed/dht/GridDhtCacheAdapter.java | 1 - .../distributed/dht/GridDhtLockFuture.java | 4 +-- .../cache/distributed/dht/GridDhtTxLocal.java | 4 +-- .../file/FilePageStoreManager.java | 27 ----------------- .../pagemem/NoOpPageStoreManager.java | 6 ---- 8 files changed, 4 insertions(+), 92 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/DhtLockFuture.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java index a87a46a6b45fb..3564b4e1e6975 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java @@ -43,18 +43,6 @@ public interface IgnitePageStoreManager extends GridCacheSharedManager, IgniteCh */ public void finishRecover() throws IgniteCheckedException; - /** - * Initializes disk store structures. - * - * @param cacheId Cache id. - * @param partitions Partitions count. - * @param cacheName Cache name. - * @param pageMetrics Page metrics. - * @throws IgniteCheckedException If failed. - */ - public void initialize(int cacheId, int partitions, String cacheName, PageMetrics pageMetrics) - throws IgniteCheckedException; - /** * Callback called when a cache is starting. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java index b6da77fa4db81..c21f5b6099722 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java @@ -37,18 +37,6 @@ public class CacheEntryInfoCollection implements Message { @GridDirectCollection(GridCacheEntryInfo.class) private List infos; - /** */ - public CacheEntryInfoCollection() { - // No-op - } - - /** - * @param infos List of cache entry info. - */ - public CacheEntryInfoCollection(List infos) { - this.infos = infos; - } - /** * */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/DhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/DhtLockFuture.java deleted file mode 100644 index b729dcd7f788f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/DhtLockFuture.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.distributed.dht; - -import org.apache.ignite.internal.IgniteInternalFuture; - -/** - * Marker interface. - */ -public interface DhtLockFuture extends IgniteInternalFuture { - /** - * @param error Error. - */ - public void onError(Throwable error); -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java index 19bbb689a2ae9..b47447f87c610 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java @@ -1565,7 +1565,6 @@ private void updateTtl( * @return {@code True} if cache affinity changed and operation should be remapped. */ protected final boolean needRemap(AffinityTopologyVersion rmtVer) { - // TODO IGNITE-7164 check mvcc crd for mvcc enabled txs. return !ctx.affinity().isCompatibleWithCurrentTopologyVersion(rmtVer); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java index 3f2e8138e4a04..f5ed1f1e577ae 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java @@ -85,7 +85,7 @@ * Cache lock future. */ public final class GridDhtLockFuture extends GridCacheCompoundIdentityFuture - implements GridCacheVersionedFuture, GridDhtFuture, GridCacheMappedVersion, DhtLockFuture { + implements GridCacheVersionedFuture, GridDhtFuture, GridCacheMappedVersion { /** */ private static final long serialVersionUID = 0L; @@ -638,7 +638,7 @@ private void readyLocks() { /** * @param t Error. */ - @Override public void onError(Throwable t) { + public void onError(Throwable t) { synchronized (this) { if (err != null) return; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java index 49f009119c8f6..d4929dacf246a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java @@ -417,8 +417,8 @@ private void finishTx(boolean commit, @Nullable IgniteInternalFuture prepFut, Gr final IgniteInternalFuture lockFut = tryRollbackAsync(); if (lockFut != null) { - if (lockFut instanceof DhtLockFuture) - ((DhtLockFuture)lockFut).onError(rollbackException()); + if (lockFut instanceof GridDhtLockFuture) + ((GridDhtLockFuture)lockFut).onError(rollbackException()); else if (!lockFut.isDone()) { /* * Prevents race with {@link GridDhtTransactionalCacheAdapter#lockAllAsync diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java index df220b27dcfe2..c86c2ecb99a38 100755 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java @@ -59,7 +59,6 @@ import org.apache.ignite.internal.pagemem.store.PageStoreCollection; import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor; -import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter; import org.apache.ignite.internal.processors.cache.persistence.DataRegion; import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager; @@ -436,32 +435,6 @@ private List findCacheGroupsWithDisabledWal() { } } - /** {@inheritDoc} */ - @Override public void initialize(int cacheId, int partitions, String cacheName, PageMetrics pageMetrics) - throws IgniteCheckedException { - assert storeWorkDir != null; - - if (!idxCacheStores.containsKey(cacheId)) { - GridCacheContext cctx = this.cctx.cacheContext(cacheId); - - CacheStoreHolder holder = initDir( - new File(storeWorkDir, cacheName), - cacheId, - cacheName, - partitions, - pageMetrics, - cctx != null && cctx.config().isEncryptionEnabled(), - cctx != null - ? cctx.group().caches().stream().map(GridCacheContext::name).collect(Collectors.toSet()) - : null - ); - - CacheStoreHolder old = idxCacheStores.put(cacheId, holder); - - assert old == null : "Non-null old store holder for cacheId: " + cacheId; - } - } - /** {@inheritDoc} */ @Override public void initializeForCache(CacheGroupDescriptor grpDesc, CacheConfiguration ccfg) throws IgniteCheckedException { assert storeWorkDir != null; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java index 03312bbb0ec57..09ac69165024f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java @@ -52,12 +52,6 @@ public class NoOpPageStoreManager implements IgnitePageStoreManager { // No-op. } - /** {@inheritDoc} */ - @Override public void initialize(int cacheId, int partitions, String workingDir, - PageMetrics pageMetrics) throws IgniteCheckedException { - // No-op. - } - /** {@inheritDoc} */ @Override public void initializeForCache(CacheGroupDescriptor grpDesc, CacheConfiguration ccfg) throws IgniteCheckedException { // No-op. From a9085b7cc3de091626c7f70b541ea0740ed492fd Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Tue, 21 May 2024 21:20:30 +0300 Subject: [PATCH 16/24] IGNITE-21835 WIP: Partial revert CacheEntryInfoCollection. Clean-up GridCacheUtils, GridNearTxLocal, RowStore, FreeList. --- .../cache/CacheEntryInfoCollection.java | 5 +++ .../processors/cache/GridCacheUtils.java | 44 ------------------- .../distributed/near/GridNearTxLocal.java | 2 +- .../cache/persistence/RowStore.java | 25 ----------- .../freelist/AbstractFreeList.java | 26 ----------- .../cache/persistence/freelist/FreeList.java | 14 ------ 6 files changed, 6 insertions(+), 110 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java index c21f5b6099722..fab0ac277fb4b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryInfoCollection.java @@ -37,6 +37,11 @@ public class CacheEntryInfoCollection implements Message { @GridDirectCollection(GridCacheEntryInfo.class) private List infos; + /** */ + public CacheEntryInfoCollection() { + // No-op + } + /** * */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java index 0a12ac3959c64..35936cc27b304 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java @@ -32,7 +32,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.LongAdder; import javax.cache.Cache; import javax.cache.CacheException; import javax.cache.configuration.Factory; @@ -564,30 +563,6 @@ public static IgniteReducer boolReducer() { }; } - /** - * @return Long reducer. - */ - public static IgniteReducer longReducer() { - return new IgniteReducer() { - private final LongAdder res = new LongAdder(); - - @Override public boolean collect(Long l) { - if (l != null) - res.add(l); - - return true; - } - - @Override public Long reduce() { - return res.sum(); - } - - @Override public String toString() { - return "Long reducer: " + res; - } - }; - } - /** * Gets reducer that aggregates maps into one. * @@ -2093,25 +2068,6 @@ public static int encryptedPageSize(int pageSize, EncryptionSpi encSpi) { - encSpi.blockSize(); /* For CRC and encryption key ID. */ } - /** - * @param sctx Shared context. - * @param cacheIds Cache ids. - * @return First partitioned cache or {@code null} in case no partitioned cache ids are in list. - */ - public static GridCacheContext firstPartitioned(GridCacheSharedContext sctx, int[] cacheIds) { - for (int i = 0; i < cacheIds.length; i++) { - GridCacheContext cctx = sctx.cacheContext(cacheIds[i]); - - if (cctx == null) - throw new CacheException("Failed to find cache."); - - if (!cctx.isReplicated()) - return cctx; - } - - return null; - } - /** * @param sctx Shared context. * @param cacheIds Cache ids. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java index 3b00043a8c1f8..a3205a8a5a01f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java @@ -2158,7 +2158,7 @@ public IgniteInternalFuture> getAllAsync( * @param skipVals Skip values flag. * @param keepCacheObjects Keep cache objects flag. * @param skipStore Skip store flag. - * @param recovery Recovery flag.. + * @param recovery Recovery flag. * @return Enlisted keys. * @throws IgniteCheckedException If failed. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/RowStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/RowStore.java index 422f1fd590272..cffcf9b1e5be0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/RowStore.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/RowStore.java @@ -27,7 +27,6 @@ import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.processors.cache.persistence.freelist.FreeList; -import org.apache.ignite.internal.processors.cache.persistence.tree.util.PageHandler; import org.apache.ignite.internal.processors.query.GridQueryRowCacheCleaner; import org.apache.ignite.internal.util.typedef.internal.U; @@ -157,30 +156,6 @@ public boolean updateRow(long link, CacheDataRow row, IoStatisticsHolder statHol return freeList.updateDataRow(link, row, statHolder); } - /** - * Run page handler operation over the row. - * - * @param link Row link. - * @param pageHnd Page handler. - * @param arg Page handler argument. - * @throws IgniteCheckedException If failed. - */ - public void updateDataRow(long link, PageHandler pageHnd, S arg, - IoStatisticsHolder statHolder) throws IgniteCheckedException { - if (!persistenceEnabled) - freeList.updateDataRow(link, pageHnd, arg, statHolder); - else { - ctx.database().checkpointReadLock(); - - try { - freeList.updateDataRow(link, pageHnd, arg, statHolder); - } - finally { - ctx.database().checkpointReadUnlock(); - } - } - } - /** * @return Free list. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/AbstractFreeList.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/AbstractFreeList.java index 1759e229f184d..7e149c1fdd1ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/AbstractFreeList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/AbstractFreeList.java @@ -802,32 +802,6 @@ private long initReusedPage(T row, long reusedPageId, IoStatisticsHolder statHol } } - /** {@inheritDoc} */ - @Override public R updateDataRow(long link, PageHandler pageHnd, S arg, - IoStatisticsHolder statHolder) throws IgniteCheckedException { - assert link != 0; - - try { - long pageId = PageIdUtils.pageId(link); - int itemId = PageIdUtils.itemId(link); - - R updRes = write(pageId, pageHnd, arg, itemId, null, statHolder); - - assert updRes != null; // Can't fail here. - - return updRes; - } - catch (AssertionError e) { - throw corruptedFreeListException(e); - } - catch (IgniteCheckedException | Error e) { - throw e; - } - catch (Throwable t) { - throw new CorruptedFreeListException("Failed to update data row", t, grpId); - } - } - /** {@inheritDoc} */ @Override public void removeDataRowByLink(long link, IoStatisticsHolder statHolder) throws IgniteCheckedException { assert link != 0; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeList.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeList.java index 5914ae52fd840..7d492fd46f8a3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeList.java @@ -22,7 +22,6 @@ import org.apache.ignite.IgniteLogger; import org.apache.ignite.internal.metric.IoStatisticsHolder; import org.apache.ignite.internal.processors.cache.persistence.Storable; -import org.apache.ignite.internal.processors.cache.persistence.tree.util.PageHandler; /** */ @@ -50,19 +49,6 @@ public interface FreeList { */ public boolean updateDataRow(long link, T row, IoStatisticsHolder statHolder) throws IgniteCheckedException; - /** - * @param link Row link. - * @param pageHnd Page handler. - * @param arg Handler argument. - * @param Argument type. - * @param Result type. - * @param statHolder Statistics holder to track IO operations. - * @return Result. - * @throws IgniteCheckedException If failed. - */ - public R updateDataRow(long link, PageHandler pageHnd, S arg, IoStatisticsHolder statHolder) - throws IgniteCheckedException; - /** * @param link Row link. * @param statHolder Statistics holder to track IO operations. From 089948466244e7dcdbb37324673c7a372d0142f8 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Tue, 21 May 2024 21:27:00 +0300 Subject: [PATCH 17/24] IGNITE-21835 WIP: DdlTransactionSelfTest, SqlParserMultiStatementSelfTest. --- .../processors/cache/DdlTransactionCalciteSelfTest.java | 2 +- ...ansactionSelfTest.java => DdlTransactionSelfTestBase.java} | 2 +- .../ignite/internal/sql/SqlParserMultiStatementSelfTest.java | 4 ++-- .../processors/cache/DdlTransactionIndexingSelfTest.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename modules/core/src/test/java/org/apache/ignite/internal/processors/cache/{DdlTransactionSelfTest.java => DdlTransactionSelfTestBase.java} (98%) diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionCalciteSelfTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionCalciteSelfTest.java index e0011a1d83f31..f8859721389f2 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionCalciteSelfTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionCalciteSelfTest.java @@ -21,7 +21,7 @@ import org.apache.ignite.configuration.QueryEngineConfiguration; /** */ -public class DdlTransactionCalciteSelfTest extends DdlTransactionSelfTest { +public class DdlTransactionCalciteSelfTest extends DdlTransactionSelfTestBase { /** {@inheritDoc} */ @Override protected QueryEngineConfiguration getQueryEngineConfiguration() { return new CalciteQueryEngineConfiguration() diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTestBase.java similarity index 98% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTestBase.java index b779af8ef131e..d16b12404eae0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionSelfTestBase.java @@ -43,7 +43,7 @@ /** * */ -public abstract class DdlTransactionSelfTest extends GridCommonAbstractTest { +public abstract class DdlTransactionSelfTestBase extends GridCommonAbstractTest { /** Create table request. */ public static final String CREATE_TABLE = "CREATE TABLE " + "person (id int, name varchar, age int, company varchar, city varchar, primary key (id, name, city))" + diff --git a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserMultiStatementSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserMultiStatementSelfTest.java index 20fe284f30ce9..1545c9961f850 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserMultiStatementSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserMultiStatementSelfTest.java @@ -45,9 +45,9 @@ public void testEmptyStatements() { assertEquals("CREATE INDEX TEST on TABLE1(id)", parser.lastCommandSql()); assertEquals(" ; DROP USER test ;;;", parser.remainingSql()); - SqlCommand begin = parser.nextCommand(); + SqlCommand dropUser = parser.nextCommand(); - assertTrue(begin instanceof SqlDropUserCommand); + assertTrue(dropUser instanceof SqlDropUserCommand); assertEquals("DROP USER test", parser.lastCommandSql()); assertEquals(";;", parser.remainingSql()); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionIndexingSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionIndexingSelfTest.java index adadfd02c8564..990c161d82d9e 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionIndexingSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/DdlTransactionIndexingSelfTest.java @@ -23,7 +23,7 @@ /** * */ -public class DdlTransactionIndexingSelfTest extends DdlTransactionSelfTest { +public class DdlTransactionIndexingSelfTest extends DdlTransactionSelfTestBase { /** {@inheritDoc} */ @Override protected QueryEngineConfiguration getQueryEngineConfiguration() { return new IndexingQueryEngineConfiguration() From 359ab5ad9178e5f8c8999faa99f82012fb5c28bd Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Tue, 21 May 2024 22:23:52 +0300 Subject: [PATCH 18/24] IGNITE-21835 WIP: Checkstyle. --- .../ignite/internal/pagemem/store/IgnitePageStoreManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java index 3564b4e1e6975..9d0f44705be1e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java @@ -25,7 +25,6 @@ import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor; import org.apache.ignite.internal.processors.cache.GridCacheSharedManager; -import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics; import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageReadWriteManager; import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport; From 21a09ee57f36e33e3f20b0b75db7b7f4c63e17dc Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Wed, 22 May 2024 14:23:45 +0300 Subject: [PATCH 19/24] IGNITE-21835 WIP: Storable#headerSize removal. --- .../cache/persistence/CacheDataRowAdapter.java | 5 ----- .../cache/persistence/GridCacheOffheapManager.java | 5 ----- .../processors/cache/persistence/Storable.java | 6 ------ .../cache/persistence/freelist/SimpleDataRow.java | 5 ----- .../cache/persistence/tree/io/AbstractDataPageIO.java | 10 ---------- .../processors/database/CacheFreeListSelfTest.java | 5 ----- .../internal/processors/query/h2/opt/H2CacheRow.java | 5 ----- 7 files changed, 41 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java index 1f761da547987..53266cef84319 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java @@ -893,11 +893,6 @@ public boolean isReady() { return len + (cacheId() != 0 ? 4 : 0); } - /** {@inheritDoc} */ - @Override public int headerSize() { - return 0; - } - /** * */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java index 9de2efe0e3140..5a68181575a6f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java @@ -1646,11 +1646,6 @@ private DataEntryRow(DataEntry entry) { throw new UnsupportedOperationException(); } - /** {@inheritDoc} */ - @Override public int headerSize() { - throw new UnsupportedOperationException(); - } - /** {@inheritDoc} */ @Override public long link() { return 0; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/Storable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/Storable.java index d8fe3a4d2f0c3..a0f5ab19b0a9a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/Storable.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/Storable.java @@ -46,12 +46,6 @@ public interface Storable { */ public int size() throws IgniteCheckedException; - /** - * @return Row header size in page. Header is indivisible part of row - * which is entirely available on the very first page followed by the row link. - */ - public int headerSize(); - /** * @return I/O for handling this storable. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/SimpleDataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/SimpleDataRow.java index 382869cf877c5..a18a4f913cb31 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/SimpleDataRow.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/SimpleDataRow.java @@ -79,11 +79,6 @@ public SimpleDataRow(int part, byte[] val) { return 2 /** Fragment size */ + 2 /** Row size */ + value().length; } - /** {@inheritDoc} */ - @Override public int headerSize() { - return 0; - } - /** * @return Value. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/AbstractDataPageIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/AbstractDataPageIO.java index 043036cd5e5d3..9802a6ece19c0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/AbstractDataPageIO.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/AbstractDataPageIO.java @@ -1142,16 +1142,6 @@ private int addRowFragment( int payloadSize = payload != null ? payload.length : Math.min(rowSize - written, getFreeSpace(pageAddr)); - if (row != null) { - int remain = rowSize - written - payloadSize; - int hdrSize = row.headerSize(); - - // We need page header (i.e. MVCC info) is located entirely on the very first page in chain. - // So we force moving it to the next page if it could not fit entirely on this page. - if (remain > 0 && remain < hdrSize) - payloadSize -= hdrSize - remain; - } - int fullEntrySize = getPageEntrySize(payloadSize, SHOW_PAYLOAD_LEN | SHOW_LINK | SHOW_ITEM); int dataOff = getDataOffsetForWrite(pageAddr, fullEntrySize, directCnt, indirectCnt, pageSize); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListSelfTest.java index abe7091861add..5d778b66a74ce 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/CacheFreeListSelfTest.java @@ -610,11 +610,6 @@ private TestDataRow(int keySize, int valSize) { return len + (cacheId() != 0 ? 4 : 0); } - /** {@inheritDoc} */ - @Override public int headerSize() { - return 0; - } - /** {@inheritDoc} */ @Override public long link() { return link; diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/H2CacheRow.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/H2CacheRow.java index 5046e9dd91451..c9b4db13be711 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/H2CacheRow.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/H2CacheRow.java @@ -263,11 +263,6 @@ private boolean removedRow() { throw new UnsupportedOperationException(); } - /** {@inheritDoc} */ - @Override public int headerSize() { - throw new UnsupportedOperationException(); - } - /** {@inheritDoc} */ @Override public String toString() { SB sb = new SB("Row@"); From 68ad6a79c7443cc86e71e1f202ac585188e410fc Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Wed, 22 May 2024 17:51:10 +0300 Subject: [PATCH 20/24] IGNITE-21835 WIP: B+Tree --- .../cache/persistence/tree/BPlusTree.java | 517 ------------------ .../database/BPlusTreeSelfTest.java | 171 +----- 2 files changed, 1 insertion(+), 687 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java index 9816a18aeba48..aae72871fe252 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/BPlusTree.java @@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.function.Supplier; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.failure.FailureContext; import org.apache.ignite.failure.FailureType; @@ -1367,63 +1366,6 @@ public GridCursor find( } } - /** - * @param lower Lower bound inclusive. - * @param upper Upper bound inclusive. - * @param c Closure applied for all found items, iteration is stopped if closure returns {@code false}. - * @throws IgniteCheckedException If failed. - */ - public void iterate(L lower, L upper, TreeRowClosure c) throws IgniteCheckedException { - checkDestroyed(); - - ClosureCursor cursor = new ClosureCursor(lower, upper, c); - - try { - cursor.iterate(); - } - catch (CorruptedDataStructureException e) { - throw e; - } - catch (IgniteCheckedException e) { - throw new IgniteCheckedException("Runtime failure on bounds: [lower=" + lower + ", upper=" + upper + "]", e); - } - catch (RuntimeException | AssertionError e) { - throw corruptedTreeException( - "Runtime failure on bounds: [lower=" + lower + ", upper=" + upper + "]", - e, grpId, pages(cursor.getCursor != null, () -> new long[]{cursor.getCursor.pageId}) - ); - } - finally { - checkDestroyed(); - } - } - - /** - * @param lower Lower bound inclusive. - * @param upper Upper bound inclusive. - * @param c Closure applied for all found items. - * @throws IgniteCheckedException If failed. - */ - public void visit(L lower, L upper, TreeVisitorClosure c) throws IgniteCheckedException { - checkDestroyed(); - - try { - new TreeVisitor(lower, upper, c).visit(); - } - catch (IgniteCheckedException e) { - throw new IgniteCheckedException("Runtime failure on bounds: [lower=" + lower + ", upper=" + upper + "]", e); - } - catch (RuntimeException e) { - throw new IgniteException("Runtime failure on bounds: [lower=" + lower + ", upper=" + upper + "]", e); - } - catch (AssertionError e) { - throw new AssertionError("Assertion error on bounds: [lower=" + lower + ", upper=" + upper + "]", e); - } - finally { - checkDestroyed(); - } - } - /** {@inheritDoc} */ @Override public T findFirst() throws IgniteCheckedException { return findFirst(null); @@ -3137,87 +3079,6 @@ private Result putDown(final Put p, final long pageId, final long fwdId, int lvl } } - /** - * @param c Get. - * @throws IgniteCheckedException If failed. - */ - private void doVisit(TreeVisitor c) throws IgniteCheckedException { - for (;;) { // Go down with retries. - c.init(); - - switch (visitDown(c, c.rootId, 0L, c.rootLvl)) { - case RETRY: - case RETRY_ROOT: - checkInterrupted(); - - continue; - - default: - return; - } - } - } - - /** - * @param v Tree visitor. - * @param pageId Page ID. - * @param fwdId Expected forward page ID. - * @param lvl Level. - * @return Result code. - * @throws IgniteCheckedException If failed. - */ - private Result visitDown(final TreeVisitor v, final long pageId, final long fwdId, final int lvl) - throws IgniteCheckedException { - long page = acquirePage(pageId); - - try { - for (;;) { - v.checkLockRetry(); - - // Init args. - v.pageId = pageId; - v.fwdId = fwdId; - - Result res = read(pageId, page, search, v, lvl, RETRY); - - switch (res) { - case GO_DOWN: - case GO_DOWN_X: - assert v.pageId != pageId; - assert v.fwdId != fwdId || fwdId == 0; - - // Go down recursively. - res = visitDown(v, v.pageId, v.fwdId, lvl - 1); - - switch (res) { - case RETRY: - checkInterrupted(); - - continue; // The child page got split, need to reread our page. - - default: - return res; - } - - case NOT_FOUND: - assert lvl == 0 : lvl; - - return v.init(pageId, page, fwdId); - - case FOUND: - throw new IllegalStateException(); // Must never be called because we always have a shift. - - default: - return res; - } - } - } - finally { - if (v.canRelease(pageId, lvl)) - releasePage(pageId, page); - } - } - /** * @param io IO. * @param pageAddr Page address. @@ -3495,259 +3356,6 @@ private final class GetCursor extends Get { } } - /** - * Get a cursor for range. - */ - private final class TreeVisitor extends Get { - /** */ - long nextPageId; - - /** */ - L upper; - - /** */ - TreeVisitorClosure p; - - /** */ - private boolean dirty; - - /** */ - private boolean writing; - - /** - * @param lower Lower bound. - */ - TreeVisitor(L lower, L upper, TreeVisitorClosure p) { - super(lower, false); - - this.shift = -1; - this.upper = upper; - this.p = p; - } - - /** {@inheritDoc} */ - @Override boolean found(BPlusIO io, long pageAddr, int idx, int lvl) throws IgniteCheckedException { - throw new IllegalStateException(); // Must never be called because we always have a shift. - } - - /** {@inheritDoc} */ - @Override boolean notFound(BPlusIO io, long pageAddr, int idx, int lvl) throws IgniteCheckedException { - if (lvl != 0) - return false; - - if (!(writing = (p.state() & TreeVisitorClosure.CAN_WRITE) != 0)) - init(pageAddr, io, idx); - - return true; - } - - /** */ - Result init(long pageId, long page, long fwdId) throws IgniteCheckedException { - // Init args. - this.pageId = pageId; - this.fwdId = fwdId; - - if (writing) { - long pageAddr = writeLock(pageId, page); - - if (pageAddr == 0) - return RETRY; - - try { - BPlusIO io = io(pageAddr); - - // Check triangle invariant. - if (io.getForward(pageAddr) != fwdId) - return RETRY; - - init(pageAddr, io, -1); - } - finally { - unlock(pageId, page, pageAddr); - } - } - - return NOT_FOUND; - } - - /** - * @param pageAddr Page address. - * @param io IO. - * @param startIdx Start index. - * @throws IgniteCheckedException If failed. - */ - private void init(long pageAddr, BPlusIO io, int startIdx) throws IgniteCheckedException { - nextPageId = 0; - - int cnt = io.getCount(pageAddr); - - if (cnt != 0) - visit(pageAddr, io, startIdx, cnt); - } - - /** - * @param pageAddr Page address. - * @param io IO. - * @param startIdx Start index. - * @param cnt Number of rows in the buffer. - * @throws IgniteCheckedException If failed. - */ - private void visit(long pageAddr, BPlusIO io, int startIdx, int cnt) - throws IgniteCheckedException { - assert io.isLeaf() : io; - assert cnt != 0 : cnt; // We can not see empty pages (empty tree handled in init). - assert startIdx >= -1 : startIdx; - assert cnt >= startIdx; - - checkDestroyed(); - - nextPageId = io.getForward(pageAddr); - - if (startIdx == -1) - startIdx = findLowerBound(pageAddr, io, cnt); - - if (cnt == startIdx) - return; // Go to the next page; - - cnt = findUpperBound(pageAddr, io, startIdx, cnt); - - for (int i = startIdx; i < cnt; i++) { - int state = p.visit(BPlusTree.this, io, pageAddr, i, wal); - - boolean stop = (state & TreeVisitorClosure.STOP) != 0; - - if (writing) - dirty = dirty || (state & TreeVisitorClosure.DIRTY) != 0; - - if (stop) { - nextPageId = 0; // The End. - - return; - } - } - - if (nextPageId != 0) { - row = io.getLookupRow(BPlusTree.this, pageAddr, cnt - 1); // Need save last row. - - shift = 1; - } - } - - /** - * @param pageAddr Page address. - * @param io IO. - * @param cnt Count. - * @return Adjusted to lower bound start index. - * @throws IgniteCheckedException If failed. - */ - private int findLowerBound(long pageAddr, BPlusIO io, int cnt) throws IgniteCheckedException { - assert io.isLeaf(); - - // Compare with the first row on the page. - int cmp = compare(0, io, pageAddr, 0, row); - - if (cmp < 0 || (cmp == 0 && shift == 1)) { - int idx = findInsertionPoint(0, io, pageAddr, 0, cnt, row, shift); - - assert idx < 0; - - return fix(idx); - } - - return 0; - } - - /** - * @param pageAddr Page address. - * @param io IO. - * @param low Start index. - * @param cnt Number of rows in the buffer. - * @return Corrected number of rows with respect to upper bound. - * @throws IgniteCheckedException If failed. - */ - private int findUpperBound(long pageAddr, BPlusIO io, int low, int cnt) throws IgniteCheckedException { - assert io.isLeaf(); - - // Compare with the last row on the page. - int cmp = compare(0, io, pageAddr, cnt - 1, upper); - - if (cmp > 0) { - int idx = findInsertionPoint(0, io, pageAddr, low, cnt, upper, 1); - - assert idx < 0; - - cnt = fix(idx); - - nextPageId = 0; // The End. - } - - return cnt; - } - - /** - * @throws IgniteCheckedException If failed. - */ - private void nextPage() throws IgniteCheckedException { - for (;;) { - if (nextPageId == 0) - return; - - long pageId = nextPageId; - long page = acquirePage(pageId); - try { - long pageAddr = lock(pageId, page); // Doing explicit null check. - - // If concurrent merge occurred we have to reinitialize cursor from the last returned row. - if (pageAddr == 0L) - break; - - try { - BPlusIO io = io(pageAddr); - - visit(pageAddr, io, -1, io.getCount(pageAddr)); - } - finally { - unlock(pageId, page, pageAddr); - } - } - finally { - releasePage(pageId, page); - } - } - - doVisit(this); // restart from last read row - } - - /** */ - private void unlock(long pageId, long page, long pageAddr) { - if (writing) { - writeUnlock(pageId, page, pageAddr, dirty); - - dirty = false; // reset dirty flag - } - else - readUnlock(pageId, page, pageAddr); - } - - /** */ - private long lock(long pageId, long page) { - if (writing = ((p.state() & TreeVisitorClosure.CAN_WRITE) != 0)) - return writeLock(pageId, page); - else - return readLock(pageId, page); - } - - /** - * @throws IgniteCheckedException If failed. - */ - private void visit() throws IgniteCheckedException { - doVisit(this); - - while (nextPageId != 0) - nextPage(); - } - } - /** * Get the last item in the tree which matches the passed filter. */ @@ -6035,101 +5643,6 @@ private void updateLowerBound(L lower) { } } - /** - * Closure cursor. - */ - private final class ClosureCursor extends AbstractForwardCursor { - /** */ - private final TreeRowClosure p; - - /** */ - private L lastRow; - - /** - * @param lowerBound Lower bound inclusive. - * @param upperBound Upper bound inclusive. - * @param p Row predicate. - */ - ClosureCursor(L lowerBound, L upperBound, TreeRowClosure p) { - super(lowerBound, upperBound, true, true); - - assert lowerBound != null; - assert upperBound != null; - assert p != null; - - this.p = p; - } - - /** {@inheritDoc} */ - @Override void init0() { - // No-op. - } - - /** {@inheritDoc} */ - @Override boolean fillFromBuffer0(long pageAddr, BPlusIO io, int startIdx, int cnt) - throws IgniteCheckedException { - if (startIdx == -1) - startIdx = findLowerBound(pageAddr, io, cnt); - - if (cnt == startIdx) - return false; - - for (int i = startIdx; i < cnt; i++) { - int cmp = compare(0, io, pageAddr, i, upperBound); - - if (cmp > 0) { - nextPageId = 0; // The End. - - return false; - } - - boolean stop = !p.apply(BPlusTree.this, io, pageAddr, i); - - if (stop) { - nextPageId = 0; // The End. - - return true; - } - } - - if (nextPageId != 0) - lastRow = io.getLookupRow(BPlusTree.this, pageAddr, cnt - 1); // Need save last row. - - return true; - } - - /** {@inheritDoc} */ - @Override boolean reinitialize0() throws IgniteCheckedException { - return true; - } - - /** {@inheritDoc} */ - @Override void onNotFound(boolean readDone) { - nextPageId = 0; - } - - /** - * @throws IgniteCheckedException If failed. - */ - private void iterate() throws IgniteCheckedException { - find(); - - if (nextPageId == 0) - return; - - for (;;) { - L lastRow0 = lastRow; - - lastRow = null; - - nextPage(lastRow0); - - if (nextPageId == 0) - return; - } - } - } - /** * Forward cursor. */ @@ -6438,36 +5951,6 @@ public T create(BPlusTree tree, BPlusIO io, long pageAddr, int idx) throws IgniteCheckedException; } - /** - * A generic visitor-style interface for performing inspection/modification operations on the tree. - */ - public interface TreeVisitorClosure { - /** */ - int STOP = 0x01; - /** */ - int CAN_WRITE = STOP << 1; - /** */ - int DIRTY = CAN_WRITE << 1; - - /** - * Performs inspection or operation on a specified row. - * - * @param tree The tree. - * @param io Th tree IO object. - * @param pageAddr The page address. - * @param idx The item index. - * @return state bitset. - * @throws IgniteCheckedException If failed. - */ - public int visit(BPlusTree tree, BPlusIO io, long pageAddr, int idx, IgniteWriteAheadLogManager wal) - throws IgniteCheckedException; - - /** - * @return state bitset. - */ - public int state(); - } - /** * @return Return number of retries. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java index 0c4a3adb32b43..6697225882431 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java @@ -857,7 +857,6 @@ private void doTestPutRemove(boolean canGetRow) throws IgniteCheckedException { assertNoLocks(); assertEquals(x, tree.findOne(x).longValue()); - checkIterate(tree, x, x, x, true); assertNoLocks(); @@ -872,15 +871,12 @@ private void doTestPutRemove(boolean canGetRow) throws IgniteCheckedException { assertNull(tree.findOne(-1L)); - for (long x = 0; x < cnt; x++) { + for (long x = 0; x < cnt; x++) assertEquals(x, tree.findOne(x).longValue()); - checkIterate(tree, x, x, x, true); - } assertNoLocks(); assertNull(tree.findOne(cnt)); - checkIterate(tree, cnt, cnt, null, false); boolean rmvRange = U.safeAbs(RMV_INC) > 1; @@ -907,7 +903,6 @@ private void doTestPutRemove(boolean canGetRow) throws IgniteCheckedException { assertNull(tree.findOne(x)); assertNull(tree.findOne(x2)); - checkIterate(tree, x, x2, null, false); assertNoLocks(); @@ -923,40 +918,6 @@ private void doTestPutRemove(boolean canGetRow) throws IgniteCheckedException { assertNoLocks(); } - /** - * @param tree Tree. - * @param lower Lower bound. - * @param upper Upper bound. - * @param exp Value to find. - * @param expFound {@code True} if value should be found. - * @throws IgniteCheckedException If failed. - */ - private void checkIterate(TestTree tree, long lower, long upper, Long exp, boolean expFound) - throws IgniteCheckedException { - TestTreeRowClosure c = new TestTreeRowClosure(exp); - - tree.iterate(lower, upper, c); - - assertEquals(expFound, c.found); - } - - /** - * @param tree Tree. - * @param lower Lower bound. - * @param upper Upper bound. - * @param c Closure. - * @param expFound {@code True} if value should be found. - * @throws IgniteCheckedException If failed. - */ - private void checkIterateC(TestTree tree, long lower, long upper, TestTreeRowClosure c, boolean expFound) - throws IgniteCheckedException { - c.found = false; - - tree.iterate(lower, upper, c); - - assertEquals(expFound, c.found); - } - /** * @throws IgniteCheckedException If failed. */ @@ -2533,37 +2494,6 @@ public void testFindFirstAndLast() throws IgniteCheckedException { assertNoLocks(); } - /** - * @throws Exception If failed. - */ - @Test - public void testIterate() throws Exception { - MAX_PER_PAGE = 5; - - TestTree tree = createTestTree(true); - - checkIterate(tree, 0L, 100L, null, false); - - for (long idx = 1L; idx <= 10L; ++idx) - tree.put(idx); - - for (long idx = 1L; idx <= 10L; ++idx) - checkIterate(tree, idx, 100L, idx, true); - - checkIterate(tree, 0L, 100L, 1L, true); - - for (long idx = 1L; idx <= 10L; ++idx) - checkIterate(tree, idx, 100L, 10L, true); - - checkIterate(tree, 0L, 100L, 100L, false); - - for (long idx = 1L; idx <= 10L; ++idx) - checkIterate(tree, 0L, 100L, idx, true); - - for (long idx = 0L; idx <= 10L; ++idx) - checkIterate(tree, idx, 11L, -1L, false); - } - /** * @throws Exception If failed. */ @@ -2714,45 +2644,6 @@ private void iterateConcurrentPutRemove(boolean rmvRange) throws Exception { info("Iteration [iter=" + i + ", key=" + findKey + ']'); assertEquals(findKey, tree.findOne(findKey)); - checkIterate(tree, findKey, findKey, findKey, true); - - IgniteInternalFuture getFut = GridTestUtils.runMultiThreadedAsync(new Callable() { - @Override public Void call() throws Exception { - ThreadLocalRandom rnd = ThreadLocalRandom.current(); - - TestTreeRowClosure p = new TestTreeRowClosure(findKey); - - TestTreeRowClosure falseP = new TestTreeRowClosure(-1L); - - int cnt = 0; - - while (!stop.get()) { - int shift = MAX_PER_PAGE > 0 ? rnd.nextInt(MAX_PER_PAGE * 2) : rnd.nextInt(100); - - checkIterateC(tree, findKey, findKey, p, true); - - checkIterateC(tree, findKey - shift, findKey, p, true); - - checkIterateC(tree, findKey - shift, findKey + shift, p, true); - - checkIterateC(tree, findKey, findKey + shift, p, true); - - checkIterateC(tree, -100L, KEYS + 100L, falseP, false); - - cnt++; - } - - info("Done, read count: " + cnt); - - return null; - } - }, 10, "find"); - - asyncRunFut = new GridCompoundFuture<>(); - - asyncRunFut.add(getFut); - - asyncRunFut.markInitialized(); try { U.sleep(100); @@ -2784,8 +2675,6 @@ private void iterateConcurrentPutRemove(boolean rmvRange) throws Exception { stop.set(true); } - asyncRunFut.get(); - stop.set(false); } } @@ -3091,17 +2980,6 @@ else if (op == 3) { last = c.get(); } - - TestTreeFindFirstClosure cl = new TestTreeFindFirstClosure(); - - tree.iterate((long)low, (long)high, cl); - - last = cl.val; - - if (last != null) { - assertTrue(low + " <= " + last + " <= " + high, last >= low); - assertTrue(low + " <= " + last + " <= " + high, last <= high); - } } return null; @@ -3435,53 +3313,6 @@ private static final class LongLeafIO extends BPlusLeafIO { } } - /** - * - */ - static class TestTreeRowClosure implements BPlusTree.TreeRowClosure { - /** */ - private final Long expVal; - - /** */ - private boolean found; - - /** - * @param expVal Value to find or {@code null} to find first. - */ - TestTreeRowClosure(Long expVal) { - this.expVal = expVal; - } - - /** {@inheritDoc} */ - @Override public boolean apply(BPlusTree tree, BPlusIO io, long pageAddr, int idx) - throws IgniteCheckedException { - assert !found; - - found = expVal == null || io.getLookupRow(tree, pageAddr, idx).equals(expVal); - - return !found; - } - } - - /** - * - */ - static class TestTreeFindFirstClosure implements BPlusTree.TreeRowClosure { - /** */ - private Long val; - - - /** {@inheritDoc} */ - @Override public boolean apply(BPlusTree tree, BPlusIO io, long pageAddr, int idx) - throws IgniteCheckedException { - assert val == null; - - val = io.getLookupRow(tree, pageAddr, idx); - - return false; - } - } - /** * */ From 959208870fff736bbcae255b7b79ad1fcd472cc5 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Wed, 22 May 2024 20:45:27 +0300 Subject: [PATCH 21/24] IGNITE-21835 WIP: AbstractDataInnerIO, GridCacheQueryAdapter, IgniteTxHandler. --- .../processors/cache/query/GridCacheQueryAdapter.java | 10 +++------- .../processors/cache/transactions/IgniteTxHandler.java | 2 -- .../processors/cache/tree/AbstractDataInnerIO.java | 2 -- .../processors/cache/tree/AbstractDataLeafIO.java | 2 -- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java index e2a78a2ee743f..5e7b7b77ee108 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java @@ -608,16 +608,12 @@ private CacheQueryFuture execute0(@Nullable IgniteReducer rmtReduce boolean loc = nodes.size() == 1 && F.first(nodes).id().equals(cctx.localNodeId()); - GridCloseableIterator it; - if (loc) - it = qryMgr.scanQueryLocal(this, true); + return qryMgr.scanQueryLocal(this, true); else if (part != null) - it = new ScanQueryFallbackClosableIterator(part, this, qryMgr, cctx); + return new ScanQueryFallbackClosableIterator(part, this, qryMgr, cctx); else - it = qryMgr.scanQueryDistributed(this, nodes); - - return it; + return qryMgr.scanQueryDistributed(this, nodes); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java index 75c4411b9d4ef..2224173cc926e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java @@ -730,8 +730,6 @@ private void sendResponseOnTimeoutOrError(@Nullable IgniteCheckedException e, * @return {@code True} if cache affinity changed and request should be remapped. */ private boolean needRemap(AffinityTopologyVersion rmtVer, GridNearTxPrepareRequest req) { - // TODO IGNITE-6754 check mvcc crd for mvcc enabled txs. - for (IgniteTxEntry e : F.concat(false, req.reads(), req.writes())) { if (!e.context().affinity().isCompatibleWithCurrentTopologyVersion(rmtVer)) return true; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataInnerIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataInnerIO.java index f732833a902d3..a3cabe6e8ed33 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataInnerIO.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataInnerIO.java @@ -56,7 +56,6 @@ protected AbstractDataInnerIO(int type, int ver, boolean canGetRow, int itemSize assert row.cacheId() != CU.UNDEFINED_CACHE_ID : row; PageUtils.putInt(pageAddr, off, row.cacheId()); - off += 4; } } @@ -99,7 +98,6 @@ protected AbstractDataInnerIO(int type, int ver, boolean canGetRow, int itemSize assert cacheId != CU.UNDEFINED_CACHE_ID; PageUtils.putInt(dstPageAddr, off, cacheId); - off += 4; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataLeafIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataLeafIO.java index 61c4c13c3853b..17933f2978035 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataLeafIO.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataLeafIO.java @@ -55,7 +55,6 @@ public AbstractDataLeafIO(int type, int ver, int itemSize) { assert row.cacheId() != CU.UNDEFINED_CACHE_ID; PageUtils.putInt(pageAddr, off, row.cacheId()); - off += 4; } } @@ -83,7 +82,6 @@ public AbstractDataLeafIO(int type, int ver, int itemSize) { assert cacheId != CU.UNDEFINED_CACHE_ID; PageUtils.putInt(dstPageAddr, off, cacheId); - off += 4; } } From 23d6da536f4741a3d3a2b1ec36d55062f79aa1ff Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Thu, 23 May 2024 16:47:56 +0300 Subject: [PATCH 22/24] IGNITE-21835 WIP: Cleanup indexing + CacheDataTree --- .../processors/cache/tree/CacheDataTree.java | 4 +-- .../messages/GridQueryNextPageResponse.java | 34 +------------------ .../apache/ignite/internal/sql/SqlParser.java | 2 +- .../processors/query/h2/QueryParser.java | 1 - .../processors/query/h2/dml/FastUpdate.java | 17 ---------- .../query/h2/dml/UpdatePlanBuilder.java | 31 ++++++----------- .../h2/twostep/GridMapQueryExecutor.java | 11 ++---- 7 files changed, 15 insertions(+), 85 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java index 22eb9014dcf23..94ece35578f27 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java @@ -367,9 +367,7 @@ public CacheDataRowStore rowStore() { assert row.key() != null : row; - cmp = compareKeys(row.key(), link); - - return cmp; + return compareKeys(row.key(), link); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java index 15637de568320..5390c583682b0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/messages/GridQueryNextPageResponse.java @@ -73,9 +73,6 @@ public class GridQueryNextPageResponse implements Message { /** Last page flag. */ private boolean last; - /** Remove mapping flag. */ - private boolean removeMapping; - /** * For {@link Externalizable}. */ @@ -242,12 +239,6 @@ public Collection plainRows() { return false; writer.incrementState(); - - case 10: - if (!writer.writeBoolean("removeMapping", removeMapping)) - return false; - - writer.incrementState(); } return true; @@ -340,15 +331,6 @@ public Collection plainRows() { return false; reader.incrementState(); - - case 10: - removeMapping = reader.readBoolean("removeMapping"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - } return reader.afterMessageRead(GridQueryNextPageResponse.class); @@ -361,7 +343,7 @@ public Collection plainRows() { /** {@inheritDoc} */ @Override public byte fieldsCount() { - return 11; + return 10; } /** @@ -406,20 +388,6 @@ public void last(boolean last) { this.last = last; } - /** - * @param removeMapping Remove mapping flag. - */ - public void removeMapping(boolean removeMapping) { - this.removeMapping = removeMapping; - } - - /** - * @return Remove mapping flag. - */ - public boolean removeMapping() { - return removeMapping; - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridQueryNextPageResponse.class, this, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParser.java b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParser.java index 5ac0e57046ab7..35717a813ee31 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParser.java @@ -251,7 +251,7 @@ private SqlCommand nextCommand0() { return cmd; } else - throw errorUnexpectedToken(lex, BEGIN, COMMIT, CREATE, DROP, ROLLBACK, COPY, SET, ALTER, START, KILL); + throw errorUnexpectedToken(lex, CREATE, DROP, COPY, SET, ALTER, KILL); case QUOTED: case MINUS: diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java index 949568b53fea8..38ca9ea01711e 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java @@ -591,7 +591,6 @@ private QueryParserResultDml prepareDmlStatement(QueryDescriptor planKey, Prepar plan = UpdatePlanBuilder.planForStatement( planKey, stmt, - false, idx, log, forceFillAbsentPKsWithDefaults diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/FastUpdate.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/FastUpdate.java index b052da8c1d16c..9ce39f071530b 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/FastUpdate.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/FastUpdate.java @@ -21,7 +21,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheAdapter; import org.apache.ignite.internal.processors.query.h2.UpdateResult; import org.apache.ignite.internal.processors.query.h2.sql.GridSqlElement; -import org.apache.ignite.lang.IgniteBiTuple; import org.jetbrains.annotations.Nullable; /** @@ -102,20 +101,4 @@ public UpdateResult execute(GridCacheAdapter cache, Object[] args) throws Ignite return res ? UpdateResult.ONE : UpdateResult.ZERO; } - - /** - * - * @param args Query Parameters. - * @return Key and value. - * @throws IgniteCheckedException If failed. - */ - public IgniteBiTuple getRow(Object[] args) throws IgniteCheckedException { - Object key = keyArg.get(args); - - assert key != null; - - Object newVal = newValArg.get(args); - - return new IgniteBiTuple(key, newVal); - } } diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java index c3b26a13adbbe..22e374379ca31 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/UpdatePlanBuilder.java @@ -83,7 +83,7 @@ public final class UpdatePlanBuilder { /** Allow hidden key value columns at the INSERT/UPDATE/MERGE statements (not final for tests). */ private static boolean ALLOW_KEY_VAL_UPDATES = IgniteSystemProperties.getBoolean( IgniteSystemProperties.IGNITE_SQL_ALLOW_KEY_VAL_UPDATES, false); - + /** * Constructor. */ @@ -97,7 +97,6 @@ private UpdatePlanBuilder() { * * @param planKey Plan key. * @param stmt Statement. - * @param mvccEnabled MVCC enabled flag. * @param idx Indexing. * @param forceFillAbsentPKsWithDefaults ForceFillAbsentPKsWithDefaults enabled flag. * @return Update plan. @@ -106,15 +105,14 @@ private UpdatePlanBuilder() { public static UpdatePlan planForStatement( QueryDescriptor planKey, GridSqlStatement stmt, - boolean mvccEnabled, IgniteH2Indexing idx, IgniteLogger log, boolean forceFillAbsentPKsWithDefaults ) throws IgniteCheckedException { if (stmt instanceof GridSqlMerge || stmt instanceof GridSqlInsert) - return planForInsert(planKey, stmt, idx, mvccEnabled, log, forceFillAbsentPKsWithDefaults); + return planForInsert(planKey, stmt, idx, log, forceFillAbsentPKsWithDefaults); else if (stmt instanceof GridSqlUpdate || stmt instanceof GridSqlDelete) - return planForUpdate(planKey, stmt, idx, mvccEnabled, log); + return planForUpdate(planKey, stmt, idx, log); else throw new IgniteSQLException("Unsupported operation: " + stmt.getSQL(), IgniteQueryErrorCode.UNSUPPORTED_OPERATION); @@ -126,7 +124,6 @@ else if (stmt instanceof GridSqlUpdate || stmt instanceof GridSqlDelete) * @param planKey Plan key. * @param stmt INSERT or MERGE statement. * @param idx Indexing. - * @param mvccEnabled Mvcc flag. * @return Update plan. * @throws IgniteCheckedException if failed. */ @@ -135,7 +132,6 @@ private static UpdatePlan planForInsert( QueryDescriptor planKey, GridSqlStatement stmt, IgniteH2Indexing idx, - boolean mvccEnabled, IgniteLogger log, boolean forceFillAbsentPKsWithDefaults ) throws IgniteCheckedException { @@ -232,13 +228,13 @@ else if (stmt instanceof GridSqlMerge) { Set rowKeys = desc.getRowKeyColumnNames(); boolean onlyVisibleColumns = true; - + for (int i = 0; i < cols.length; i++) { GridSqlColumn col = cols[i]; if (!col.column().getVisible()) onlyVisibleColumns = false; - + String colName = col.columnName(); colNames[i] = colName; @@ -270,12 +266,12 @@ else if (stmt instanceof GridSqlMerge) { else hasValProps = true; } - + rowKeys.removeIf(rowKey -> desc.type().property(rowKey).defaultValue() != null); - + boolean fillAbsentPKsWithNullsOrDefaults = type.fillAbsentPKsWithDefaults() || forceFillAbsentPKsWithDefaults; - + if (fillAbsentPKsWithNullsOrDefaults && onlyVisibleColumns && !rowKeys.isEmpty()) { String[] extendedColNames = new String[rowKeys.size() + colNames.length]; int[] extendedColTypes = new int[rowKeys.size() + colTypes.length]; @@ -310,7 +306,6 @@ else if (stmt instanceof GridSqlMerge) { if (rowsNum == 0 && !F.isEmpty(selectSql)) { distributed = checkPlanCanBeDistributed( idx, - mvccEnabled, planKey, selectSql, tbl.dataTable().cacheName(), @@ -389,7 +384,6 @@ private static boolean noQuery(List rows) { * @param planKey Plan key. * @param stmt UPDATE or DELETE statement. * @param idx Indexing. - * @param mvccEnabled MVCC flag. * @return Update plan. * @throws IgniteCheckedException if failed. */ @@ -397,7 +391,6 @@ private static UpdatePlan planForUpdate( QueryDescriptor planKey, GridSqlStatement stmt, IgniteH2Indexing idx, - boolean mvccEnabled, IgniteLogger log ) throws IgniteCheckedException { GridSqlElement target; @@ -493,7 +486,6 @@ else if (stmt instanceof GridSqlDelete) { if (!F.isEmpty(selectSql)) { distributed = checkPlanCanBeDistributed( idx, - mvccEnabled, planKey, selectSql, tbl.dataTable().cacheName(), @@ -530,7 +522,6 @@ else if (stmt instanceof GridSqlDelete) { if (!F.isEmpty(selectSql)) { distributed = checkPlanCanBeDistributed( idx, - mvccEnabled, planKey, selectSql, tbl.dataTable().cacheName(), @@ -650,7 +641,7 @@ public static UpdatePlan planForBulkLoad(SqlBulkLoadCommand cmd, GridH2Table tbl * @param colIdx Column index if key or value is present in columns list, {@code -1} if it's not. * @param hasProps Whether column list affects individual properties of key or value. * @param key Whether supplier should be created for key or for value. - * @param forUpdate {@code FOR UPDATE} flag. + * @param forUpdate {@code true} if called for {@code UPDATE} statement. * @return Closure returning key or value. * @throws IgniteCheckedException If failed. */ @@ -932,7 +923,6 @@ else if (desc.isValueColumn(colId)) { * Checks whether the given update plan can be distributed and returns additional info. * * @param idx Indexing. - * @param mvccEnabled Mvcc flag. * @param planKey Plan key. * @param selectQry Derived select query. * @param cacheName Cache name. @@ -941,14 +931,13 @@ else if (desc.isValueColumn(colId)) { */ private static DmlDistributedPlanInfo checkPlanCanBeDistributed( IgniteH2Indexing idx, - boolean mvccEnabled, QueryDescriptor planKey, String selectQry, String cacheName, IgniteLogger log ) throws IgniteCheckedException { - if ((!mvccEnabled && !planKey.skipReducerOnUpdate()) || planKey.batched()) + if (!planKey.skipReducerOnUpdate() || planKey.batched()) return null; try (H2PooledConnection conn = idx.connections().connection(planKey.schemaName())) { diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java index aa9923b990c8c..3d388561840f2 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java @@ -351,7 +351,8 @@ private void onQueryRequest0( IoStatisticsQueryHelper.startGatheringQueryStatistics(); // Prepare to run queries. - GridCacheContext mainCctx = mainCacheContext(cacheIds); + GridCacheContext mainCctx = !F.isEmpty(cacheIds) ? ctx.cache().context().cacheContext(cacheIds.get(0)) + : null; MapNodeResults nodeRess = resultsForNode(node.id()); @@ -613,14 +614,6 @@ private void onQueryRequest0( } } - /** - * @param cacheIds Cache ids. - * @return Id of the first cache in list, or {@code null} if list is empty. - */ - private GridCacheContext mainCacheContext(List cacheIds) { - return !F.isEmpty(cacheIds) ? ctx.cache().context().cacheContext(cacheIds.get(0)) : null; - } - /** * Releases reserved partitions. * From 6addc7382a34d2747e432bbaed4028df29cf60d8 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Fri, 24 May 2024 14:24:41 +0300 Subject: [PATCH 23/24] IGNITE-21835 WIP. --- docs/_docs/setup.adoc | 2 +- .../cache/query/index/IndexProcessor.java | 4 +-- .../dht/GridDhtTxFinishRequest.java | 4 +-- .../dht/GridDhtTxPrepareFuture.java | 2 +- .../dht/GridDhtTxPrepareRequest.java | 2 +- .../dht/topology/GridDhtLocalPartition.java | 2 +- .../persistence/GridCacheOffheapManager.java | 3 +-- .../resources/META-INF/classnames.properties | 6 ----- ...entAffinityAssignmentWithBaselineTest.java | 1 - .../wal/memtracker/PageMemoryTracker.java | 2 +- ...ntryProcessorExternalizableFailedTest.java | 21 --------------- ...acheEntryProcessorNonSerializableTest.java | 26 ------------------- .../processors/query/h2/IgniteH2Indexing.java | 1 - .../processors/query/h2/dml/DmlAstUtils.java | 2 +- .../query/h2/GridIndexRebuildSelfTest.java | 11 ++------ .../query/h2/QueryDataPageScanTest.java | 1 - 16 files changed, 12 insertions(+), 78 deletions(-) diff --git a/docs/_docs/setup.adoc b/docs/_docs/setup.adoc index a54918b627e2e..cdb204007bd9e 100644 --- a/docs/_docs/setup.adoc +++ b/docs/_docs/setup.adoc @@ -326,7 +326,7 @@ Example of the output: ignite.sh -systemProps IGNITE_AFFINITY_HISTORY_SIZE - [Integer] Maximum size for affinity assignment history. Default is 25. IGNITE_ALLOW_ATOMIC_OPS_IN_TX - [Boolean] Allows atomic operations inside transactions. Default is true. -IGNITE_ALLOW_DML_INSIDE_TRANSACTION - [Boolean] When set to true, Ignite will allow executing DML operation (MERGE|INSERT|UPDATE|DELETE) within transactions for non MVCC mode. Default is false. +IGNITE_ALLOW_DML_INSIDE_TRANSACTION - [Boolean] When set to true, Ignite will allow executing DML operation (MERGE|INSERT|UPDATE|DELETE) within transactions. Default is false. IGNITE_ALLOW_START_CACHES_IN_PARALLEL - [Boolean] Allows to start multiple caches in parallel. Default is true. ... diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexProcessor.java index 4f14bf8b7e582..a0a339c0dc145 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexProcessor.java @@ -490,7 +490,6 @@ private IgniteCheckedException updateIndex( * @param pageMemory Page memory to work with. * @param removeId Global remove id. * @param reuseList Reuse list where free pages should be stored. - * @param mvccEnabled Whether mvcc is enabled. * @throws IgniteCheckedException If failed. */ public void destroyOrphanIndex( @@ -500,8 +499,7 @@ public void destroyOrphanIndex( int grpId, PageMemory pageMemory, GridAtomicLong removeId, - ReuseList reuseList, - boolean mvccEnabled) throws IgniteCheckedException { + ReuseList reuseList) throws IgniteCheckedException { assert ctx.cache().context().database().checkpointLockIsHeldByThread(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index 151f5dd6fcdac..7b8d329fd79c5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -101,7 +101,7 @@ public GridDhtTxFinishRequest() { * @param addDepInfo Deployment info flag. * @param retVal Need return value * @param waitRemoteTxs Wait remote transactions flag - * @param updCntrs Update counters for mvcc Tx. + * @param updCntrs Update counters for Tx. */ public GridDhtTxFinishRequest( UUID nearNodeId, @@ -187,7 +187,7 @@ public GridDhtTxFinishRequest( * @param addDepInfo Deployment info flag. * @param retVal Need return value * @param waitRemoteTxs Wait remote transactions flag - * @param updCntrs Update counters for mvcc Tx. + * @param updCntrs Update counters for Tx. */ public GridDhtTxFinishRequest( UUID nearNodeId, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java index 814a8c6ea9471..97f5e35eb3af1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java @@ -1326,7 +1326,7 @@ private void prepare0() throws IgniteTxRollbackCheckedException { assert entry != null && entry.cached() != null : entry; - // Counter shouldn't be reserved for mvcc, local cache entries, NOOP operations and NOOP transforms. + // Counter shouldn't be reserved for local cache entries, NOOP operations and NOOP transforms. if (!entry.cached().isLocal() && entry.op() != NOOP && !(entry.op() == TRANSFORM && (entry.entryProcessorCalculatedValue() == null || // Possible for txs over cachestore diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index c2f70cfe4e4c5..b5c94db790566 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -132,7 +132,7 @@ public GridDhtTxPrepareRequest() { * @param addDepInfo Deployment info flag. * @param storeWriteThrough Cache store write through flag. * @param retVal Need return value flag - * @param updCntrs Update counters for mvcc Tx. + * @param updCntrs Update counters for Tx. */ public GridDhtTxPrepareRequest( IgniteUuid futId, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java index 245f580dc4d72..55b15ecf3433a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java @@ -951,7 +951,7 @@ public long getAndIncrementUpdateCounter(long delta) { } /** - * Updates MVCC cache update counter on backup node. + * Updates cache update counter on backup node. * * @param start Start position * @param delta Delta. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java index 5a68181575a6f..9643b65c707ac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java @@ -1226,8 +1226,7 @@ public void findAndCleanupLostIndexesForStoppedCache(int cacheId) throws IgniteC grp.groupId(), grp.dataRegion().pageMemory(), globalRemoveId(), - reuseListForIndex(name), - false + reuseListForIndex(name) ); indexStorage.dropIndex(name); diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index 91efdc09cdccb..d64b665f09862 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -737,9 +737,6 @@ org.apache.ignite.internal.processors.cache.GridCacheLoaderWriterStoreFactory org.apache.ignite.internal.processors.cache.GridCacheLockTimeoutException org.apache.ignite.internal.processors.cache.GridCacheLogger org.apache.ignite.internal.processors.cache.GridCacheMapEntry$1 -org.apache.ignite.internal.processors.cache.GridCacheMapEntry$MvccAcquireLockListener -org.apache.ignite.internal.processors.cache.GridCacheMapEntry$MvccRemoveLockListener -org.apache.ignite.internal.processors.cache.GridCacheMapEntry$MvccUpdateLockListener org.apache.ignite.internal.processors.cache.GridCacheMessage org.apache.ignite.internal.processors.cache.GridCacheMultiTxFuture$1 org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate @@ -1121,8 +1118,6 @@ org.apache.ignite.internal.processors.cache.distributed.near.consistency.IgniteI org.apache.ignite.internal.processors.cache.distributed.near.consistency.IgniteTransactionalConsistencyViolationException org.apache.ignite.internal.processors.cache.dr.GridCacheDrExpirationInfo org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo -org.apache.ignite.internal.processors.cache.mvcc.DeadlockProbe -org.apache.ignite.internal.processors.cache.mvcc.ProbedTx org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter$RowData org.apache.ignite.internal.processors.cache.persistence.CheckpointState org.apache.ignite.internal.processors.cache.persistence.CorruptedDataStructureException @@ -1214,7 +1209,6 @@ org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManag org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager$3 org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager$4 org.apache.ignite.internal.processors.cache.query.GridCacheQueryAdapter$1 -org.apache.ignite.internal.processors.cache.query.GridCacheQueryAdapter$MvccTrackingIterator org.apache.ignite.internal.processors.cache.query.GridCacheQueryAdapter$ScanQueryFallbackClosableIterator org.apache.ignite.internal.processors.cache.query.GridCacheQueryDetailMetricsAdapter org.apache.ignite.internal.processors.cache.query.GridCacheQueryFutureAdapter$1 diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/ClientAffinityAssignmentWithBaselineTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/ClientAffinityAssignmentWithBaselineTest.java index 4ae891dbba37e..8afc8fd288f01 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/ClientAffinityAssignmentWithBaselineTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/baseline/ClientAffinityAssignmentWithBaselineTest.java @@ -950,7 +950,6 @@ private void awaitTopology(Throwable e) throws IgniteCheckedException { ClusterTopologyException ex = X.cause(e, ClusterTopologyException.class); IgniteFuture f; - // For now in MVCC case the topology exception doesn't have a remap future. if (ex != null && (f = ex.retryReadyFuture()) != null) f.get(); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTracker.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTracker.java index 9e4f2c84be44f..5886b63209ff4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTracker.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/memtracker/PageMemoryTracker.java @@ -559,7 +559,7 @@ public boolean checkPages(boolean checkAll) throws IgniteCheckedException { * @param checkAll Check all tracked pages, otherwise check until first error. * @param checkPageCnt Check tracked and allocated pages count. This check can be done only if there is no * concurrent modification of pages in the system (for example when checkpointWriteLock is held). Some threads - * (for example MVCC vacuum cleaner) can modify pages even if there is no activity from a users point of view. + * can modify pages even if there is no activity from a users point of view. * @return {@code true} if content of all tracked pages equals to content of these pages in the ignite instance. */ private boolean checkPages(boolean checkAll, boolean checkPageCnt) throws IgniteCheckedException { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java index 75f997073a32b..c4e627b6ead6a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorExternalizableFailedTest.java @@ -559,27 +559,6 @@ private void checkExplicitTxInvoke(Ignite node, IgniteCache cache, TransactionCo } } - /** */ - @SuppressWarnings({"unchecked", "ThrowableNotThrown"}) - private void checkExplicitMvccInvoke(Ignite node, IgniteCache cache, TransactionConcurrency txConcurrency, - TransactionIsolation txIsolation) { - try (final Transaction tx = node.transactions().txStart(txConcurrency, txIsolation)) { - cache.put(KEY, WRONG_VALUE); - - GridTestUtils.assertThrowsWithCause(new Callable() { - @Override public Object call() throws Exception { - cache.invoke(KEY, createEntryProcessor()); - - fail("Should never happened."); - - tx.commit(); - - return null; - } - }, UnsupportedOperationException.class); - } - } - /** * @return Entry processor. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java index 277172c8b95ef..c8ea0b44df142 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheEntryProcessorNonSerializableTest.java @@ -411,32 +411,6 @@ private void checkTxInvoke(Ignite node, IgniteCache cache, TransactionConcurrenc } } - /** - * @param node Grid node. - * @param cache Node cache. - * @param txConcurrency Transaction concurrency. - * @param txIsolation Transaction isolation. - */ - @SuppressWarnings({"unchecked", "ThrowableNotThrown"}) - private void checkMvccInvoke(Ignite node, IgniteCache cache, TransactionConcurrency txConcurrency, - TransactionIsolation txIsolation) { - try (final Transaction tx = node.transactions().txStart(txConcurrency, txIsolation)) { - cache.put(KEY, WRONG_VALUE); - - GridTestUtils.assertThrowsWithCause(new Callable() { - @Override public Object call() { - cache.invoke(KEY, new NonSerialazibleEntryProcessor()); - - fail("Should never happened."); - - tx.commit(); - - return null; - } - }, NotSerializableException.class); - } - } - /** * @return Cache configuration. */ diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java index eb06429ad4b13..f355dd7091922 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java @@ -1946,7 +1946,6 @@ private List>> executeUpdateDistributed( GridCacheContext cctx = plan.cacheContext(); - // For MVCC case, let's enlist batch elements one by one. if (plan.hasRows() && plan.mode() == UpdateMode.INSERT) { CacheOperationContext opCtx = DmlUtils.setKeepBinaryContext(cctx); diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlAstUtils.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlAstUtils.java index 84d70ecdb5604..99910b49998aa 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlAstUtils.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/dml/DmlAstUtils.java @@ -362,7 +362,7 @@ public static GridSqlSelect selectForUpdate(GridSqlUpdate update) { GridSqlElement where = update.where(); - // On no MVCC mode we cannot use lazy mode when UPDATE query contains index with updated columns + // We cannot use lazy mode when UPDATE query contains index with updated columns // and that index may be chosen to scan by WHERE condition // because in this case any rows update may be updated several times. // e.g. in the cases below we cannot use lazy mode: diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java index 3cc5afa954c1c..6f66104683582 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexRebuildSelfTest.java @@ -139,15 +139,8 @@ public class GridIndexRebuildSelfTest extends DynamicIndexAbstractSelfTest { *
  • Restart the node and block index rebuild;
  • *
  • For half of the keys do cache puts before corresponding key * has been processed during index rebuild;
  • - *
  • Check that: - *
      - *
    • For MVCC case: some keys have all versions that existed before restart, while those - * updated concurrently have only put version (one with mark value -1) - * and latest version present before node restart;
    • - *
    • For non MVCC case: keys updated concurrently must have mark values of -1 despite that - * index rebuild for them has happened after put.
    • - *
    - *
  • + *
  • Check that keys updated concurrently must have mark values of -1 despite that + * index rebuild for them has happened after put.
  • *

    * @throws Exception if failed. */ diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/QueryDataPageScanTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/QueryDataPageScanTest.java index 095b16448ab1e..0f424a50d4416 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/QueryDataPageScanTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/QueryDataPageScanTest.java @@ -214,7 +214,6 @@ private void doTestConcurrentUpdates() throws Exception { if (accountId1 == accountId2) continue; - // Sort to avoid MVCC deadlock. if (accountId1 > accountId2) { long tmp = accountId1; accountId1 = accountId2; From b0f720b65f243936005fb27be41587aa841d2914 Mon Sep 17 00:00:00 2001 From: Ilya Shishkov Date: Fri, 24 May 2024 15:49:01 +0300 Subject: [PATCH 24/24] IGNITE-21835 WIP: CacheDataRowAdapter. --- .../processors/cache/persistence/CacheDataRowAdapter.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java index 53266cef84319..dce8064c7d4fa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java @@ -376,8 +376,6 @@ protected IncompleteObject readIncomplete( long nextLink = data.nextLink(); - int hdrLen = 0; - if (incomplete == null) { if (nextLink == 0) { // Fast path for a single page row. @@ -389,8 +387,8 @@ protected IncompleteObject readIncomplete( ByteBuffer buf = wrapPointer(pageAddr, pageSize); - int off = data.offset() + hdrLen; - int payloadSize = data.payloadSize() - hdrLen; + int off = data.offset(); + int payloadSize = data.payloadSize(); buf.position(off); buf.limit(off + payloadSize);