(ignite-3) branch main updated: IGNITE-20886 Don't unregister indexes on CatalogEvent#INDEX_DROP (#2849)

2023-11-17 Thread tkalkirill
This is an automated email from the ASF dual-hosted git repository.

tkalkirill pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
 new 9462367a70 IGNITE-20886 Don't unregister indexes on 
CatalogEvent#INDEX_DROP (#2849)
9462367a70 is described below

commit 9462367a70a01b9086793dff0e9f13e1dde1e382
Author: Kirill Tkalenko 
AuthorDate: Fri Nov 17 16:40:07 2023 +0300

IGNITE-20886 Don't unregister indexes on CatalogEvent#INDEX_DROP (#2849)
---
 .../apache/ignite/internal/index/IndexManager.java | 10 +---
 .../ignite/internal/index/IndexManagerTest.java| 30 +++---
 .../internal/index/TestIndexManagementUtils.java   |  4 +++
 3 files changed, 31 insertions(+), 13 deletions(-)

diff --git 
a/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java
 
b/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java
index 3d132204e5..c5a10da1e1 100644
--- 
a/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java
+++ 
b/modules/index/src/main/java/org/apache/ignite/internal/index/IndexManager.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.index;
 import static java.util.concurrent.CompletableFuture.allOf;
 import static java.util.concurrent.CompletableFuture.failedFuture;
 import static 
org.apache.ignite.internal.catalog.events.CatalogEvent.INDEX_CREATE;
-import static 
org.apache.ignite.internal.catalog.events.CatalogEvent.INDEX_DROP;
 import static org.apache.ignite.internal.util.IgniteUtils.inBusyLock;
 import static org.apache.ignite.internal.util.IgniteUtils.inBusyLockAsync;
 
@@ -135,14 +134,6 @@ public class IndexManager implements IgniteComponent {
 return onIndexCreate((CreateIndexEventParameters) parameters);
 });
 
-catalogService.listen(INDEX_DROP, (parameters, exception) -> {
-if (exception != null) {
-return failedFuture(exception);
-}
-
-return onIndexDrop((DropIndexEventParameters) parameters);
-});
-
 LOG.info("Index manager started");
 }
 
@@ -179,6 +170,7 @@ public class IndexManager implements IgniteComponent {
 return 
mvTableStoragesByIdVv.get(causalityToken).thenApply(mvTableStoragesById -> 
mvTableStoragesById.get(tableId));
 }
 
