diff --git a/CHANGELOG.md b/CHANGELOG.md index c1cb63b..a5e835e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Optimize: Don't get column info again when not needed * [#5](https://github.com/ngocdaothanh/mydit/issues/5) Convert MySQL text to MongoDB UTF-8 String +* [#8](https://github.com/ngocdaothanh/mydit/issues/8) + Fix bug: Cannot exit when the number of errors exceeds the configured threshold * [#6](https://github.com/ngocdaothanh/mydit/issues/6) Update Logback from 1.1.2 to 1.1.3 * [#7](https://github.com/ngocdaothanh/mydit/issues/7) diff --git a/src/main/scala/mydit/MySQLExtractor.scala b/src/main/scala/mydit/MySQLExtractor.scala index 8391767..16e9609 100644 --- a/src/main/scala/mydit/MySQLExtractor.scala +++ b/src/main/scala/mydit/MySQLExtractor.scala @@ -66,10 +66,14 @@ class MySQLExtractor( } } - def start() { + def connect() { client.connect() } + def disconnect() { + client.disconnect() + } + //-------------------------------------------------------------------------- private def onFormatDescription(data: FormatDescriptionEventData) { diff --git a/src/main/scala/mydit/Rep.scala b/src/main/scala/mydit/Rep.scala index 9218830..508b865 100644 --- a/src/main/scala/mydit/Rep.scala +++ b/src/main/scala/mydit/Rep.scala @@ -20,7 +20,7 @@ class Rep(config: Config) extends RepEvent.Listener { mo.binlogGetPosition ) my.addListener(this) - my.start() + my.connect() //-------------------------------------------------------------------------- @@ -59,6 +59,10 @@ class Rep(config: Config) extends RepEvent.Listener { "Replicator program now exits because the failed replication event queue size exceeds {} (see config/application.conf)", config.maxFailedEventQueueSize ) + + // Need to disconnect before exiting, otherwise we can't exit because + // there are still running threads + my.disconnect() System.exit(-1) } } else if (lastQSize > 0) {