[Bug]More than one state exists in fetch thread state machine.
ShanceWang opened this issue · comments
Environment
-
Ptubes version: 1.0.0
-
Operating System version: Linux
-
Java version: 1.8
Steps to reproduce this issue
The "onChannelDisconnect" function in class NettyHttpRdsCdcReaderConnection will enqueue another state object into "messageQueue" of the fetch thread When the netty connection is lost.
private void onChannelDisconnect() {
log.warn("Fetch thread disconnected from remote server " + targetServer);
if (!this.getState()
.equals(State.CLOSING) && !this.getState()
.equals(State.CLOSED)) {
this.fetchThreadState.setStateId(FetchThreadState.StateId.PICK_SERVER);
this.fetchThread.enqueueMessage(this.fetchThreadState); // it is
this.setState(State.CLOSED);
} else {
log.warn("Fetch thread connection is already closed.");
}
}
The bug may cause a data loss risk. Because two state in "messageQueue" of the fetch thread will cause two fetching reader event in a short time. Meanwhile, the dispatch class is a a non-thread-safe while doing events distribution.
Expected Behavior
Only one state object contains in the "messageQueue" of the fetch thread.
Actual Behavior
There is more than one state object exists in "messageQueue" of the fetch thread.
hi, shance,I saw this problem, I tried to follow your process and found that it can be reproduced, it is a bug, we need to fix it