Skip to content

Commit 159e609

Browse files
authored
Merge branch 'main' into bugfix/meta-query-multiple-alternatives
2 parents 492ee9d + 7b77e50 commit 159e609

2 files changed

Lines changed: 24 additions & 19 deletions

File tree

cli/src/bin/annis_bench_queries.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ pub fn create_query_input<M>(
4343
query_language: QueryLanguage::AQL,
4444
timeout: None,
4545
};
46-
let count = if let Ok(count) = cs.count(search_query) {
47-
count
48-
} else {
49-
0
50-
};
46+
let count = cs.count(search_query).unwrap_or_default();
5147
assert_eq!(def.count, count);
5248
});
5349
});

graphannis/src/annis/db/corpusstorage.rs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,28 +1408,16 @@ impl CorpusStorage {
14081408
db.apply_update(update, |_| {})?;
14091409
}
14101410
// start background thread to persists the results
1411-
14121411
let active_background_workers = self.active_background_workers.clone();
14131412
{
14141413
let (lock, _cvar) = &*active_background_workers;
14151414
let mut nr_active_background_workers = lock.lock()?;
14161415
*nr_active_background_workers += 1;
14171416
}
14181417
thread::spawn(move || {
1419-
trace!("Starting background thread to sync WAL updates");
1420-
let lock = db_entry.read().unwrap();
1421-
if let Ok(db) = get_read_or_error(&lock) {
1422-
let db: &AnnotationGraph = db;
1423-
if let Err(e) = db.background_sync_wal_updates() {
1424-
error!("Can't sync changes in background thread: {:?}", e);
1425-
} else {
1426-
trace!("Finished background thread to sync WAL updates");
1427-
}
1418+
if let Err(err) = sync_wal_updates_in_background(db_entry, active_background_workers) {
1419+
error!("Error in WAL update background thread: {}", err);
14281420
}
1429-
let (lock, cvar) = &*active_background_workers;
1430-
let mut nr_active_background_workers = lock.lock().unwrap();
1431-
*nr_active_background_workers -= 1;
1432-
cvar.notify_all();
14331421
});
14341422

14351423
Ok(())
@@ -2739,3 +2727,24 @@ fn create_lockfile_for_directory(db_dir: &Path) -> Result<File> {
27392727

27402728
Ok(lock_file)
27412729
}
2730+
2731+
fn sync_wal_updates_in_background(
2732+
db_entry: Arc<RwLock<CacheEntry>>,
2733+
active_background_workers: Arc<(Mutex<usize>, Condvar)>,
2734+
) -> Result<()> {
2735+
trace!("Starting background thread to sync WAL updates");
2736+
let lock = db_entry.read()?;
2737+
if let Ok(db) = get_read_or_error(&lock) {
2738+
let db: &AnnotationGraph = db;
2739+
if let Err(e) = db.background_sync_wal_updates() {
2740+
error!("Can't sync changes in background thread: {:?}", e);
2741+
} else {
2742+
trace!("Finished background thread to sync WAL updates");
2743+
}
2744+
}
2745+
let (lock, cvar) = &*active_background_workers;
2746+
let mut nr_active_background_workers = lock.lock()?;
2747+
*nr_active_background_workers -= 1;
2748+
cvar.notify_all();
2749+
Ok(())
2750+
}

0 commit comments

Comments
 (0)