about summary refs log tree commit diff
path: root/tvix/Cargo.nix
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-06-16T08·43+0300
committerflokli <flokli@flokli.de>2024-06-16T12·02+0000
commit7e42b4f314c2136366c4456f2af894108e765abf (patch)
treecee3fb45a378c76ff9d62bf18ce0118e9d3cfbe1 /tvix/Cargo.nix
parent452299dcd205847477874698740626af041705df (diff)
fix(tvix/store/bin): fix shutdown behaviour for FUSE r/8285
Both umounts happening from another process, as well as tvix-store
itself calling umount() on FuseDaemon will cause the FUSE worker threads
to terminate.

So far there was no nice way to wait on these threads to be terminated
from multiple places, causing the `tvix-store mount` command to only be
terminated if interrupted via ctrl-c, not via an external umount.

Update FuseDaemon to use a ThreadPool, which gives us a join primitive
over all threads, that can also be called from multiple places.

Await on a join() from there to end the program, not the ctrl-c signal
handler as it was before.

Using FuseDaemon from multiple tasks requires Arc<>-ing both the
ThreadPool as well as the inner FuseSession (which also needs to be
inside a Mutex if we want to unmount), but now we can clone FuseDaemon
around and use it in two places. We could probably also have used an
Option and drop the FuseSession after the first umount, but this looks
cleaner.

Change-Id: Id635ef59b560c111db52ad0b3ca3d12bc7ae28ca
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11825
Reviewed-by: Brian Olsen <me@griff.name>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/Cargo.nix')
-rw-r--r--tvix/Cargo.nix25
1 files changed, 24 insertions, 1 deletions
diff --git a/tvix/Cargo.nix b/tvix/Cargo.nix
index 3b8c45bf48f4..cd8ec667f36d 100644
--- a/tvix/Cargo.nix
+++ b/tvix/Cargo.nix
@@ -11293,6 +11293,24 @@ rec {
         ];
         features = { };
       };
+      "threadpool" = rec {
+        crateName = "threadpool";
+        version = "1.8.1";
+        edition = "2015";
+        sha256 = "1amgfyzvynbm8pacniivzq9r0fh3chhs7kijic81j76l6c5ycl6h";
+        authors = [
+          "The Rust Project Developers"
+          "Corey Farwell <coreyf@rwell.org>"
+          "Stefan Schindler <dns2utf8@estada.ch>"
+        ];
+        dependencies = [
+          {
+            name = "num_cpus";
+            packageId = "num_cpus";
+          }
+        ];
+
+      };
       "tikv-jemalloc-sys" = rec {
         crateName = "tikv-jemalloc-sys";
         version = "0.5.4+5.3.0-patched";
@@ -13320,6 +13338,11 @@ rec {
             packageId = "thiserror";
           }
           {
+            name = "threadpool";
+            packageId = "threadpool";
+            optional = true;
+          }
+          {
             name = "tokio";
             packageId = "tokio";
             features = [ "fs" "macros" "net" "rt" "rt-multi-thread" "signal" ];
@@ -13445,7 +13468,7 @@ rec {
         features = {
           "cloud" = [ "dep:bigtable_rs" "object_store/aws" "object_store/azure" "object_store/gcp" ];
           "default" = [ "cloud" ];
-          "fs" = [ "dep:libc" "dep:fuse-backend-rs" ];
+          "fs" = [ "dep:fuse-backend-rs" "dep:threadpool" "dep:libc" ];
           "fuse" = [ "fs" ];
           "tonic-reflection" = [ "dep:tonic-reflection" ];
           "virtiofs" = [ "fs" "dep:vhost" "dep:vhost-user-backend" "dep:virtio-queue" "dep:vm-memory" "dep:vmm-sys-util" "dep:virtio-bindings" "fuse-backend-rs?/vhost-user-fs" "fuse-backend-rs?/virtiofs" ];