-
Notifications
You must be signed in to change notification settings - Fork 93
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
ref(buffering): Add BufferService with SQLite backend #1920
Conversation
This is the initial naive implementation of the prsistent envelope buffer backed by SQLite. In this initial iterration: * add config option to enable persistent buffer * add migrations to create DB and required table for storing the envelopes - migrations run on start up and if the failure happens relay won't start at all * update envelope context to avoid sending the outcome if it's dropped while persisting it into the buffer - we might want to use `done` here instead * add SqliteBufferService which handles the sqlite pooling and insert/select/delete operations Still some TODOs: * metrics won't make any sense if we dropp and re-create the envelope context, still have to handle this properly - persist the data from the initil context? - don't care about it at all? * add high-/lowwaterrmark and use the memory for the inital buffer before storing envelopes in the db * read up the envelopes in batches instead of all at once
69266f2
to
7c4f618
Compare
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.
Preliminary review, mostly questions and bikeshedding.
own_key TEXT, | ||
sampling_key TEXT, |
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.
Can we make these fixed width 32 byte arrays? That should make the lookup faster (at least in theory).
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 will have to look into this, how the indicies on the binary fields work.
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 should make the lookup faster
I'm basing this on an assumption that TEXT
fields store a reference to a string that is saved somewhere else, while fixed-width types are stored "inline". But this assumption might be wrong as I have no idea how sqlite does 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.
This is good stuff, looks good!
Some comments on top of what Joris suggests.
/// Describes the errors linked with the `Sqlite` backed buffer. | ||
#[error("failed to fetch data from the database")] | ||
DatabaseError(#[from] sqlx::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.
A database is a type of backend of a buffer. Should we abstract it? Feel free to address this in a follow-up PR, or not do it at all until we actually use another backend.
own_key TEXT, | ||
sampling_key TEXT, |
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 should make the lookup faster
I'm basing this on an assumption that TEXT
fields store a reference to a string that is saved somewhere else, while fixed-width types are stored "inline". But this assumption might be wrong as I have no idea how sqlite does 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.
Looks good, I think this is ready for load testing.
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.
Looks good! There are still some open questions & suggestions, but none of them are blocking from my point of view.
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.
The PR looks good to me, I'd address the order topic before deploying, in this conversation.
* master: ref(buffering): Add BufferService with SQLite backend (#1920)
In PR:
BufferService
to handle the sqlite pooling and insert/select/delete operationsfix: https://github.com/getsentry/team-ingest/issues/78