Skip to content

[probes.external] Fix logical race condition in external server probe handling - #744

Merged
manugarg merged 1 commit into
cloudprober:masterfrom
apolcyn:fix_race
May 19, 2024
Merged

manugarg merged 1 commit into
cloudprober:masterfrom
apolcyn:fix_race

Conversation

@apolcyn

@apolcyn apolcyn commented May 14, 2024

Copy link
Copy Markdown
Contributor

Currently there is a logical race condition as follows:

Suppose there is an external probe running in SERVER mode, with only one target.

  1. cloudprober sends the single request

  2. If the external probe server responds quickly enough, cloudprober can read the reply, but then when it checks sendDoneCh, it might not be closed yet.

  3. cloudprober's reader go-routine goes back to blocking on the select statement.

  4. Now the parent go-routine closes sendDoneCh.

At this point, the reader go-routine will remain blocked on the top select statement.

It will remain there until the context times out.


The impact of this bug is probably not catastrophic in most cases, but it causes a bunch of spurious "deadline exceeded" error logs from here if nothing else.

@manugarg

Copy link
Copy Markdown
Contributor

Thanks @apolcyn!

Just to summarize for myself: race condition occurs when we are able to read the reply, but send channel is not closed so we come back to reading the reply channel which will not yield anymore as reply has already been read. That will cause goroutine to get blocked until timeout.

That makes sense to me. I'll take a further lok.

@manugarg
manugarg merged commit 333e6f1 into cloudprober:master May 19, 2024
@manugarg manugarg changed the title Fix logical race condition in external server probe handling [probes.external] Fix logical race condition in external server probe handling May 19, 2024
@manugarg manugarg added this to the v0.13.5 milestone May 21, 2024
rishabhgargsde pushed a commit to rishabhgargsde/cloudprober that referenced this pull request Dec 24, 2024
rishabhgargsde pushed a commit to rishabhgargsde/cloudprober that referenced this pull request Dec 24, 2024
rishabhgargsde pushed a commit to rishabhgargsde/cloudprober that referenced this pull request Dec 30, 2024
rishabhgargsde pushed a commit to rishabhgargsde/cloudprober that referenced this pull request Dec 30, 2024
rishabhgargsde pushed a commit to rishabhgargsde/cloudprober that referenced this pull request Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants