From aee07199c525b7089c5fbd9f08bbaa9091c2902b Mon Sep 17 00:00:00 2001 From: Ben Osheroff Date: Tue, 16 Jun 2015 10:31:00 -0700 Subject: [PATCH 1/2] upgrade open-replicator this picks up a patch wherein we catch dead connections --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f76318258..7ebfb9e7c 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ com.zendesk open-replicator - 1.2.0 + 1.2.1 net.sf.jopt-simple From b00114f77852061fdc3b2279239328836c0c8df2 Mon Sep 17 00:00:00 2001 From: Ben Osheroff Date: Tue, 16 Jun 2015 10:32:23 -0700 Subject: [PATCH 2/2] recover from a dead open-replicator occasionally a master will cut the CX from underneath us. this allows us to recover. --- .../zendesk/maxwell/MaxwellBinlogEventListener.java | 1 + src/main/java/com/zendesk/maxwell/MaxwellParser.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/zendesk/maxwell/MaxwellBinlogEventListener.java b/src/main/java/com/zendesk/maxwell/MaxwellBinlogEventListener.java index d93aacf23..5e6c3d2af 100644 --- a/src/main/java/com/zendesk/maxwell/MaxwellBinlogEventListener.java +++ b/src/main/java/com/zendesk/maxwell/MaxwellBinlogEventListener.java @@ -18,6 +18,7 @@ public void stop() { mustStop.set(true); } + @Override public void onEvents(BinlogEventV4 event) { while (mustStop.get() != true) { try { diff --git a/src/main/java/com/zendesk/maxwell/MaxwellParser.java b/src/main/java/com/zendesk/maxwell/MaxwellParser.java index 16b939963..4d57a5d06 100644 --- a/src/main/java/com/zendesk/maxwell/MaxwellParser.java +++ b/src/main/java/com/zendesk/maxwell/MaxwellParser.java @@ -92,13 +92,23 @@ public void run() throws Exception { for(;;) { event = getEvent(); + + if ( !replicator.isRunning() ) { + LOGGER.warn("open-replicator stopped at position " + replicator.getBinlogFileName() + ":" + replicator.getBinlogPosition() + " -- restarting"); + replicator.start(); + } + if ( event == null ) continue; if ( !skipEvent(event)) { producer.push(event); - // TODO: we need to tell the producer to only store a stop-event on table-maps + // TODO: we need to tell the producer to only store a stop-event on table-maps; otherwise we can end up + // in the middle of multiple row events, which is a bug. } + + replicator.setBinlogFileName(event.getBinlogFilename()); + replicator.setBinlogPosition(event.getHeader().getNextPosition()); } }