-
Notifications
You must be signed in to change notification settings - Fork 91
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
fix(projects): Treat fetch failures as pending #4140
base: master
Are you sure you want to change the base?
Conversation
time.sleep(1) # Wait for project to be cached | ||
|
||
# Relay still accepts events for this project | ||
next_response = relay.send_event(42) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the old version, this call raises a 403 error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does have the downside of potentially exhausting buffers if a project consistently cannot be computed. Do we need more alerts for this case?
@@ -777,7 +791,13 @@ impl ProjectCacheBroker { | |||
let state = source | |||
.fetch(project_key, no_cache, cached_state) | |||
.await | |||
.unwrap_or_else(|()| ProjectFetchState::disabled()); | |||
.unwrap_or_else(|e| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly a bit nicer to read with:
.inspect_err(|e| relay_log::error!(..))
.unwrap_or(ProjectFetchState::pending())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how unwrap_or_else
only creates a ProjectFetchState
in the error case. ProjectFetchState::pending()
calls Instant::now()
, so it's not entirely free.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That part could be fixed by using unwrap_or_else
, but I think the current version is fine as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went overboard with my example, I mainly meant the split of logging into the inspect_err
, keep the side effect separate from the conversion. But either way it's fine and possibly worse with the how rustfmt wants to format it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That part could be fixed by using unwrap_or_else
Yes, but then you need to ignore the argument passed to unwrap_or_else
(the error), that you previously inspected with inspect_err
. Is that better?
.inspect_err(|e| {
relay_log::error!(
error = e as &dyn Error,
"Failed to fetch project from source"
);
})
.unwrap_or_else(|_| ProjectFetchState::pending());
// vs
.unwrap_or_else(|e| {
relay_log::error!(
error = &e as &dyn Error,
"Failed to fetch project from source"
);
ProjectFetchState::pending()
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think the current version is superior.
Good point, we should alert when the buffer gets close to its total capacity, or implement @iambriccardo 's automatic eviction policy. I added a task to the epic. |
@@ -777,7 +791,13 @@ impl ProjectCacheBroker { | |||
let state = source | |||
.fetch(project_key, no_cache, cached_state) | |||
.await | |||
.unwrap_or_else(|()| ProjectFetchState::disabled()); | |||
.unwrap_or_else(|e| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That part could be fixed by using unwrap_or_else
, but I think the current version is fine as well.
Note: not merging this until https://github.com/getsentry/team-ingest/issues/345 is mature. |
Measure impact before we merge #4140.
When we fail to fetch a project state for any reason (max retries exceeded, redis error), we should not mark the project as invalid.
Currently we treat the project as if the DSN was invalid, and respond to clients with a 403 response. This might have made sense as a defensive measure in a pre-spooling world where envelopes could not be buffered for a longer period of time, but with spooling and time-based envelope eviction, we can now safely buffer them.
ref: INC-888
blocked by: https://github.com/getsentry/team-ingest/issues/345