Skip to content

Commit

Permalink
Merge pull request #156 from zendesk/ben/fix_unfound_mysql
Browse files Browse the repository at this point in the history
look for mysql database in schema *after* adding databases
  • Loading branch information
Ben Osheroff committed Nov 23, 2015
2 parents 2272b2b + 737701b commit 04f96b1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/com/zendesk/maxwell/schema/SchemaStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,6 @@ private void restoreFrom(BinlogPosition targetPosition)

this.schema_id = schemaRS.getLong("id");

if ( this.schema.findDatabase("mysql") == null ) {
LOGGER.info("Could not find mysql db, adding it to schema");
SchemaCapturer sc = new SchemaCapturer(connection, "mysql");
Database db = sc.capture().findDatabase("mysql");
this.schema.addDatabase(db);
shouldResave = true;
}

p = connection.prepareStatement("SELECT * from `maxwell`.`databases` where schema_id = ? ORDER by id");
p.setLong(1, this.schema_id);

Expand All @@ -252,6 +244,14 @@ private void restoreFrom(BinlogPosition targetPosition)
this.schema.getDatabases().add(restoreDatabase(dbRS.getInt("id"), dbRS.getString("name"), dbRS.getString("encoding")));
}

if ( this.schema.findDatabase("mysql") == null ) {
LOGGER.info("Could not find mysql db, adding it to schema");
SchemaCapturer sc = new SchemaCapturer(connection, "mysql");
Database db = sc.capture().findDatabase("mysql");
this.schema.addDatabase(db);
shouldResave = true;
}

if ( shouldResave )
this.schema_id = saveSchema();
}
Expand Down

0 comments on commit 04f96b1

Please sign in to comment.