mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-25 01:59:08 -05:00
improvement: remove pauses for backups, likely not needed w/ WAL compaction
This commit is contained in:
parent
7774db8c47
commit
14fe9f9ee1
16
src/db.rs
16
src/db.rs
|
@ -44,10 +44,6 @@ pub const DB_FILE: &str = "nostr.db";
|
||||||
/// How frequently to attempt checkpointing
|
/// How frequently to attempt checkpointing
|
||||||
pub const CHECKPOINT_FREQ_SEC: u64 = 60;
|
pub const CHECKPOINT_FREQ_SEC: u64 = 60;
|
||||||
|
|
||||||
/// How many persisted events before we pause for backups.
|
|
||||||
/// It isn't clear this is enough to make the online backup API work yet.
|
|
||||||
pub const EVENT_COUNT_BACKUP_PAUSE_TRIGGER: usize = 1000;
|
|
||||||
|
|
||||||
/// Build a database connection pool.
|
/// Build a database connection pool.
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
|
@ -184,10 +180,6 @@ pub async fn db_writer(
|
||||||
let rps_setting = settings.limits.messages_per_sec;
|
let rps_setting = settings.limits.messages_per_sec;
|
||||||
let mut most_recent_rate_limit = Instant::now();
|
let mut most_recent_rate_limit = Instant::now();
|
||||||
let mut lim_opt = None;
|
let mut lim_opt = None;
|
||||||
// Constant writing has interfered with online backups. Keep
|
|
||||||
// track of how long since we've given the backups a chance to
|
|
||||||
// run.
|
|
||||||
let mut backup_pause_counter: usize = 0;
|
|
||||||
let clock = governor::clock::QuantaClock::default();
|
let clock = governor::clock::QuantaClock::default();
|
||||||
if let Some(rps) = rps_setting {
|
if let Some(rps) = rps_setting {
|
||||||
if rps > 0 {
|
if rps > 0 {
|
||||||
|
@ -340,12 +332,6 @@ pub async fn db_writer(
|
||||||
notice_tx.try_send(Notice::error(event.id, msg)).ok();
|
notice_tx.try_send(Notice::error(event.id, msg)).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
backup_pause_counter += 1;
|
|
||||||
if backup_pause_counter > EVENT_COUNT_BACKUP_PAUSE_TRIGGER {
|
|
||||||
info!("pausing db write thread for a moment...");
|
|
||||||
thread::sleep(Duration::from_millis(500));
|
|
||||||
backup_pause_counter = 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// use rate limit, if defined, and if an event was actually written.
|
// use rate limit, if defined, and if an event was actually written.
|
||||||
|
@ -919,4 +905,4 @@ pub async fn db_query(
|
||||||
let ok: Result<()> = Ok(());
|
let ok: Result<()> = Ok(());
|
||||||
ok
|
ok
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user