You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/10/23 22:19:26 UTC
[GitHub] [geode] gesterzhou opened a new pull request #5665: GEODE-8651: MsgReader's readHeader and readMessage should be synchron…
gesterzhou opened a new pull request #5665:
URL: https://github.com/apache/geode/pull/5665
…ized
Co-authored-by: Anil <ag...@pivotal.io>
Co-authored-by: Darrel Schneider <da...@vmware.com>
Co-authored-by: Bill Burcham <bi...@gmail.com>
Co-authored-by: Ernie Burghardt <eb...@pivotal.io>
Thank you for submitting a contribution to Apache Geode.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
- [ ] Has your PR been rebased against the latest commit within the target branch (typically `develop`)?
- [ ] Is your initial contribution a single, squashed commit?
- [ ] Does `gradlew build` run cleanly?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
### Note:
Please ensure that once the PR is submitted, check Concourse for build issues and
submit an update to your PR as soon as possible. If you need help, please send an
email to dev@geode.apache.org.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] dschneider-pivotal commented on a change in pull request #5665: GEODE-8651: MsgReader's readHeader and readMessage should be synchron…
Posted by GitBox <gi...@apache.org>.
dschneider-pivotal commented on a change in pull request #5665:
URL: https://github.com/apache/geode/pull/5665#discussion_r512899430
##########
File path: geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTest.java
##########
@@ -113,4 +114,35 @@ public void connectTimeoutIsShortWhenAlerting() throws UnknownHostException {
assertThat(connection.getP2PConnectTimeout(distributionConfig)).isEqualTo(100);
});
}
+
+ @Test
+ public void notifyHandshakeWaiterShouldPositionByteBufferOnlyOnce() throws Exception {
+ ConnectionTable connectionTable = mock(ConnectionTable.class);
+ Distribution distribution = mock(Distribution.class);
+ DistributionManager distributionManager = mock(DistributionManager.class);
+ DMStats dmStats = mock(DMStats.class);
+ CancelCriterion stopper = mock(CancelCriterion.class);
+ SocketCloser socketCloser = mock(SocketCloser.class);
+ TCPConduit tcpConduit = mock(TCPConduit.class);
+
+ when(connectionTable.getBufferPool()).thenReturn(new BufferPool(dmStats));
+ when(connectionTable.getConduit()).thenReturn(tcpConduit);
+ when(connectionTable.getDM()).thenReturn(distributionManager);
+ when(connectionTable.getSocketCloser()).thenReturn(socketCloser);
+ when(distributionManager.getDistribution()).thenReturn(distribution);
+ when(stopper.cancelInProgress()).thenReturn(null);
+ when(tcpConduit.getCancelCriterion()).thenReturn(stopper);
+ when(tcpConduit.getDM()).thenReturn(distributionManager);
+ when(tcpConduit.getSocketId()).thenReturn(new InetSocketAddress(getLocalHost(), 10337));
+ when(tcpConduit.getStats()).thenReturn(dmStats);
+
+ SocketChannel channel = SocketChannel.open();
+
+ Connection connection = new Connection(connectionTable, channel.socket());
+ connection = spy(connection);
+ connection.setSharedUnorderedForTest();
+ connection.run();
+
+ verify(connection, times(1)).getConduit();
Review comment:
I don't like that we verify that getConduit is called 1 time. I understand after looking at the code but it seems rather indirect logically and brittle. I would prefer that you extract the block of code in notifyHandshakeWaiter starting at line 810 into a method named "clearSSLInputBuffer". Then this test can assert that clearSSLInputBuffer is only called 1 time. This would be much clearer and less brittle and would not increase the diffs much
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] gesterzhou commented on a change in pull request #5665: GEODE-8651: MsgReader's readHeader and readMessage should be synchron…
Posted by GitBox <gi...@apache.org>.
gesterzhou commented on a change in pull request #5665:
URL: https://github.com/apache/geode/pull/5665#discussion_r512928045
##########
File path: geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTest.java
##########
@@ -113,4 +114,35 @@ public void connectTimeoutIsShortWhenAlerting() throws UnknownHostException {
assertThat(connection.getP2PConnectTimeout(distributionConfig)).isEqualTo(100);
});
}
+
+ @Test
+ public void notifyHandshakeWaiterShouldPositionByteBufferOnlyOnce() throws Exception {
+ ConnectionTable connectionTable = mock(ConnectionTable.class);
+ Distribution distribution = mock(Distribution.class);
+ DistributionManager distributionManager = mock(DistributionManager.class);
+ DMStats dmStats = mock(DMStats.class);
+ CancelCriterion stopper = mock(CancelCriterion.class);
+ SocketCloser socketCloser = mock(SocketCloser.class);
+ TCPConduit tcpConduit = mock(TCPConduit.class);
+
+ when(connectionTable.getBufferPool()).thenReturn(new BufferPool(dmStats));
+ when(connectionTable.getConduit()).thenReturn(tcpConduit);
+ when(connectionTable.getDM()).thenReturn(distributionManager);
+ when(connectionTable.getSocketCloser()).thenReturn(socketCloser);
+ when(distributionManager.getDistribution()).thenReturn(distribution);
+ when(stopper.cancelInProgress()).thenReturn(null);
+ when(tcpConduit.getCancelCriterion()).thenReturn(stopper);
+ when(tcpConduit.getDM()).thenReturn(distributionManager);
+ when(tcpConduit.getSocketId()).thenReturn(new InetSocketAddress(getLocalHost(), 10337));
+ when(tcpConduit.getStats()).thenReturn(dmStats);
+
+ SocketChannel channel = SocketChannel.open();
+
+ Connection connection = new Connection(connectionTable, channel.socket());
+ connection = spy(connection);
+ connection.setSharedUnorderedForTest();
+ connection.run();
+
+ verify(connection, times(1)).getConduit();
Review comment:
fixed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] kohlmu-pivotal commented on pull request #5665: GEODE-8651: MsgReader's readHeader and readMessage should be synchron…
Posted by GitBox <gi...@apache.org>.
kohlmu-pivotal commented on pull request #5665:
URL: https://github.com/apache/geode/pull/5665#issuecomment-715627743
I would like to also point out that it does not make sense that any of the people that were added to review (except @bschuchardt ) to review this code. As the rest have all be names co-authors, which in reality does sort of defeat the point if they review what they authored
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] gesterzhou commented on pull request #5665: GEODE-8651: MsgReader's readHeader and readMessage should be synchron…
Posted by GitBox <gi...@apache.org>.
gesterzhou commented on pull request #5665:
URL: https://github.com/apache/geode/pull/5665#issuecomment-715628486
We have some tests to verify it. However, we are adding unit test, on the way.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] gesterzhou merged pull request #5665: GEODE-8651: MsgReader's readHeader and readMessage should be synchron…
Posted by GitBox <gi...@apache.org>.
gesterzhou merged pull request #5665:
URL: https://github.com/apache/geode/pull/5665
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] dschneider-pivotal commented on pull request #5665: GEODE-8651: MsgReader's readHeader and readMessage should be synchron…
Posted by GitBox <gi...@apache.org>.
dschneider-pivotal commented on pull request #5665:
URL: https://github.com/apache/geode/pull/5665#issuecomment-716704688
As far as the extra synchronization goes in readAck, I agree that if the only place that was concurrently modifying this buffer was the extra notifyHandshakeWaiter then this sync is not needed. But from the viewpoint of readAck, it currently calls readHeader and readMessage or readChunk. All these methods end up synchronizing to protect the buffer. If that sync is needed then it is also needed at the readAck level. readAck is incorrect to allow another thread to modify the buffer between the readHeader and readMessage calls. It is hard to prove that no other threads could concurrently modify the buffer which is why I think we added the new ioFilter.getSynchObject. I'm arguing that if we are going to have getSynchObject then readAck should synchronize on it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] dschneider-pivotal commented on pull request #5665: GEODE-8651: MsgReader's readHeader and readMessage should be synchron…
Posted by GitBox <gi...@apache.org>.
dschneider-pivotal commented on pull request #5665:
URL: https://github.com/apache/geode/pull/5665#issuecomment-716697054
@bschuchardt when you said to move the buffer-clearing to readAck did you mean the code in notifyHandshakeWaiter that sets the position and limit to 0 if SSL? If so I don't understand what that has todo with readAck. notifyHandshakeWaiter is called to notify the thread that is stuck in waitForHandshake that it no longer needs to wait. I don't understand why in SSL we need to clear the buffer before doing this (we thought you might know why) but it does not seem to be connected with reading a direct ack which is what readAck does.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] kohlmu-pivotal edited a comment on pull request #5665: GEODE-8651: MsgReader's readHeader and readMessage should be synchron…
Posted by GitBox <gi...@apache.org>.
kohlmu-pivotal edited a comment on pull request #5665:
URL: https://github.com/apache/geode/pull/5665#issuecomment-715627743
I would like to also point out that it does not make sense that any of the people that were added to review (except @bschuchardt ) to review this code. As the rest have all be named as co-authors, which in reality does sort of defeat the point if they review what they authored
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] gesterzhou commented on pull request #5665: GEODE-8651: MsgReader's readHeader and readMessage should be synchron…
Posted by GitBox <gi...@apache.org>.
gesterzhou commented on pull request #5665:
URL: https://github.com/apache/geode/pull/5665#issuecomment-717365736
> Do we have any tests that reproduce the behavior that we are trying to fix with this synchronization?
>
> Are there any existing tests that reproduce this error?
>
> If none of the above are true, could you please update ticket with tests that prove that this problem has been resolved.
The test is added.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [geode] kirklund commented on pull request #5665: GEODE-8651: MsgReader's readHeader and readMessage should be synchron…
Posted by GitBox <gi...@apache.org>.
kirklund commented on pull request #5665:
URL: https://github.com/apache/geode/pull/5665#issuecomment-717381294
Ooops, I meant "The test has been added"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org