Skip to content

Addressing Potential Memory Leak Issue in ZMQ Connection Handling #239

Open
@ryan961

Description

@ryan961
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

What happened?

While packaging ZMQ connections in the project to ensure high availability, the code uses dialEventSockLoop for constant proactive reconnection to ZMQ, which usually doesn't cause any issues.
However, if ZMQ disconnects during operation, and then we try to close the process, the goroutine becomes stuck here,

if err := b.dialEventSock(); err != nil {
log.WithError(err).Error("backend/concentratord: event socket dial error")
time.Sleep(time.Second)
continue
}

continuously trying to reconnect, hence preventing the process from exiting. It may be necessary to introduce an exit channel here to monitor the exit signals from the main program, thereby facilitating a smooth exit of the goroutine.
Moreover, it seems that the zmq package has some configurations like zmq4.WithAutomaticReconnect and zmq4.WithDialerMaxRetries... Would it be unnecessary, then, to attempt reconnections manually here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions