Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receive: race condition in handler Close() when stopped early #7087

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

cincinnat
Copy link
Contributor

@cincinnat cincinnat commented Jan 23, 2024

Receiver hangs waiting for the HTTP Handler to shutdown if an error occurs before Handler is initialized. This might happen, for example, if the hashring is too small for a given replication factor.

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Fixes a race condition in receive.Handler.Close().

Verification

Before this change, the race condition could be reproduced with the script below. Eventually (in about 1-2 seconds) receiver would be able to start "successfully" and the script would hang until killed with SIGKILL. Health checks would not work since the health check listener is already down.

#!/bin/bash

trap exit SIGINT SIGTERM

while :; do
    thanos receive \
        --tsdb.path=/tmp/data \
        --label='receive="1"' \
        --receive.hashrings-algorithm=ketama \
        --receive.hashrings='[{"endpoints": ["127.0.0.1:19291"]}]' \
        --receive.replication-factor=2
done

@cincinnat cincinnat changed the title receive: race condition in handler Close() when stopped early Receive: race condition in handler Close() when stopped early Jan 23, 2024
Receiver hangs waiting for the HTTP Hander to shutdown if an error occurs
before Handler is initialized. This might happen, for example, if the hashring
is too small for a given replication factor.

Signed-off-by: Mikhail Nozdrachev <mikhail.nozdrachev@aiven.io>
@cincinnat cincinnat force-pushed the cincinnat-receive-handler-race branch from 0bbf6d8 to 0f0f081 Compare January 23, 2024 12:55
@cincinnat cincinnat marked this pull request as ready for review January 23, 2024 13:28
Copy link
Contributor

@MichaHoffmann MichaHoffmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@GiedriusS GiedriusS merged commit fce0fe2 into thanos-io:main Jan 24, 2024
20 checks passed
GiedriusS pushed a commit to vinted/thanos that referenced this pull request Jan 30, 2024
…-io#7087)

Receiver hangs waiting for the HTTP Hander to shutdown if an error occurs
before Handler is initialized. This might happen, for example, if the hashring
is too small for a given replication factor.

Signed-off-by: Mikhail Nozdrachev <mikhail.nozdrachev@aiven.io>
jnyi pushed a commit to jnyi/thanos that referenced this pull request Apr 4, 2024
…-io#7087)

Receiver hangs waiting for the HTTP Hander to shutdown if an error occurs
before Handler is initialized. This might happen, for example, if the hashring
is too small for a given replication factor.

Signed-off-by: Mikhail Nozdrachev <mikhail.nozdrachev@aiven.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants