Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEODE-8706: getConnection should get readLock to sync with destroyCon… #5750

Merged
merged 2 commits into from Nov 16, 2020

Conversation

gesterzhou
Copy link
Contributor

…nection

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?

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.

@kohlmu-pivotal kohlmu-pivotal added this to Verified - Approved in Quality Review Nov 16, 2020
@kohlmu-pivotal
Copy link
Contributor

Whilst the change LGTM... I cannot help but feel that the whole logic of (un)/locking of the connectionLifeCycleLock should really be a little more hidden. This locking logic proliferates throughout the whole GatewaySenderEventRemoteDispatcher. Which makes it way too easy to actually miss logic where the connection lock needs to be used.
@boglesby @gesterzhou maybe we should be locking at moving all this logic to another location.
There is also no indication of WHY this lock is required? Is it protecting the accessing of connection properties or is it avoiding the accidental setting of the connection field with another instance? It is not clear.

@boglesby
Copy link
Contributor

The lock is controlling access to the connection field. The destroyConnection and initializeConnection methods set it so they use the writeLock, and the readAcknowledgement and _dispatchBatch methods access it so they use the readLock. The getConnection method should also use the readLock, but it hasn't up until now with this change.

} finally {
getConnectionLifeCycleLock().readLock().unlock();
}
if (needToReconnect) {
if (logger.isDebugEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this debug statement need to be moved inside the readLock too since it calls this.connection.getServer()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need, you see the original author used:
(this.connection == null) ? "null" : ...

That means he realized this connection could be null here

@gesterzhou gesterzhou merged commit 399b875 into develop Nov 16, 2020
@gesterzhou gesterzhou deleted the feature/GEODE-8706 branch November 16, 2020 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Quality Review
Verified - Approved
3 participants