+// TODO: IGNITE-20121 Unregister index only before we physically start 
deleting the index before truncate catalog
 private CompletableFuture onIndexDrop(DropIndexEventParameters 
parameters) {
 int indexId = parameters.indexId();
 int tableId = parameters.tableId();
diff --git 
a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java
 
b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java
index 1b38573f37..d146da3172 100644
--- 
a/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java
+++ 
b/modules/index/src/test/java/org/apache/ignite/internal/index/IndexManagerTest.java
@@ -22,9 +22,12 @@ import static 
org.apache.ignite.internal.catalog.CatalogService.DEFAULT_SCHEMA_N
 import static 
org.apache.ignite.internal.catalog.CatalogService.DEFAULT_ZONE_NAME;
 import static 
org.apache.ignite.internal.catalog.commands.CatalogUtils.DEFAULT_DATA_REGION;
 import static 
org.apache.ignite.internal.index.TestIndexManagementUtils.COLUMN_NAME;
+import static 
org.apache.ignite.internal.index.TestIndexManagementUtils.INDEX_NAME;
 import static 
org.apache.ignite.internal.index.TestIndexManagementUtils.NODE_NAME;
 import static 
org.apache.ignite.internal.index.TestIndexManagementUtils.TABLE_NAME;
+import static 
org.apache.ignite.internal.index.TestIndexManagementUtils.createIndex;
 import static 
org.apache.ignite.internal.index.TestIndexManagementUtils.createTable;
+import static 
org.apache.ignite.internal.index.TestIndexManagementUtils.dropIndex;
 import static org.apache.ignite.internal.table.TableTestUtils.createHashIndex;
 import static org.apache.ignite.internal.table.TableTestUtils.dropTable;
 import static org.apache.ignite.internal.table.TableTestUtils.getTableIdStrict;
@@ -38,10 +41,15 @@ import static 
org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyLong;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.LongFunction;
 import org.apache.ignite.internal.catalog.CatalogManager;
 import org.apache.ignite.internal.catalog.CatalogManagerImpl;
@@ -73,9 +81,7 @@ import org.junit.jupiter.api.AfterEach;
 import org.jun

(ignite) branch ignite-2.16 updated: IGNITE-20759 Fix writing post-handshake message in NIO server (#11036)

2023-11-17 Thread ivandasch
This is an automated email from the ASF dual-hosted git repository.

ivandasch pushed a commit to branch ignite-2.16
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/ignite-2.16 by this push:
 new 363031c8fa5  IGNITE-20759 Fix writing post-handshake message in NIO 
server (#11036)
363031c8fa5 is described below

commit 363031c8fa5ffdc805feac45086785dadc1f1cd9
Author: Ivan Daschinskiy 
AuthorDate: Fri Nov 17 14:48:40 2023 +0300

 IGNITE-20759 Fix writing post-handshake message in NIO server (#11036)

(cherry picked from commit d02626640e05772ca61faabe7f9c1718016bc264)
---
 .../ignite/internal/util/nio/GridNioServer.java|   3 +-
 .../internal/util/nio/ssl/BlockingSslHandler.java  |   4 +-
 .../tcp/internal/GridNioServerWrapper.java |   6 -
 .../tcp/internal/TcpHandshakeExecutor.java | 367 -
 .../tcp/GridTcpCommunicationSpiAbstractTest.java   |   2 +-
 .../tcp/TcpCommunicationHandshakeTimeoutTest.java  |   3 +-
 6 files changed, 224 insertions(+), 161 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
index 695eaed5228..fc23516c8af 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
@@ -1425,7 +1425,8 @@ public class GridNioServer {
 try {
 boolean writeFinished = writeSslSystem(ses, sockCh);
 
-if (!handshakeFinished) {
+// If post-handshake message is not written fully (possible on 
JDK 17), we should retry.
+if (!handshakeFinished || !writeFinished) {
 if (writeFinished)
 stopPollingForWrite(key, ses);
 
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
index 40ded3c314b..1da7c8ab62a 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
@@ -85,8 +85,8 @@ public class BlockingSslHandler {
 SocketChannel ch,
 boolean directBuf,
 ByteOrder order,
-IgniteLogger log)
-throws SSLException {
+IgniteLogger log
+) {
 this.ch = ch;
 this.log = log;
 this.sslEngine = sslEngine;
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java
 
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java
index 8302b1c9508..187b7fc3edb 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java
@@ -1186,12 +1186,6 @@ public class GridNioServerWrapper {
 try {
 return tcpHandshakeExecutor.tcpHandshake(ch, rmtNodeId, sslMeta, 
msg);
 }
-catch (IOException e) {
-if (log.isDebugEnabled())
-log.debug("Failed to read from channel: " + e);
-
-throw new IgniteCheckedException("Failed to read from channel.", 
e);
-}
 finally {
 if (!timeoutObject.cancel())
 throw handshakeTimeoutException();
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
 
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
index cb5e256503e..387ceed0fdb 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
@@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.channels.SocketChannel;
 import java.util.UUID;
+import javax.net.ssl.SSLException;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.internal.util.nio.ssl.BlockingSslHandler;
@@ -67,228 +68,296 @@ public class TcpHandshakeExecutor {
  * @param ch Socket channel which using for handshake.
  * @param rmtNodeId Expected remote node.
  * @param sslMeta Required data for ssl.
- * @param msg Handshake message which should be send during handshake.
+ * @param msg Handshake message which should be sent during handshake.
  * @return Handshake response from predefined variants from {@link 
RecoveryLastReceivedMessage}.
- * @throws IgniteCheckedException

(ignite) branch master updated: IGNITE-20759 Fix writing post-handshake message in NIO server (#11036)

2023-11-17 Thread ivandasch
This is an automated email from the ASF dual-hosted git repository.

ivandasch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
 new d02626640e0  IGNITE-20759 Fix writing post-handshake message in NIO 
server (#11036)
d02626640e0 is described below

commit d02626640e05772ca61faabe7f9c1718016bc264
Author: Ivan Daschinskiy 
AuthorDate: Fri Nov 17 14:48:40 2023 +0300

 IGNITE-20759 Fix writing post-handshake message in NIO server (#11036)
---
 .../ignite/internal/util/nio/GridNioServer.java|   3 +-
 .../internal/util/nio/ssl/BlockingSslHandler.java  |   4 +-
 .../tcp/internal/GridNioServerWrapper.java |   6 -
 .../tcp/internal/TcpHandshakeExecutor.java | 367 -
 .../tcp/GridTcpCommunicationSpiAbstractTest.java   |   2 +-
 .../tcp/TcpCommunicationHandshakeTimeoutTest.java  |   3 +-
 6 files changed, 224 insertions(+), 161 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
index 695eaed5228..fc23516c8af 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
@@ -1425,7 +1425,8 @@ public class GridNioServer {
 try {
 boolean writeFinished = writeSslSystem(ses, sockCh);
 
-if (!handshakeFinished) {
+// If post-handshake message is not written fully (possible on 
JDK 17), we should retry.
+if (!handshakeFinished || !writeFinished) {
 if (writeFinished)
 stopPollingForWrite(key, ses);
 
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
index 40ded3c314b..1da7c8ab62a 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
@@ -85,8 +85,8 @@ public class BlockingSslHandler {
 SocketChannel ch,
 boolean directBuf,
 ByteOrder order,
-IgniteLogger log)
-throws SSLException {
+IgniteLogger log
+) {
 this.ch = ch;
 this.log = log;
 this.sslEngine = sslEngine;
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java
 
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java
index 8302b1c9508..187b7fc3edb 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java
@@ -1186,12 +1186,6 @@ public class GridNioServerWrapper {
 try {
 return tcpHandshakeExecutor.tcpHandshake(ch, rmtNodeId, sslMeta, 
msg);
 }
-catch (IOException e) {
-if (log.isDebugEnabled())
-log.debug("Failed to read from channel: " + e);
-
-throw new IgniteCheckedException("Failed to read from channel.", 
e);
-}
 finally {
 if (!timeoutObject.cancel())
 throw handshakeTimeoutException();
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
 
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
index cb5e256503e..387ceed0fdb 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
@@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.channels.SocketChannel;
 import java.util.UUID;
+import javax.net.ssl.SSLException;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.internal.util.nio.ssl.BlockingSslHandler;
@@ -67,228 +68,296 @@ public class TcpHandshakeExecutor {
  * @param ch Socket channel which using for handshake.
  * @param rmtNodeId Expected remote node.
  * @param sslMeta Required data for ssl.
- * @param msg Handshake message which should be send during handshake.
+ * @param msg Handshake message which should be sent during handshake.
  * @return Handshake response from predefined variants from {@link 
RecoveryLastReceivedMessage}.
- * @throws IgniteCheckedException If not related to IO exception happened.
- * @throws IOException If reading or writ

(ignite-3) branch main updated: IGNITE-20825 Fix ItDurableFinishTest.testCoordinatorMissedResponse flakiness (#2835)

2023-11-17 Thread sk0x50
This is an automated email from the ASF dual-hosted git repository.

sk0x50 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
 new 901b9168d6 IGNITE-20825 Fix 
ItDurableFinishTest.testCoordinatorMissedResponse  flakiness (#2835)
901b9168d6 is described below

commit 901b9168d6ddfc2044c6dca5e65072c6d5da1fa0
Author: Cyrill 
AuthorDate: Fri Nov 17 11:54:45 2023 +0300

IGNITE-20825 Fix ItDurableFinishTest.testCoordinatorMissedResponse  
flakiness (#2835)

Co-authored-by: Kirill Sizov 
---
 .../ignite/internal/table/ItDurableFinishTest.java | 24 ++
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItDurableFinishTest.java
 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItDurableFinishTest.java
index 7060c8abef..606165ad51 100644
--- 
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItDurableFinishTest.java
+++ 
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItDurableFinishTest.java
@@ -27,6 +27,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
@@ -48,7 +50,6 @@ import org.apache.ignite.network.NetworkMessage;
 import org.apache.ignite.table.Tuple;
 import org.apache.ignite.tx.TransactionException;
 import org.jetbrains.annotations.Nullable;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 
 /**
@@ -59,6 +60,8 @@ public class ItDurableFinishTest extends 
ClusterPerTestIntegrationTest {
 
 private static final String TABLE_NAME = "TEST_FINISH";
 
+private final Collection> futures = new ArrayList<>();
+
 private void createTestTableWith3Replicas() {
 String zoneSql = "create zone test_zone with partitions=1, replicas=3";
 String sql = "create table " + TABLE_NAME + " (key int primary key, 
val varchar(20))"
@@ -178,9 +181,12 @@ public class ItDurableFinishTest extends 
ClusterPerTestIntegrationTest {
 }
 
 @Test
-@Disabled("https://issues.apache.org/jira/browse/IGNITE-20825";)
 void testCoordinatorMissedResponse() throws ExecutionException, 
InterruptedException {
 testFinishRow(this::coordinatorMissedResponse, this::commitRow);
+
+for (CompletableFuture future : futures) {
+assertThat(future, willCompleteSuccessfully());
+}
 }
 
 private void coordinatorMissedResponse(
@@ -197,15 +203,17 @@ public class ItDurableFinishTest extends 
ClusterPerTestIntegrationTest {
 if (networkMessage instanceof TxFinishReplicaRequest && 
!messageHandled.get()) {
 messageHandled.set(true);
 
-logger().info("Pausing message handling: {}.", networkMessage);
+logger().info("Drop message [msg={}].", networkMessage);
 
-CompletableFuture finish = 
coordinatorMessaging.invoke(s, networkMessage, 3000);
-
-assertThat(finish, willCompleteSuccessfully());
+// Here we act as a man-in-the-middle: the finish request is 
intercepted and further routed to
+// the commit partition as normal. The coordinator instead 
fails with a timeout (see DefaultMessagingService.invoke0)
+// and has to retry the finish request according to the 
durable finish logic.
+// The test checks that the second coordinator attempt to 
commit succeeds
+// and the server is able to apply a COMMIT over COMMIT 
without exceptions.
 
-finish.join();
+CompletableFuture finish = 
coordinatorMessaging.invoke(s, networkMessage, 3000);
 
-logger().info("Continue message handling: {}.", 
networkMessage);
+futures.add(finish);
 
 return true;
 }



(ignite) branch master updated: IGNITE-20758 Fix LongDestroyDurableBackgroundTaskTest (#11026)

2023-11-17 Thread dpavlov
This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
 new 461977b82ea IGNITE-20758 Fix LongDestroyDurableBackgroundTaskTest 
(#11026)
461977b82ea is described below

commit 461977b82ea962a18f98d7264d801c2b2aa04378
Author: Ilya Shishkov 
AuthorDate: Fri Nov 17 11:22:32 2023 +0300

IGNITE-20758 Fix LongDestroyDurableBackgroundTaskTest (#11026)
---
 .../cache/persistence/db/LongDestroyDurableBackgroundTaskTest.java   | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/LongDestroyDurableBackgroundTaskTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/LongDestroyDurableBackgroundTaskTest.java
index 3220bc8f41e..d3faef4cc4c 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/LongDestroyDurableBackgroundTaskTest.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/LongDestroyDurableBackgroundTaskTest.java
@@ -371,7 +371,6 @@ public class LongDestroyDurableBackgroundTaskTest extends 
GridCommonAbstractTest
 
 taskArg.caches(new String[]{"SQL_PUBLIC_T"});
 taskArg.nodeIds(nodeIds.toArray(EMPTY_UUIDS));
-taskArg.checkFirst(0);
 taskArg.checkThrough(1);
 taskArg.checkCrc(true);
 taskArg.checkSizes(true);