spencerlambert / mysql-events

A node meteor package that watches a MySQL database and runs callbacks on matched events.
Other
87 stars 74 forks source link

It seems connections is never destroyed zongji.on('error') is called #26

Closed chknim closed 6 years ago

chknim commented 7 years ago

In index.js, if on 'error' is triggered, it seems recursively calling zongjiManager will new ZongJi every time and that seems to cause infinite connections.

Upon creating ZongJi, new connections to db are created and it does not seem to me they are destroyed or released properly?

function zongjiManager(dsn, options, onBinlog) { var newInst = new ZongJi(dsn, options); newInst.on('error', function(reason) { newInst.removeListener('binlog', onBinlog); newInst.child = false; setTimeout(function() { // If multiple errors happened, a new instance may have already been created if(!newInst.child) { var newInstNext = zongjiManager(dsn, Object.assign({}, options, newInst.binlogNextPos

chknim commented 7 years ago

I can contribute a patch or try to reproduce. Just want a second eye here to confirm I'm not barking up the wrong tree.

spencerlambert commented 7 years ago

Yes, I think you are right. I had a similar experience a few months back, I lacked the time to really do much more than simply rip it out in that installation. A pull request would be greatly appreciated.

chknim commented 7 years ago

Thanks spencerlambert. Quick question. I notice the master is still using zongji 0.4.3 while the latest is 0.4.4 (the diff is just mysql version is upgraded from 2.10.2 to 2.12.0). I might try that altogether as well in my PR if you dont see a problem with that.

spencerlambert commented 7 years ago

I don't have a problem with upgrading to zongi 0.4.4 at the same time.