Skip to content

[Bug]More than one state exists in fetch thread state machine.  #5

@ShanceWang

Description

@ShanceWang

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions