zongji icon indicating copy to clipboard operation
zongji copied to clipboard

start() options ignored if server already connected

Open lperrin opened this issue 7 years ago • 2 comments

I tried something like:

const zongji = new ZongJi({
  host: argv['source-host'],
  user: argv['source-user'],
  password: argv['source-password'],
  charset: 'utf8mb4'
});

someAsyncCode(function () {
    zongji.start({
      startAtEnd: true,
      includeEvents: ['tablemap', 'writerows', 'updaterows', 'deleterows', 'rotate'],
      includeSchema: includeSchema
    });
});

I realized that my options (including startAtEnd) were ignored by ZongJi. I suspect it's because the connection is already established by the time I call .start(). It's not a critical problem but it'd be great if it was mentioned in the doc.

Thanks for the great work!

lperrin avatar Apr 12 '17 01:04 lperrin

I just came across this issue today as well. The binlogOptions set in _init() are not overwritten when start() is called. If start() is called before all of the async initialization takes place, this works fine, but if zongji is created well before start() is called, then generateBinlog() already happened and the filename/startpos cannot change.

It seems like the fix is to move the ready function into start(). I think you should be able to set most if not all of the options that are sent to generateBinlog after construction anyways.

mrichards42 avatar Apr 17 '17 20:04 mrichards42

Burned by this. Seems best to pass the options as the second parameter to the Zongji constructor, even though the docs say to pass startAtEnd to the start function.

brainsiq avatar Aug 01 '17 15:08 brainsiq