IGNITE-5869 Client hangs in case of binary configuration compact footer of client node differs from server node
Signed-off-by: Andrey Gura <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ccc334d6 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ccc334d6 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ccc334d6 Branch: refs/heads/ignite-5896 Commit: ccc334d62de5b51f5d31d7064d1de4b0245e8232 Parents: 72608a5 Author: Evgeny Stanilovskiy <[email protected]> Authored: Fri Sep 1 15:46:57 2017 +0300 Committer: Andrey Gura <[email protected]> Committed: Fri Sep 1 17:25:53 2017 +0300 ---------------------------------------------------------------------- .../ignite/spi/discovery/tcp/ServerImpl.java | 12 ++- ...pClientDiscoveryMarshallerCheckSelfTest.java | 85 ++++++++++++++++++-- 2 files changed, 89 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/ccc334d6/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java index 5d7e39e..7dc94d3 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java @@ -3534,7 +3534,7 @@ class ServerImpl extends TcpDiscoveryImpl { try { trySendMessageDirectly(node, - new TcpDiscoveryCheckFailedMessage(locNodeId, err.sendMessage())); + new TcpDiscoveryCheckFailedMessage(err.nodeId(), err.sendMessage())); } catch (IgniteSpiException e) { if (log.isDebugEnabled()) @@ -6073,6 +6073,16 @@ class ServerImpl extends TcpDiscoveryImpl { else { ignored = true; + ClientMessageWorker worker = clientMsgWorkers.get(msg.creatorNodeId()); + + if (worker != null) { + msg.verify(getLocalNodeId()); + worker.addMessage(msg); + } + else if (log.isDebugEnabled()) + log.debug("Failed to find client message worker " + + "[clientNode=" + msg.creatorNodeId() + ']'); + state = spiState; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/ccc334d6/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java index 1a88b11..f88a9ea 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java @@ -17,8 +17,11 @@ package org.apache.ignite.spi.discovery.tcp; +import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.configuration.BinaryConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; import org.apache.ignite.spi.IgniteSpiException; @@ -33,19 +36,41 @@ public class TcpClientDiscoveryMarshallerCheckSelfTest extends GridCommonAbstrac /** */ private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + /** */ + private boolean testFooter; + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); - if (igniteInstanceName.endsWith("0")) - cfg.setMarshaller(new JdkMarshaller()); - else { - cfg.setClientMode(true); - + if (testFooter) { cfg.setMarshaller(new BinaryMarshaller()); + + TcpDiscoverySpi spi = new TcpDiscoverySpi(); + + spi.setJoinTimeout(-1); // IGNITE-605, and further tests limitation bypass + + cfg.setDiscoverySpi(spi); + + if (igniteInstanceName.endsWith("0")) { + cfg.setClientMode(true); + BinaryConfiguration bc = new BinaryConfiguration(); + bc.setCompactFooter(false); + cfg.setBinaryConfiguration(bc); + } } + else { + if (igniteInstanceName.endsWith("0")) + cfg.setMarshaller(new JdkMarshaller()); + else { + cfg.setClientMode(true); + cfg.setMarshaller(new BinaryMarshaller()); + } - cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder)); + TcpDiscoverySpi spi = new TcpDiscoverySpi().setIpFinder(ipFinder); + + cfg.setDiscoverySpi(spi); + } return cfg; } @@ -73,4 +98,50 @@ public class TcpClientDiscoveryMarshallerCheckSelfTest extends GridCommonAbstrac assertTrue(ex.getMessage().contains("Local node's marshaller differs from remote node's marshaller")); } } -} \ No newline at end of file + + /** + * Starts client-server grid with different binary configurations. + * + * @throws Exception If failed. + */ + private void clientServerInconsistentConfigFail(boolean multiNodes) throws Exception { + testFooter = true; + + IgniteEx ig0 = startGrid(1); + IgniteCache ic = ig0.getOrCreateCache("cahe_name"); + if (multiNodes) + startGrid(2); + + try { + IgniteEx ig = startGrid(0); + + for (String c : ig.cacheNames()) + System.out.println(c); + + fail("Expected SPI exception was not thrown, multiNodes=" + multiNodes); + } catch (IgniteCheckedException expect) { + Throwable ex = expect.getCause().getCause(); + + assertTrue(ex instanceof IgniteSpiException); + assertTrue("Catched exception: " + ex.getMessage(), ex.getMessage().contains("Local node's binary " + + "configuration is not equal to remote node's binary configuration")); + } finally { + stopAllGrids(); + } + } + + /** + * @throws Exception If failed. + */ + public void testInconsistentFooterConfigSingle() throws Exception { + clientServerInconsistentConfigFail(false); + } + + /** + * @throws Exception If failed. + */ + public void testInconsistentFooterConfigMulti() throws Exception { + for (int i = 0; i < 10; ++i) + clientServerInconsistentConfigFail(true); + } +}
