Comments (5)
Maybe, sure, but obviously we'd need to work with the Raft maintainers to do that.
from rqlite.
This seems to be a limitation of raft itself, whenever you call raft.Shutdown()
it returns a future, that you can then use to wait for it to finish. Inside the raft implementation it does not check for shutdown during the network transfer.
We could simply not wait on the Shutdown future, but I imagine this can lead to some buggy behavior.
Imho this is working as intended.
from rqlite.
Shouldn't an issue be raised with Hashicorp's raft then?
from rqlite.
@otoolep Could this network transfer be done in a future in raft, so we can check for shutdown while copying?
Smth along the lines of this
diff --git a/raft.go b/raft.go
index 28c1128..73d85c9 100644
--- a/raft.go
+++ b/raft.go
@@ -1755,32 +1755,49 @@ func (r *Raft) installSnapshot(rpc RPC, req *InstallSnapshotRequest) {
countingRPCReader := newCountingReader(rpc.Reader)
// Spill the remote snapshot to disk
- transferMonitor := startSnapshotRestoreMonitor(r.logger, countingRPCReader, req.Size, true)
- n, err := io.Copy(sink, countingRPCReader)
- transferMonitor.StopAndWait()
- if err != nil {
- sink.Cancel()
- r.logger.Error("failed to copy snapshot", "error", err)
- rpcErr = err
- return
- }
+ diskCopyErrCh := make(chan error, 1)
+ // NOTE: Maybe this is a good candidate for a future?
+ go func() {
+ transferMonitor := startSnapshotRestoreMonitor(r.logger, countingRPCReader, req.Size, true)
+ n, err := io.Copy(sink, countingRPCReader)
+ transferMonitor.StopAndWait()
+ if err != nil {
+ sink.Cancel()
+ r.logger.Error("failed to copy snapshot", "error", err)
+ diskCopyErrCh <- err
+ return
+ }
- // Check that we received it all
- if n != req.Size {
- sink.Cancel()
- r.logger.Error("failed to receive whole snapshot",
- "received", hclog.Fmt("%d / %d", n, req.Size))
- rpcErr = fmt.Errorf("short read")
- return
- }
+ // Check that we received it all
+ if n != req.Size {
+ sink.Cancel()
+ r.logger.Error("failed to receive whole snapshot",
+ "received", hclog.Fmt("%d / %d", n, req.Size))
+ diskCopyErrCh <- fmt.Errorf("short read")
+ return
+ }
- // Finalize the snapshot
- if err := sink.Close(); err != nil {
- r.logger.Error("failed to finalize snapshot", "error", err)
- rpcErr = err
+ // Finalize the snapshot
+ if err := sink.Close(); err != nil {
+ r.logger.Error("failed to finalize snapshot", "error", err)
+ diskCopyErrCh <- err
+ return
+ }
+ r.logger.Info("copied to local snapshot", "bytes", n)
+ diskCopyErrCh <- nil
+ }()
+
+ // Wait for snapshot copy or shutdown
+ select {
+ case err := <-diskCopyErrCh:
+ if err != nil {
+ rpcErr = err
+ return
+ }
+ case <-r.shutdownCh:
+ // future.respond(ErrRaftShutdown)
return
}
- r.logger.Info("copied to local snapshot", "bytes", n)
// Restore snapshot
future := &restoreFuture{ID: sink.ID()}
from rqlite.
Thanks, I just wanted to know if that was feasible. We should raise an issue in the hashicorp/raft repo and discuss with the maintainers there.
from rqlite.
Related Issues (20)
- Null pointer panic HOT 7
- Add "vtypes" field to API response to indicate actual value types
- Read-only node showing failed to open store: set log info: failed to get last command index HOT 4
- Can't create a empty database in rqlite shell HOT 3
- failed to install snapshot HOT 26
- Leader election times seem too long with max current term HOT 16
- Recovery process can result in old snapshot getting sent to node HOT 43
- Rust sqlx-rqlite HOT 1
- CLI support Home and End key
- Build and upload binaries automatically HOT 4
- Which version of Sqlite dialect is supported? HOT 4
- PRAGMA foreign_keys are turning them off even we turn them on. HOT 4
- connect rqlite over unix sockets HOT 2
- how to debug random "database disk image is malformed" error? HOT 10
- rqlited + DNS client 100% CPU usage after network disconnecting (windows) HOT 21
- CTRL-C should stop the process HOT 1
- [FeatureRequest] Make number of retries configurable for /nodes and potentially other relevant http calls HOT 7
- Build from source fails in Windows VM HOT 7
- Synchronisation bug related to http.Server.AllowedOrigin HOT 1
- Dynamic backup file naming HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rqlite.