You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR makes bunch of changes to ways how local sync
and s3 sync threads are managed inside parseable. The
goal is to make parseable main thread be aware of unwanted
failure inside either of these dedicated sync thread. Additionally
we want to have control over life cycle of these threads and
have them stop on command, This can be later explored in
future if we want to have graceful shutdown an also to
guarantee more data consistency in case of failure.
This solution works something like this:
Sync threads are spawned with pair of one shot channels
(named with suffix inbox and outbox) for communication with
main thread.
inbox is sender type which can be used to stop the respective
thread by breaking its scheduler loop. outbox is receiver type
which is polled inside the main thread's looped select. So that
whenever we receive a message from thread we stop.
scheduler is ran inside loop which runs pending tasks and polls
the channel for any message from main thread
( if any then stop the thread )
All of this is wrapped by a catch unwind. So in case of an
unwinding because of panic there is a chance to let main thread
know and handle accordingly. This is added as a safeguard for
now but later we need to verify that local_sync and s3_sync
don't have anything that can panic.
Fixes#43
// actix server finished .. stop other threads and stop the server
80
+
s3sync_inbox.send(()).unwrap_or(());
81
+
localsync_inbox.send(()).unwrap_or(());
82
+
localsync_handler.join().unwrap_or(());
83
+
s3sync_handler.join().unwrap_or(());
84
+
return e
85
+
},
86
+
_ = &mut localsync_outbox => {
87
+
// crash the server if localsync fails for any reason
88
+
// panic!("Local Sync thread died. Server will fail now!")
89
+
returnErr(anyhow::Error::msg("Failed to sync local data to disc. This can happen due to critical error in disc or environment. Please restart the Parseable server.\n\nJoin us on Parseable Slack if the issue persists after restart : https://launchpass.com/parseable"))
90
+
},
91
+
_ = &mut s3sync_outbox => {
92
+
// s3sync failed, this is recoverable by just starting s3sync thread again
0 commit comments