Repository navigation
fix(server): Retain valid cached project states on error - #1426
Conversation
|
While playing with GitHub Copilot I touched this part of the code. |
a15f25f to
3b76e3f
Compare
| pub last_fetch: Instant, | ||
|
|
||
| /// True if this project state was fetched but incompatible with this Relay. | ||
| /// True if this project state failed fetching or was incompatible with this Relay. |
There was a problem hiding this comment.
What does "incompatible" mean? Reading the docstrings of invalid, it seems to refer to projects that could not be parsed; but I don't know what the scope of "parse" is, if it's only e.g. syntax issues or network issues while fetching. Specifically, is an expired project state invalid?
Also, the docstrings for invalid are updated here, could we also update them for invalid()?
| // If the new state is valid or the old one is expired, always use the new one. | ||
| _ => self.state = Some(state.clone()), |
There was a problem hiding this comment.
Is there a reason to fall back to the old state, if both are expired? Do we assume that the new state is more up-to-date even if both are stale?
There was a problem hiding this comment.
I think it's fair to assume that the state passed into this function is newer.
| // If the new state is invalid but the old one still usable, keep the old one. | ||
| ExpiryState::Updated(old) | ExpiryState::Stale(old) if state.invalid() => state = old, | ||
| // If the new state is valid or the old one is expired, always use the new one. | ||
| _ => self.state = Some(state.clone()), |
There was a problem hiding this comment.
Is there a chance both states are updated? What should we do there?
There was a problem hiding this comment.
It's a good question. We could write this function in a way that it always preserves the fresher config, but for now I would keep the default behavior of replacing the old state with the state passed as an argument, and only make an exception for invalid configs.
| pub last_fetch: Instant, | ||
|
|
||
| /// True if this project state was fetched but incompatible with this Relay. | ||
| /// True if this project state failed fetching or was incompatible with this Relay. |
| // If the new state is valid or the old one is expired, always use the new one. | ||
| _ => self.state = Some(state.clone()), |
There was a problem hiding this comment.
I think it's fair to assume that the state passed into this function is newer.
| // If the new state is invalid but the old one still usable, keep the old one. | ||
| ExpiryState::Updated(old) | ExpiryState::Stale(old) if state.invalid() => state = old, | ||
| // If the new state is valid or the old one is expired, always use the new one. | ||
| _ => self.state = Some(state.clone()), |
There was a problem hiding this comment.
It's a good question. We could write this function in a way that it always preserves the fresher config, but for now I would keep the default behavior of replacing the old state with the state passed as an argument, and only make an exception for invalid configs.
* master: release: 0.8.15 fix(py): Respect the renormalize flag (#1548) (fix)e2e: Use report self hosted issues env variable (#1539) meta(vscode): Enable all features in Rust-Analyzer (#1542) release: 0.8.14 build(craft): Fix manylinux artifact name (#1547) feat(quotas): New data category for indexed transactions (#1535) test(auth): Unflake re_auth_failure (#1531) replays: add warning log for parse errors (#1534) fix(server): Retain valid cached project states on error (#1426) feat(protocol): Implement response context schema (#1529) feat(replays): emit org_id on recording kafka messages (#1528) feat: Add .NET/Portable-PDB specific protocol fields (#1518) feat(quotas): Enforce rate limits on metrics buckets (#1515) ref(pii): Consider all token as sensitive [INGEST-1550] (#1527) release: 22.10.0
Fixes a case where valid project states are removed from the project cache after
the fetch deadline has succeeded. Relay should instead continue using caches
until the grace period has expired, and retry fetching in the background.
ProjectState::err. The specific error (i.e.deserialization and network errors) can still be logged at the source.
ProjectState::missingalways overwrites the existing state.ProjectState::erronly overwrites if the existing state is (hard) outdated.This error is cached and propagated.
ProjectState::err. We have to figure out a backoff mechanism for this case(probably a flag/Instant on the Project).
INGEST-1504
INGEST-1507
#skip-changelog