Skip to content

Conversation

@ihsandemir
Copy link
Collaborator

Fix for shutting down the client properly if the cluster connection attempts all fail.

@ihsandemir ihsandemir added this to the 3.8.2 milestone May 12, 2017
@ihsandemir ihsandemir self-assigned this May 12, 2017
@ihsandemir ihsandemir requested a review from sancar May 12, 2017 08:53
@devOpsHazelcast
Copy link
Contributor

Test FAILed.

@ihsandemir
Copy link
Collaborator Author

verify

@devOpsHazelcast
Copy link
Contributor

Test FAILed.

1 similar comment
@devOpsHazelcast
Copy link
Contributor

Test FAILed.

@devOpsHazelcast
Copy link
Contributor

Test FAILed.

1 similar comment
@devOpsHazelcast
Copy link
Contributor

Test FAILed.

@ihsandemir
Copy link
Collaborator Author

verify

@devOpsHazelcast
Copy link
Contributor

Test FAILed.

@ihsandemir
Copy link
Collaborator Author

verify

@devOpsHazelcast
Copy link
Contributor

Test FAILed.

@ihsandemir
Copy link
Collaborator Author

verify

@devOpsHazelcast
Copy link
Contributor

Test FAILed.

@devOpsHazelcast
Copy link
Contributor

Test FAILed.

1 similar comment
@devOpsHazelcast
Copy link
Contributor

Test FAILed.

@devOpsHazelcast
Copy link
Contributor

Test FAILed.

…ttempts all fail. The Thread join now will detect if it is being called from running thread and avoid deadlock.

Removed the unneded test testTcpSocketConnectionTimeout_withIntMax.

Added some additional tests for testing thread functionality.
…ava client.

Corrected what is being tested at IssueTest.issue221.
…o this causes invalid memory access since the client is destroyed and all its services are destroyed.
@devOpsHazelcast
Copy link
Contributor

Test FAILed.

@devOpsHazelcast
Copy link
Contributor

Test FAILed.

@devOpsHazelcast
Copy link
Contributor

Test PASSed.

@sancar
Copy link
Contributor

sancar commented Jun 2, 2017

I did not get why shutdown needs a countdown latch to wait.
Can you describe failing scenario ?
First thing comes to my mind that a thread called shutdown and running shutdown method. In the meantime, destructor called shutdown. Checked that it is not active and returned immediately causing to delete everything while another thread accessing the fields of it.
But in this scenario, it means that HazelcastInstance shared among threads without a sharedPtr.

I am trying to understand if this is a problem we need to solve, or is it just a illegal usage.

@ihsandemir
Copy link
Collaborator Author

@sancar Yes, that is exactly the case. I saw it test https://github.com/hazelcast/hazelcast-cpp-client/blob/master/hazelcast/test/src/cluster/ClientConnectionTest.cpp#L48

So, the test finishes and hence the client destructor is executed before the shutdown is actually completed and hence during the shutdown illegal memory access occurs. I don't think it is an illegal use.

Yes, java uses shared references which eliminates the problem. It may also be solved by keeping an internally shared pointer and just returning a wrapper object HazelcastClient to the user, and also keeping a reference inside the clientcontext object which is being used between the threads.

In any case, we need to guarantee that the shutdown is finished and all threads are closed before exiting the destructor.

@sancar
Copy link
Contributor

sancar commented Jun 2, 2017

I still don't get it. How is the HazelcastClient shared between two threads in this test? If it is a raw pointer and one is calling destructor. This usage is illegal.
If it was shared via a shared_ptr<HazelcastClient> then since the one calling shutdown is not decremented the shared_ptr count, no one can call destructor before it finishes.

@devOpsHazelcast
Copy link
Contributor

Test FAILed.

…titionService was hung indefinitely on shutdown, could not regenerate the problem locally but this may be possible reason. Failing to shutdown the connection means any waiting invocation may not be set and if partition service is waiting on future.get, it may block indefinitely.
@devOpsHazelcast
Copy link
Contributor

Test PASSed.

@devOpsHazelcast
Copy link
Contributor

Test PASSed.

@devOpsHazelcast
Copy link
Contributor

Test PASSed.

@ihsandemir ihsandemir merged commit 217484b into hazelcast:master Jun 5, 2017
@ihsandemir ihsandemir deleted the shutdownFix branch June 5, 2017 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants