-
Notifications
You must be signed in to change notification settings - Fork 667
In-memory DatabaseLogger #3961
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
base: master
Are you sure you want to change the base?
In-memory DatabaseLogger #3961
Conversation
3e71368 to
fe02d88
Compare
fa8fb90 to
5c76b8e
Compare
5c76b8e to
9ce1579
Compare
| .map(Ok::<_, std::convert::Infallible>); | ||
| let Some(host) = worker_ctx.leader(database.id).await.map_err(log_and_500)? else { | ||
| if follow { | ||
| return Err((StatusCode::NOT_FOUND, "Host not running, cannot follow logs").into()); |
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 think this is a misleading error message. My reading of the doc comment on NodeDelegate::leader is that it will spawn the host if necessary, and will only return None for databases whose leader is not assigned to this node. (I am unsure of the interaction with in-memory databases, if that's relevant in this path.)
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.
Hm you're right. This has been incorrect before because it isn't considered that this might be the right host to read disk-backed module logs from, but the database is not running (e.g. because it is suspended, or currently bootstrapping).
For now, I'll revert to return 404 with the message of the get_leader_replica_by_database call above, and remove that call as it is redundant.
I'll come up with a follow-up.
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.
2be2fd8 to
1486274
Compare
1486274 to
87525f8
Compare
crates/core/src/database_logger.rs
Outdated
| // Cap reading the tail into memory at a few hundred KiB. | ||
| let n = n.min(2500); | ||
| let (tail, more) = { | ||
| let inner = self.inner.lock_arc(); |
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 seems questionable to me - won't this block if another thread is in the process of doing the sync_data() call below?
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.
If we want to do this we should just make it an async mutex.
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.
We have to do this if we don't want to serve duplicate log lines.
Using an async mutex doesn't work, though, as we are calling DatabaseLogger:write from within an async context virtually everywhere. I guess we always had a problem with blocking here.
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.
Made it to use message-passing. PTAL
a16cf24 to
c7ad80b
Compare
edb5dc8 to
38524a5
Compare
This is the second step to make in-memory-only databases not touch the disk at all. While at it, also make it so file-backed module logs are streamed in constant memory where possible. Co-authored-by: Phoebe Goldman <[email protected]> Signed-off-by: Kim Altintop <[email protected]>
38524a5 to
84ff62d
Compare
This is the second step to make in-memory-only databases not touch the disk at all.
While at it, also make it so file-backed module logs are streamed in constant memory where possible.
Depends-on: #3912
Expected complexity level and risk
2
Testing
Added some unit-level tests.