Comments (9)
The code in close sets a 100ms timeout here
if b.c != nil {
b.c.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
}
how about using b.c.Close() directly?
from go-mysql.
if b.c != nil {
b.c.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
}
b.c.Close()
I tried to add b.c.Close() here in replication/binlogsyncer.go.
After adding this line, the process exit successfully.
from go-mysql.
Em, SetReadDeadline will have no effect if reading some data in 100ms and then be cleared. Maybe Close is right here.
can you send me a PR to fix this?
from go-mysql.
Sure, but I found another problem when verifying the fix code.
Even if I called b.c.Close() here, there is still a case that blocking on b.wg.Wait().
Because BinlogSyncer.parseEvent is sending BinlogEvent to a buffered channel(s.ch), so onStream method may be blocking on it.
from go-mysql.
How about SetReadDeadline(0)?
from go-mysql.
The point is BinlogSyncer.parseEvent thread may be already blocked on s.ch before BinlogSyncer.Close() was called.
As long as BinlogSyncer.Close() waiting on b.wg.Wait(), no matter how to close the TCP connection, onStream method on the other thread will not decrease the WaitGroup.
from go-mysql.
@andwxh , can above PR fix this problem?
from go-mysql.
Yeah! This time its completely fixed. Thank you.
from go-mysql.
I wondered is it a good practice to use two variables (wg & stopCh) in Close(), in order to ensure onStream thread stopped. But it works now.
from go-mysql.
Related Issues (20)
- Is it possible to use github.com/klauspost/compress instead of github.com/DataDog/zstd HOT 5
- TableMapEvent 中 ColumnName 获取列名称是空数据。mysql是5.7版本 HOT 5
- Can we only focus the data changes of the tables we care about? HOT 1
- 关于Canal的binlog事件重试疑问 HOT 1
- 什么情况下event.Rows长度会为0 或者为nil? HOT 1
- When will the length of event.Rows be 0 or nil? HOT 4
- invalid sequence 0 != 1 HOT 6
- canal.RowsEvent returns 2 duplicate rows for every update event HOT 2
- Proper way to save position after Canal OnRow event HOT 3
- canal处理Text类型字段时增量日志和存量日志对应的数据结构不同 HOT 1
- add value string output HOT 5
- add a EventCacheSize variable to BinlogSyncerConfig to limit the streamer's memory usage
- How to start binlog syncer from last position HOT 3
- Tables
- Why In OnRow e.Header is nil ,no e.Header.LogPos
- canal can't send create index and drop index sql HOT 2
- MySQL 8.3 will introduce new GTID format
- [Warning] Aborted connection 52412 to db: 'unconnected' user: 'boss' host: '' (Got an error reading communication packets) HOT 7
- how to remove log output HOT 2
- column values missing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-mysql.