Skip to content

Relay listener does not restart sometimes #8749

Closed

Description

@GermanCoding

Does your log mention database corruption?

No

Include required information

  • Syncthing v1.23.0, Linux (64-bit Intel/AMD)
  • Browser N/A

Steps to reproduce:

  1. Manually configure a relay server in "Sync protocol listen addresses"
  2. Let the connection to the relay server drop periodically (due to inadvertent network issues)
  3. Watch how the relay listener usually restarts after a while, trying to reconnect
  4. At some point, the relay listener stops restarting altogether

This didn't happen in older versions of syncthing, though I cannot exactly say which ones. In those versions, the relay listener would always restart after some period, if the relay failed. This seems to no longer be the case. Below is a sanitized log of one of my syncthing instances, recorded over the last 10 days:

Jan 04 06:02:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) starting
Jan 04 06:02:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Joined relay relay://my.own.relay:22067
Jan 04 06:02:32 Odroid-H2 syncthing[458004]: [<Self>] INFO: Established secure connection to <some-device> at <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256
Jan 04 06:02:32 Odroid-H2 syncthing[458004]: [<Self>] INFO: Replacing old connection <IPs>:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256 with <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256 for <device>
Jan 04 06:02:32 Odroid-H2 syncthing[458004]: [<Self>] INFO: Device <some-device> client is "syncthing v1.22.2" named "my.device" at [2003:f1:1f07:a400:fd4d:a411:d86a:4122]:45450-[2a01:4f8:151:506c::2]:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256
Jan 04 06:02:32 Odroid-H2 syncthing[458004]: [<Self>] INFO: Replacing old connection <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256 with <IPs>:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256 for <some-device>
Jan 04 06:02:32 Odroid-H2 syncthing[458004]: [<Self>] INFO: Connection to <some-device> at <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256 closed: replacing connection
Jan 05 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) shutting down
Jan 05 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: listenerSupervisor@relay://my.own.relay:22067/?id=<ID>: service relay://my.own.relay:22067/?id=<ID> failed: timed out
Jan 05 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) starting
Jan 05 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Joined relay relay://my.own.relay:22067
Jan 06 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) shutting down
Jan 06 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: listenerSupervisor@relay://my.own.relay:22067/?id=<ID>: service relay://my.own.relay:22067/?id=<ID> failed: timed out
Jan 06 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) starting
Jan 06 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Joined relay relay://my.own.relay:22067
Jan 06 06:00:58 Odroid-H2 syncthing[458004]: [<Self>] INFO: Established secure connection to <some-device> at <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256
Jan 06 06:00:58 Odroid-H2 syncthing[458004]: [<Self>] INFO: Replacing old connection <IPs>:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256 with <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256 for <some-device>
Jan 06 06:00:58 Odroid-H2 syncthing[458004]: [<Self>] INFO: Device <some-device> client is "syncthing v1.23.0" named "my.device" at <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256
Jan 06 06:01:38 Odroid-H2 syncthing[458004]: [<Self>] INFO: Replacing old connection <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256 with <IPs>:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256 for <some-device>
Jan 06 06:01:38 Odroid-H2 syncthing[458004]: [<Self>] INFO: Connection to <some-device> at <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256 closed: replacing connection
Jan 07 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) shutting down
Jan 07 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: listenerSupervisor@relay://my.own.relay:22067/?id=<ID>: service relay://my.own.relay:22067/?id=<ID> failed: timed out
Jan 07 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) starting
Jan 07 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Joined relay relay://my.own.relay:22067
Jan 08 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) shutting down
Jan 08 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: listenerSupervisor@relay://my.own.relay:22067/?id=<ID>: service relay://my.own.relay:22067/?id=<ID> failed: timed out
Jan 08 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) starting
Jan 08 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Joined relay relay://my.own.relay:22067
Jan 09 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) shutting down
Jan 09 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: listenerSupervisor@relay://my.own.relay:22067/?id=<ID>: service relay://my.own.relay:22067/?id=<ID> failed: timed out
Jan 09 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) starting
Jan 09 05:57:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Joined relay relay://my.own.relay:22067
Jan 09 06:01:24 Odroid-H2 syncthing[458004]: [<Self>] INFO: Established secure connection to <some-device> at <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256
Jan 09 06:01:24 Odroid-H2 syncthing[458004]: [<Self>] INFO: Replacing old connection <IPs>:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256 with <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256 for <some-device>
Jan 09 06:01:24 Odroid-H2 syncthing[458004]: [<Self>] INFO: Device <some-device> client is "syncthing v1.23.0" named "my.device" at <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256
Jan 09 06:02:05 Odroid-H2 syncthing[458004]: [<Self>] INFO: Replacing old connection <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256 with <IPs>:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256 for <some-device>
Jan 09 06:02:05 Odroid-H2 syncthing[458004]: [<Self>] INFO: Connection to <some-device> at <IPs>:22067/relay-server/TLS1.3-TLS_AES_128_GCM_SHA256 closed: replacing connection
Jan 09 20:18:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) shutting down
Jan 09 20:18:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: listenerSupervisor@relay://my.own.relay:22067/?id=<ID>: service relay://my.own.relay:22067/?id=<ID> failed: timed out
Jan 09 20:18:15 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) starting
Jan 09 20:18:25 Odroid-H2 syncthing[458004]: [<Self>] INFO: Relay listener (relay://my.own.relay:22067/?id=<ID>) shutting down

Pay special attention to the dates: The relay listener last failed on Jan 9th, tried to restart - which apparently failed - and then never restarted. It's been over 5 days now, and the relay listener hasn't yet attempted at a restart (at least no log line mentioning the word "relay" has been printed at all).

As you can see from the logs, the relay does fail from time to time - this is (probably) due to a slightly unreliable network connection, nothing I can do about that. I understand if there's an exponential backoff implemented somewhere, but 5+ days without a reconnection attempt is a bit excessive I think.

In the advanced configuration, my

Relay Reconnect Interval (minutes) / relayReconnectIntervalM is set to 10. I do not recall changing this, but I don't know what the default value is.

(Of course, restarting syncthing fixes this issue immediatly, but it's not ideal)

Activity

  1. added
    bug
    needs-triage
    on Jan 15, 2023
  2. calmh commented on Jan 15, 2023

    @calmh
    Member

    Can we have a non sanitized log? At least for an hour around the last event.

  3. GermanCoding commented on Jan 15, 2023

    @GermanCoding
    ContributorAuthor

    I have send the full log privately. I don't think it contains useful data though. If you can give me some pointers about which debugging facilities to enable, I could try to reproduce with more logging enabled.

  4. calmh commented on Jan 15, 2023

    @calmh
    Member

    Well, the relay one to begin with. The relay listener not restarting should be due to its context being cancelled, that is, because of a config change or because Syncthing itself is shutting down. Without any context in the logs I have no idea what's going on.

  5. GermanCoding commented on Jan 15, 2023

    @GermanCoding
    ContributorAuthor

    After restarting & enabling relay (+ connections) logging, I got lucky and the issue appeared again within a few minutes (due to a router restart this time): Below is an excerpt from the relay shutting down and not coming back. The full logs are also attached.

    I have also set Relay Reconnect Interval (minutes) / relayReconnectIntervalM to 1.

    Jan 15 06:07:49 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:07:49.651819 static.go:81: DEBUG: StaticClient:0xc0002dc870@relay://my.own.relay:22067/?id=relay-ID&token=relay-token received message protocol.Ping
    Jan 15 06:07:49 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:07:49.651919 static.go:89: DEBUG: StaticClient:0xc0002dc870@relay://my.own.relay:22067/?id=relay-ID&token=relay-token sent pong
    Jan 15 06:08:19 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:08:19.653569 static.go:81: DEBUG: StaticClient:0xc0002dc870@relay://my.own.relay:22067/?id=relay-ID&token=relay-token received message protocol.Ping
    Jan 15 06:08:19 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:08:19.653658 static.go:89: DEBUG: StaticClient:0xc0002dc870@relay://my.own.relay:22067/?id=relay-ID&token=relay-token sent pong
    Jan 15 06:08:49 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:08:49.651743 static.go:81: DEBUG: StaticClient:0xc0002dc870@relay://my.own.relay:22067/?id=relay-ID&token=relay-token received message protocol.Ping
    Jan 15 06:08:49 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:08:49.651986 static.go:89: DEBUG: StaticClient:0xc0002dc870@relay://my.own.relay:22067/?id=relay-ID&token=relay-token sent pong
    Jan 15 06:09:19 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:09:19.654217 static.go:81: DEBUG: StaticClient:0xc0002dc870@relay://my.own.relay:22067/?id=relay-ID&token=relay-token received message protocol.Ping
    Jan 15 06:09:19 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:09:19.654459 static.go:89: DEBUG: StaticClient:0xc0002dc870@relay://my.own.relay:22067/?id=relay-ID&token=relay-token sent pong
    Jan 15 06:11:19 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:11:19.655381 static.go:121: DEBUG: StaticClient:0xc0002dc870@relay://my.own.relay:22067/?id=relay-ID&token=relay-token timed out
    Jan 15 06:11:19 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:11:19.655496 static.go:174: DEBUG: StaticClient:0xc0002dc870@relay://my.own.relay:22067/?id=relay-ID&token=relay-token disconnecting
    Jan 15 06:11:19 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:11:19.655847 relay_listen.go:65: INFO: Relay listener (relay://my.own.relay:22067/?id=relay-ID&token=relay-token) shutting down
    Jan 15 06:11:19 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:11:19.655994 svcutil.go:192: INFO: listenerSupervisor@relay://my.own.relay:22067/?id=relay-ID&token=relay-token: service relay://my.own.relay:22067/?id=relay-ID&token=relay-token failed: timed out
    Jan 15 06:11:19 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:11:19.656083 relay_listen.go:57: INFO: Relay listener (relay://my.own.relay:22067/?id=relay-ID&token=relay-token) starting
    Jan 15 06:11:29 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:11:29.661120 static.go:51: DEBUG: Could not connect to relay relay://my.own.relay:22067/?id=relay-ID&token=relay-token: dial tcp 176.9.103.107:22067: i/o timeout
    Jan 15 06:11:29 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:11:29.661242 relay_listen.go:65: INFO: Relay listener (relay://my.own.relay:22067/?id=relay-ID&token=relay-token) shutting down
    Jan 15 06:12:15 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:12:15.140587 service.go:423: INFO: Established secure connection to <Device-6> at 192.168.10.34:22000-192.168.10.31:22000/tcp-server/TLS1.3-TLS_AES_128_GCM_SHA256
    Jan 15 06:12:15 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:12:15.140804 model.go:2213: INFO: Replacing old connection [2003:f1:1f13:8300:c18c:7cce:e08d:9cb7]:22000-[2003:f1:1f19:4800:e48f:4c42:87d1:cb0b]:55492/tcp-server/TLS1.3-TLS_AES_128_GCM_SHA256 with 192.168.10.34:22000-192.168.10.31:22000/tcp-server/TLS1.3-TLS_AES_128_GCM_SHA256 for <Device-6>
    Jan 15 06:12:15 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:12:15.141633 model.go:1782: INFO: Connection to <Device-6> at [2003:f1:1f13:8300:c18c:7cce:e08d:9cb7]:22000-[2003:f1:1f19:4800:e48f:4c42:87d1:cb0b]:55492/tcp-server/TLS1.3-TLS_AES_128_GCM_SHA256 closed: replacing connection
    Jan 15 06:12:15 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:12:15.142228 model.go:2264: INFO: Device <Device-6> client is "syncthing v1.23.0" named "Device-6" at 192.168.10.34:22000-192.168.10.31:22000/tcp-server/TLS1.3-TLS_AES_128_GCM_SHA256
    Jan 15 06:12:43 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:12:43.784100 model.go:1782: INFO: Connection to <Device-4> at 192.168.10.34:47356-176.9.103.107:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256 closed: reading length: read tcp4 192.168.10.34:47356->176.9.103.107:22000: read: connection reset by peer
    Jan 15 06:12:51 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:12:51.016163 service.go:423: INFO: Established secure connection to <Device-4> at [2003:f1:1f19:5900:125:8302:4d0f:d580]:22000-[2a01:4f8:151:506c::2]:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256
    Jan 15 06:12:51 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:12:51.016532 model.go:2264: INFO: Device <Device-4> client is "syncthing v1.23.0" named "Device-4" at [2003:f1:1f19:5900:125:8302:4d0f:d580]:22000-[2a01:4f8:151:506c::2]:22000/tcp-client/TLS1.3-TLS_AES_128_GCM_SHA256
    Jan 15 06:20:50 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:20:50.563461 api.go:747: INFO: Enabled debug data for "connections"
    Jan 15 06:20:57 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:20:57.402127 service.go:1111: DEBUG: dialing <Device-3> tcp://10.192.3.2:22000 error: dial tcp 10.192.3.2:22000: i/o timeout
    Jan 15 06:20:57 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:20:57.402460 service.go:1111: DEBUG: dialing <Device-2> tcp://[2003:f1:1f13:8300:256c:4d68:cf91:27a5]:22000 error: dial tcp [2003:f1:1f13:8300:256c:4d68:cf91:27a5]:22000: i/o timeout
    Jan 15 06:20:57 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:20:57.402582 service.go:1141: DEBUG: failed to connect to <Device-2> 9
    Jan 15 06:20:57 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:20:57.402644 service.go:1141: DEBUG: failed to connect to <Device-3> 10
    Jan 15 06:20:57 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:20:57.402706 structs.go:244: DEBUG: dialing <Device-2> tcp://62.226.235.69:22000 prio 10
    Jan 15 06:21:07 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:21:07.403525 service.go:1111: DEBUG: dialing <Device-2> tcp://62.226.235.69:22000 error: dial tcp 62.226.235.69:22000: i/o timeout
    Jan 15 06:21:07 Odroid-H2 syncthing[973896]: [<Self>] 2023/01/15 06:21:07.403581 service.go:1141: DEBUG: failed to connect to <Device-2> 10
    
    

    The relay listener shuts shown approximately 5 minutes after startup and then never comes back up.

    I have attached the full logs - a few lines are altered for privacy, but I have not removed anything.

    I am not (intentionally) doing config changes nor is syncthing shutting down while the relay listener shuts down.

    Logfile removed (no longer needed)

  6. removed
    needs-triage
    on Jan 16, 2023
  7. calmh commented on Jan 16, 2023

    @calmh
    Member

    So this is an interesting one and took me a while to narrow down. The problem occurs when the error is a timeout:

    tcp://62.226.235.69:22000 error: dial tcp 62.226.235.69:22000: i/o timeout
    

    The reason is that the service manager that runs the listener doesn't restart it when it returns a context cancelled or timed out error (because cancelling the context is the way to stop the service):

    https://github.com/thejerf/suture/blob/32afe7cf63d192b4b6315eb9613a2221431206b7/v4/supervisor.go#L367-L370

    And since Go 1.19,

    When a net package function or method returns an "I/O timeout" error, the error will now satisfy errors.Is(err, context.DeadlineExceeded).

    (https://tip.golang.org/doc/go1.19)

    So a timeout error cancels the entire listener...

  8. added a commit that references this issue on Jan 16, 2023
    05d02d1
  9. added a commit that references this issue on Jan 23, 2023
    f8b7cc4
  10. added this to the v1.23.2 milestone on Feb 12, 2023
  11. added a commit that references this issue on Feb 22, 2023
    22f7807
  12. added
    frozen-due-to-age
    on Jan 19, 2024
  13. locked and limited conversation to collaborators on Jan 19, 2024
  14. added a commit that references this issue on Jan 30, 2024
    abdac2c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfrozen-due-to-age

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions