Skip to content

Commit

Permalink
[data ingestion] disable inotify for macos (#19195)
Browse files Browse the repository at this point in the history
## Description 

prevents local tests from hanging

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
phoenix-o authored Sep 4, 2024
1 parent e743719 commit aa9dd42
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions crates/sui-data-ingestion-core/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use anyhow::Result;
use backoff::backoff::Backoff;
use futures::StreamExt;
use mysten_metrics::spawn_monitored_task;
use notify::RecursiveMode;
use notify::Watcher;
#[cfg(not(target_os = "macos"))]
use notify::{RecommendedWatcher, RecursiveMode};
use object_store::path::Path;
use object_store::ObjectStore;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -342,9 +342,12 @@ impl CheckpointReader {
(reader, checkpoint_recv, processed_sender, exit_sender)
}

pub async fn run(mut self) -> Result<()> {
let (inotify_sender, mut inotify_recv) = mpsc::channel(1);
std::fs::create_dir_all(self.path.clone()).expect("failed to create a directory");
#[cfg(not(target_os = "macos"))]
fn init_watcher(
inotify_sender: mpsc::Sender<()>,
path: &std::path::Path,
) -> RecommendedWatcher {
use notify::Watcher;
let mut watcher = notify::recommended_watcher(move |res| {
if let Err(err) = res {
eprintln!("watch error: {:?}", err);
Expand All @@ -354,10 +357,19 @@ impl CheckpointReader {
.expect("Failed to send inotify update");
})
.expect("Failed to init inotify");

watcher
.watch(&self.path, RecursiveMode::NonRecursive)
.watch(path, RecursiveMode::NonRecursive)
.expect("Inotify watcher failed");
watcher
}

pub async fn run(mut self) -> Result<()> {
let (_inotify_sender, mut inotify_recv) = mpsc::channel::<()>(1);
std::fs::create_dir_all(self.path.clone()).expect("failed to create a directory");

#[cfg(not(target_os = "macos"))]
let _watcher = Self::init_watcher(_inotify_sender, &self.path);

self.gc_processed_files(self.last_pruned_watermark)
.expect("Failed to clean the directory");

Expand Down

0 comments on commit aa9dd42

Please sign in to comment.