summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Kösters <timo@koesters.xyz>2023-08-07 16:04:12 +0000
committerTimo Kösters <timo@koesters.xyz>2023-08-07 16:04:12 +0000
commit888f7e44035d88f4b07d52092cf9b93eb90b5b08 (patch)
tree3108ee680a7f5444dac4b08ad1d9cc7eb619b7bf
parent06ab707c79b58df2eca96add0f419755e3522bdf (diff)
parent06fccbc3405c943ed4ecd2f1ab7528101f2a891c (diff)
downloadconduit-888f7e44035d88f4b07d52092cf9b93eb90b5b08.zip
Merge branch 'more-logging-enrichment' into 'next'
Slightly more logging improvements See merge request famedly/conduit!530
-rw-r--r--src/api/client_server/directory.rs1
-rw-r--r--src/main.rs35
-rw-r--r--src/service/rooms/spaces/mod.rs5
3 files changed, 26 insertions, 15 deletions
diff --git a/src/api/client_server/directory.rs b/src/api/client_server/directory.rs
index a812dbc..50ae9f1 100644
--- a/src/api/client_server/directory.rs
+++ b/src/api/client_server/directory.rs
@@ -221,6 +221,7 @@ pub(crate) async fn get_public_rooms_filtered_helper(
serde_json::from_str(s.content.get())
.map(|c: RoomTopicEventContent| Some(c.topic))
.map_err(|_| {
+ error!("Invalid room topic event in database for room {}", room_id);
Error::bad_database("Invalid room topic event in database.")
})
})?,
diff --git a/src/main.rs b/src/main.rs
index 1975038..c74d6dd 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -40,7 +40,7 @@ use tower_http::{
trace::TraceLayer,
ServiceBuilderExt as _,
};
-use tracing::{error, info, warn};
+use tracing::{debug, error, info, warn};
use tracing_subscriber::{prelude::*, EnvFilter};
pub use conduit::*; // Re-export everything from the library crate
@@ -54,17 +54,7 @@ static GLOBAL: Jemalloc = Jemalloc;
#[tokio::main]
async fn main() {
- // This is needed for opening lots of file descriptors, which tends to
- // happen more often when using RocksDB and making lots of federation
- // connections at startup. The soft limit is usually 1024, and the hard
- // limit is usually 512000; I've personally seen it hit >2000.
- //
- // * https://www.freedesktop.org/software/systemd/man/systemd.exec.html#id-1.12.2.1.17.6
- // * https://github.com/systemd/systemd/commit/0abf94923b4a95a7d89bc526efc84e7ca2b71741
- #[cfg(unix)]
- maximize_fd_limit().expect("should be able to increase the soft limit to the hard limit");
-
- // Initialize DB
+ // Initialize config
let raw_config =
Figment::new()
.merge(
@@ -135,6 +125,16 @@ async fn main() {
tracing::subscriber::set_global_default(subscriber).unwrap();
}
+ // This is needed for opening lots of file descriptors, which tends to
+ // happen more often when using RocksDB and making lots of federation
+ // connections at startup. The soft limit is usually 1024, and the hard
+ // limit is usually 512000; I've personally seen it hit >2000.
+ //
+ // * https://www.freedesktop.org/software/systemd/man/systemd.exec.html#id-1.12.2.1.17.6
+ // * https://github.com/systemd/systemd/commit/0abf94923b4a95a7d89bc526efc84e7ca2b71741
+ #[cfg(unix)]
+ maximize_fd_limit().expect("should be able to increase the soft limit to the hard limit");
+
info!("Loading database");
if let Err(error) = KeyValueDatabase::load_or_create(config).await {
error!(?error, "The database couldn't be loaded or created");
@@ -569,12 +569,19 @@ fn method_to_filter(method: Method) -> MethodFilter {
}
#[cfg(unix)]
+#[tracing::instrument(err)]
fn maximize_fd_limit() -> Result<(), nix::errno::Errno> {
use nix::sys::resource::{getrlimit, setrlimit, Resource};
let res = Resource::RLIMIT_NOFILE;
- let (_, hard_limit) = getrlimit(res)?;
+ let (soft_limit, hard_limit) = getrlimit(res)?;
+
+ debug!("Current nofile soft limit: {soft_limit}");
- setrlimit(res, hard_limit, hard_limit)
+ setrlimit(res, hard_limit, hard_limit)?;
+
+ debug!("Increased nofile soft limit to {hard_limit}");
+
+ Ok(())
}
diff --git a/src/service/rooms/spaces/mod.rs b/src/service/rooms/spaces/mod.rs
index e92fc07..9b57d53 100644
--- a/src/service/rooms/spaces/mod.rs
+++ b/src/service/rooms/spaces/mod.rs
@@ -326,7 +326,10 @@ impl Service {
.map_or(Ok(None), |s| {
serde_json::from_str(s.content.get())
.map(|c: RoomTopicEventContent| Some(c.topic))
- .map_err(|_| Error::bad_database("Invalid room topic event in database."))
+ .map_err(|_| {
+ error!("Invalid room topic event in database for room {}", room_id);
+ Error::bad_database("Invalid room topic event in database.")
+ })
})?,
world_readable: services()
.rooms