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

feat(spooler): Add initialization of stacks #3967

Merged
merged 18 commits into from
Sep 2, 2024

Conversation

iambriccardo
Copy link
Member

@iambriccardo iambriccardo commented Aug 29, 2024

This PR implements the initialization logic of the envelope buffer. The initialization logic has to be run separately from the construction of the buffer since they are two separate things.

In addition, the PR enables the SQLite implementation of the spooler which can be enabled via the configuration.

https://github.com/getsentry/team-ingest/issues/519

@iambriccardo iambriccardo marked this pull request as ready for review August 30, 2024 07:39
@iambriccardo iambriccardo requested a review from a team as a code owner August 30, 2024 07:39
tokio::spawn(async move {
let mut buffer = PolymorphicEnvelopeBuffer::from_config(&config, memory_checker)
.await
.expect("Envelope buffer couldn't be initialized from the config");
Copy link
Member Author

Choose a reason for hiding this comment

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

We might want to fallback to the memory buffer impl in case we fail disk initialization, but we still have to handle Err given the method signature.

Copy link
Member

Choose a reason for hiding this comment

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

Have you tried how this behaves locally? E.g. by giving the path to a directory that does not exist?

Copy link
Member Author

@iambriccardo iambriccardo Aug 30, 2024

Choose a reason for hiding this comment

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

The implementation creates a folder with the file, so it will not fail unless there is filesystem failure. What we could test is to not have the path in the config but this will make the implementation switch to memory. I need to artificially try to return an error and see what is the behavior.

Copy link
Member

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

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

Looks good overall, I left a few questions.

relay-server/src/services/buffer/envelope_store/mod.rs Outdated Show resolved Hide resolved
tokio::spawn(async move {
let mut buffer = PolymorphicEnvelopeBuffer::from_config(&config, memory_checker)
.await
.expect("Envelope buffer couldn't be initialized from the config");
Copy link
Member

Choose a reason for hiding this comment

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

Have you tried how this behaves locally? E.g. by giving the path to a directory that does not exist?

relay-server/src/services/buffer/mod.rs Show resolved Hide resolved
relay-server/src/services/buffer/envelope_buffer/mod.rs Outdated Show resolved Hide resolved
let mut buffer = PolymorphicEnvelopeBuffer::from_config(&config, memory_checker)
.await
.expect("Envelope buffer couldn't be initialized from the config");
buffer.initialize().await;
Copy link
Member

Choose a reason for hiding this comment

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

Any reason we don't call initialize() inside of from_config()? Is it the difference in error handling?

Copy link
Member Author

Choose a reason for hiding this comment

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

Initialize is designed to be infallible but initially, I wanted to design the buffer with the initialization being independent of instantiation, because you don't need the initialization, this separation might be also useful for testing.

CHANGELOG.md Outdated Show resolved Hide resolved
relay-server/src/services/buffer/stack_provider/mod.rs Outdated Show resolved Hide resolved
relay-server/src/services/buffer/mod.rs Show resolved Hide resolved
iambriccardo and others added 4 commits August 30, 2024 13:13
Co-authored-by: Joris Bayer <joris.bayer@sentry.io>
Self::new(own_key, sampling_key)
}

pub fn iter(&self) -> impl Iterator<Item = ProjectKey> {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub fn iter(&self) -> impl Iterator<Item = ProjectKey> {
/// Returns an iterator over the contained distinct project keys.
pub fn iter(&self) -> impl Iterator<Item = ProjectKey> {

@iambriccardo iambriccardo merged commit ec1cb2a into master Sep 2, 2024
24 checks passed
@iambriccardo iambriccardo deleted the riccardo/feat/loading-buffer branch September 2, 2024 08:40
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