kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 84a5d8bc69e0de4df0420169399592739208a7487d17b4b785d4237d18165f43 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-09-08 21:20 -07:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-09-08 21:22 -07:00 |
| Parents | 73e7b6a4d0ef |
2 files changed
modified driver-core/CHANGELOG.rst +1 −0
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | - [improvement] Add ResultSet.wasApplied() for conditional queries (JAVA-358) |
| 13 | 13 | - [bug] Fix negative HostConnectionPool open count (JAVA-349) |
| 14 | 14 | - [improvement] Log more connection details at trace and debug levels (JAVA-436) |
| 15 | +- [bug] Fix cluster shutdown (JAVA-445) | |
| 15 | 16 | |
| 16 | 17 | 2.0.5: |
| 17 | 18 | ------ |
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +6 −5
| @@ -1230,14 +1230,15 @@ | ||
| 1230 | 1230 | logger.debug("Shutting down"); |
| 1231 | 1231 | |
| 1232 | 1232 | // If we're shutting down, there is no point in waiting on scheduled reconnections, nor on notifications |
| 1233 | - // delivery so we use shutdownNow | |
| 1233 | + // delivery or blocking tasks so we use shutdownNow | |
| 1234 | 1234 | reconnectionExecutor.shutdownNow(); |
| 1235 | 1235 | scheduledTasksExecutor.shutdownNow(); |
| 1236 | + blockingExecutor.shutdownNow(); | |
| 1236 | 1237 | |
| 1237 | 1238 | // but for the worker executor, we want to let submitted tasks finish unless the shutdown is forced. |
| 1238 | 1239 | executor.shutdown(); |
| 1239 | 1240 | |
| 1240 | - // We also closes the metrics | |
| 1241 | + // We also close the metrics | |
| 1241 | 1242 | if (metrics != null) |
| 1242 | 1243 | metrics.shutdown(); |
| 1243 | 1244 | |
| @@ -1984,6 +1985,7 @@ | ||
| 1984 | 1985 | reconnectionExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); |
| 1985 | 1986 | scheduledTasksExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); |
| 1986 | 1987 | executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); |
| 1988 | + blockingExecutor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); | |
| 1987 | 1989 | |
| 1988 | 1990 | // Some of the jobs on the executors can be doing query stuff, so close the |
| 1989 | 1991 | // connectionFactory at the very last |
| @@ -2052,9 +2054,8 @@ | ||
| 2052 | 2054 | |
| 2053 | 2055 | void shutdown() { |
| 2054 | 2056 | shutdown = true; |
| 2055 | - executor.shutdown(); | |
| 2056 | - // Run the task one last time if a call to register raced with the two lines above (i.e. | |
| 2057 | - // saw shutdown as false but added its connection after the last task in the executor ran). | |
| 2057 | + // Force shutdown to avoid waiting for the interval, and run the task manually one last time | |
| 2058 | + executor.shutdownNow(); | |
| 2058 | 2059 | reaperTask.run(); |
| 2059 | 2060 | } |
| 2060 | 2061 | } |