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

client/setec: single-flight dynamic lookups #98

Merged
merged 5 commits into from
Feb 17, 2024

Conversation

creachadair
Copy link
Member

From a discussion with @bradfitz. We already have single-flighting in the
store for polls anyway, so this is a straightforward extension.

For callers like scertec, it is very likely that a dynamic lookup may have a
large number of goroutines that all want the same secrets near a (re)start.
Single-flight the lookup so they don't all pound the secrets service and then
race on poking the value into the store.

For callers like scertec, it is very likely that a dynamic lookup may have a
large number of goroutines that all want the same secrets near a (re)start.
Single-flight the lookup so they don't all pound the secrets service and then
race on poking the value into the store.
@creachadair creachadair force-pushed the mjf/flight-of-the-singlebee branch from e1ff3d1 to 3c405ce Compare February 16, 2024 23:22
client/setec/store.go Outdated Show resolved Hide resolved
Comment on lines 384 to 389
} else if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) {
return nil, err
}
// Cancelled or deadline exceeed. If it was us, we'll fall off the loop.
}
s.logf("[store] added new undeclared secret %q", name)
return s.secretLocked(name), nil
return nil, ctx.Err()
Copy link
Member

Choose a reason for hiding this comment

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

You don't return the best error here in the case of the non-coalesced caller hitting its timeout: rather than seeing a net/http Client Do timeout with a certain URL wrapping a timeout error, you'll instead just get a timeout.

On line 384 maybe add an || ctx.Err() != nil around the whole thing? Or look at the Result.Shared value?

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense to me. I found the formulation a little tricky with the negations as they were, so I reworked it a bit, see what you think.

Copy link
Member

@bradfitz bradfitz left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@creachadair creachadair merged commit a4d9ef5 into main Feb 17, 2024
1 of 2 checks passed
@creachadair creachadair deleted the mjf/flight-of-the-singlebee branch February 17, 2024 03:35
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.

3 participants