From 0325ae3ba328ac7b4215057d2c00ac467dd9d820 Mon Sep 17 00:00:00 2001 From: Connor Brewster Date: Mon, 16 Oct 2023 21:33:43 -0500 Subject: fix(tvix/castore): Fix race when ingesting into castore After finishing the ingestion, the directory putter was not being closed. This caused a race where the root directory node was accessed before the directory node had been flushed to the server. This patch makes it so we close the putter before returning the root node which should ensure that the root node exists on the directory service server before the `ingest_path` function returns. Fixes b/326 Change-Id: Id16cf46bc48962121dde76d3c9c23a845d87d0f1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9761 Tested-by: BuildkiteCI Reviewed-by: flokli --- tvix/castore/src/import.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tvix/castore/src/import.rs b/tvix/castore/src/import.rs index 65f2a30eeae2..e17338756b87 100644 --- a/tvix/castore/src/import.rs +++ b/tvix/castore/src/import.rs @@ -189,6 +189,10 @@ pub async fn ingest_path + Debug>( .await?; if entry.depth() == 0 { + // Make sure all the directories are flushed. + if entry.file_type().is_dir() { + directory_putter.close().await?; + } return Ok(node); } else { // calculate the parent path, and make sure we register the node there. -- cgit 1.4.1