Skip to content

Retry backoff not reset on successful re-connection #43

@ajcasagrande

Description

@ajcasagrande

I started noticing that the time to retry reader connections was becoming increasingly long the more times you connect/disconnect cycle the readers without restarting the device service.

I added extra printouts to the following code in order to track it down a little better

Snippet of interest which shows what i am referring to:

2021/06/29 16:53:42 retry attempt: 5, wait: 2m5s
level=DEBUG ts=2021-06-29T23:55:47.365787007Z app=edgex-device-rfid-llrp source=device.go:151 device=SpeedwayR-11-25-D6 msg="Attempting LLRP Client connection."
level=INFO ts=2021-06-29T23:55:47.366315604Z app=edgex-device-rfid-llrp source=device.go:470 device=SpeedwayR-11-25-D6 msg="Device connection restored."
...
level=ERROR ts=2021-06-29T23:56:45.720013566Z app=edgex-device-rfid-llrp source=device.go:166 error="failed to get next message: failed to read header: EOF" device=SpeedwayR-11-25-D6 msg="Client disconnected unexpectedly."
2021/06/29 16:56:45 retry attempt: 1, wait: 0s
level=DEBUG ts=2021-06-29T23:56:45.720256459Z app=edgex-device-rfid-llrp source=device.go:139 address=10.0.0.53:5084 device=SpeedwayR-11-25-D6 msg="Attempting to dial Reader."
level=ERROR ts=2021-06-29T23:56:45.720555502Z app=edgex-device-rfid-llrp source=device.go:144 error="dial tcp 10.0.0.53:5084: connect: connection refused" address=10.0.0.53:5084 device=SpeedwayR-11-25-D6 msg="Failed to dial Reader."
2021/06/29 16:56:45 retry attempt: 6, wait: 3m15s

Explanation:

  • Notice that 2 mins go by waiting for attempt 5 (retry.Slow), when it is able to successfully reconnect.

  • A little while later the connection is dropped and immediately, the retry.Quick attempts to reconnect and fails (retry attempt: 1, wait: 0s).

  • After this the retry.Slow waits for attempt 6 for over 3 minutes.

    • Because the connection was restored after attempt 5, the retry.Slow should be reset back to attempt 1, or at least the back-off time should be reset.

Full log here

Metadata

Metadata

Assignees

No one assigned

    Labels

    1-lowpriority denoting isolated changesholdIntended for PRs we want to flag for ongoing review

    Type

    No type

    Projects

    Status

    Icebox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions