-
Notifications
You must be signed in to change notification settings - Fork 334
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
Add close
method for Region
trait
#832
Comments
We could acquire the write lock of the region (so we can ensure all pending writes before close are done) and mark the region as closing |
Cool, can I take this |
I'm currently work on the part that shut down the server gracefully when it received the ctrl-c signal (and I guess we also need to handle the SIGTERM), But I encountered some issues. The greptimedb/src/cmd/src/bin/greptime.rs Lines 33 to 37 in 8ffc078
The first pattern that came to my mind is to use a channel and pass the channel as a part of ctx into let (rx, tx) = channel();
let ctx = Context { sigterm: tx };
tokio::select! {
result = cmd.run(ctx) => {
if let Err(err) = result {
error!(err; "Fatal error occurs!");
}
}
_ = tokio::signal::ctrl_c() => {
info!("Goodbye!");
rx.send(());
}
} Then we can handle the signal in the greptimedb/src/cmd/src/datanode.rs Lines 68 to 83 in 8ffc078
Is this a good solution? Any suggestions are welcomed. |
Could we add another enum, like enum Application {
Datanode(Datanode),
Frontend(Frontend),
} We build the application from the command and run that application. let app = cmd.build();
tokio::select! {
result = app.run(ctx) => {},
_ = tokio::signal::ctrl_c() => {
app.stop();
}
} |
@v0y4g3r Maybe we could change this into a tracking issue to graceful shutdown |
What type of enhancement is this?
API improvement
What does the enhancement do?
A
close
method should be added toRegion
trait so that the resources held byRegion
can be gracefully release, for example, when a table is dropped.Implementation challenges
In order to gracefully close a region, we need to implement following tasks:
greptimedb/src/storage/src/region/writer.rs
Line 513 in 8ffc078
The text was updated successfully, but these errors were encountered: