Skip to content

Commit f475f9d

Browse files
committed
Add more logging around active_drop_spawns
1 parent a294778 commit f475f9d

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

nativelink-store/src/filesystem_store.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,15 @@ impl Drop for EncodedFilePath {
122122

123123
let file_path = self.get_file_path().to_os_string();
124124
let shared_context = self.shared_context.clone();
125-
shared_context
125+
// .fetch_add returns previous value, so we add one to get approximate current value
126+
let current_active_drop_spawns = shared_context
126127
.active_drop_spawns
127-
.fetch_add(1, Ordering::Relaxed);
128+
.fetch_add(1, Ordering::Relaxed)
129+
+ 1;
130+
debug!(
131+
?current_active_drop_spawns,
132+
"Spawned a filesystem_delete_file"
133+
);
128134
background_spawn!("filesystem_delete_file", async move {
129135
let result = fs::remove_file(&file_path)
130136
.await
@@ -134,9 +140,15 @@ impl Drop for EncodedFilePath {
134140
} else {
135141
debug!(?file_path, "File deleted",);
136142
}
137-
shared_context
143+
// .fetch_sub returns previous value, so we subtract one to get approximate current value
144+
let current_active_drop_spawns = shared_context
138145
.active_drop_spawns
139-
.fetch_sub(1, Ordering::Relaxed);
146+
.fetch_sub(1, Ordering::Relaxed)
147+
- 1;
148+
debug!(
149+
?current_active_drop_spawns,
150+
"Dropped a filesystem_delete_file"
151+
);
140152
});
141153
}
142154
}

nativelink-store/tests/filesystem_store_test.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,13 @@ async fn temp_files_get_deleted_on_replace_test() -> Result<(), Error> {
367367
tokio::task::yield_now().await;
368368
}
369369

370+
assert!(logs_contain(
371+
"Spawned a filesystem_delete_file current_active_drop_spawns=1"
372+
));
373+
assert!(logs_contain(
374+
"Dropped a filesystem_delete_file current_active_drop_spawns=0"
375+
));
376+
370377
check_temp_empty(&temp_path).await
371378
}
372379

0 commit comments

Comments
 (0)