Elffuss BraidHub

kikocis/java-driver public

Merge pull request #215 from olim7t/java415

Fix tokenMap initialization at startup (JAVA-415).
Changeseta3447a72a046975758e1f27434efa8175115af242aa7fc271515d10e18ef0432
AuthorSylvain Lebresne <sylvain@datastax.com> · 2014-08-11 17:16 +02:00
CommitterSylvain Lebresne <sylvain@datastax.com> · 2014-08-11 17:16 +02:00
Parentsc650795a337f, c994d7eb1103

Browse the files at this changeset

3 files changed

modified driver-core/CHANGELOG.rst +1 −0
@@ -8,6 +8,7 @@
88 - [bug] Fix handling of SimpleStatement with values in query builder
99 batches (JAVA-393)
1010 - [bug] Ensure pool is properly closed in onDown (JAVA-417)
11+- [bug] Fix tokenMap initialization at startup (JAVA-415)
1112
1213
1314 2.0.4:
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +1 −1
@@ -1772,7 +1772,7 @@
17721772 // that querying a table just after having created it don't fail.
17731773 if (!ControlConnection.waitForSchemaAgreement(connection, Cluster.Manager.this))
17741774 logger.warn("No schema agreement from live replicas after {} ms. The schema may not be up to date on some nodes.", ControlConnection.MAX_SCHEMA_AGREEMENT_WAIT_MS);
1775- ControlConnection.refreshSchema(connection, keyspace, table, Cluster.Manager.this, false, false);
1775+ ControlConnection.refreshSchema(connection, keyspace, table, Cluster.Manager.this, false);
17761776 } catch (Exception e) {
17771777 logger.error("Error during schema refresh ({}). The schema from Cluster.getMetadata() might appear stale. Asynchronously submitting job to fix.", e.getMessage());
17781778 submitSchemaRefresh(keyspace, table);
modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +6 −4
@@ -228,8 +228,10 @@
228228 refreshNodeListAndTokenMap(connection, cluster, isInitialConnection);
229229
230230 // Note that refreshing the schema will trigger refreshNodeListAndTokenMap since table == null
231+ // We want that because the token map was not properly initialized by the first call above, since it requires the list of keyspaces
232+ // to be loaded.
231233 logger.debug("[Control connection] Refreshing schema");
232- refreshSchema(connection, null, null, cluster, isInitialConnection, true);
234+ refreshSchema(connection, null, null, cluster, isInitialConnection);
233235 return connection;
234236 } catch (BusyConnectionException e) {
235237 connection.closeAsync().get();
@@ -247,7 +249,7 @@
247249 // At startup, when we add the initial nodes, this will be null, which is ok
248250 if (c == null)
249251 return;
250- refreshSchema(c, keyspace, table, cluster, false, false);
252+ refreshSchema(c, keyspace, table, cluster, false);
251253 } catch (ConnectionException e) {
252254 logger.debug("[Control connection] Connection error while refreshing schema ({})", e.getMessage());
253255 signalError();
@@ -262,7 +264,7 @@
262264 }
263265 }
264266
265- static void refreshSchema(Connection connection, String keyspace, String table, Cluster.Manager cluster, boolean isInitialConnection, boolean dontReloadNodeInfo) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException {
267+ static void refreshSchema(Connection connection, String keyspace, String table, Cluster.Manager cluster, boolean isInitialConnection) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException {
266268 // Make sure we're up to date on schema
267269 String whereClause = "";
268270 if (keyspace != null) {
@@ -306,7 +308,7 @@
306308
307309 // If the table is null, we either rebuild all from scratch or have an updated keyspace. In both case, rebuild the token map
308310 // since some replication on some keyspace may have changed
309- if (table == null && !dontReloadNodeInfo)
311+ if (table == null)
310312 refreshNodeListAndTokenMap(connection, cluster, false);
311313 }
312314