about summary refs log tree commit diff
path: root/tvix/store/src/pathinfoservice
diff options
context:
space:
mode:
authorIlan Joselevich <personal@ilanjoselevich.com>2024-07-29T14·59+0300
committerIlan Joselevich <personal@ilanjoselevich.com>2024-07-29T15·50+0000
commit9cbebfea279e0972bcedff6225ca5152a6542a3f (patch)
tree257c44f60fd0d1140a6fa04724393fa4e0fae4cf /tvix/store/src/pathinfoservice
parenta794790203b48ac50490f4fa0bfd66cbbb7e29c4 (diff)
fix(tvix/store) RedbPathInfoService: improve logs and errors r/8422
Add more logging and remove context from errors because that's already
provided by the logs (Errors also need to be refactored anyway, there's
also confusion about StorageError vs InvalidRequest, there's no
consistency)

Change-Id: Ia43c0d237d9075152490c635b05fb3fb343abcc8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12058
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/store/src/pathinfoservice')
-rw-r--r--tvix/store/src/pathinfoservice/redb.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/tvix/store/src/pathinfoservice/redb.rs b/tvix/store/src/pathinfoservice/redb.rs
index 180ec3ef7695..bd0e0fc2b686 100644
--- a/tvix/store/src/pathinfoservice/redb.rs
+++ b/tvix/store/src/pathinfoservice/redb.rs
@@ -56,9 +56,9 @@ impl RedbPathInfoService {
 }
 
 /// Ensures all tables are present.
+/// Opens a write transaction and calls open_table on PATHINFO_TABLE, which will
+/// create it if not present.
 fn create_schema(db: &redb::Database) -> Result<(), redb::Error> {
-    // Opens a write transaction and calls open_table on PATHINFO_TABLE, which will
-    // create it if not present.
     let txn = db.begin_write()?;
     txn.open_table(PATHINFO_TABLE)?;
     txn.commit()?;
@@ -80,7 +80,7 @@ impl PathInfoService for RedbPathInfoService {
                     Some(pathinfo_bytes) => Ok(Some(
                         PathInfo::decode(pathinfo_bytes.value().as_slice()).map_err(|e| {
                             warn!(err=%e, "failed to decode stored PathInfo");
-                            Error::StorageError(format!("failed to decode stored PathInfo: {}", e))
+                            Error::StorageError("failed to decode stored PathInfo".to_string())
                         })?,
                     )),
                     None => Ok(None),
@@ -95,7 +95,10 @@ impl PathInfoService for RedbPathInfoService {
         // Call validate on the received PathInfo message.
         let store_path = path_info
             .validate()
-            .map_err(|e| Error::InvalidRequest(format!("failed to validate PathInfo: {}", e)))?
+            .map_err(|e| {
+                warn!(err=%e, "failed to validate PathInfo");
+                Error::StorageError("failed to validate PathInfo".to_string())
+            })?
             .to_owned();
 
         let path_info_encoded = path_info.encode_to_vec();
@@ -110,7 +113,7 @@ impl PathInfoService for RedbPathInfoService {
                         .insert(store_path.digest(), path_info_encoded)
                         .map_err(|e| {
                             warn!(err=%e, "failed to insert PathInfo");
-                            Error::StorageError(format!("failed to insert PathInfo: {}", e))
+                            Error::StorageError("failed to insert PathInfo".to_string())
                         })?;
                 }
                 Ok(txn.commit()?)
@@ -136,7 +139,8 @@ impl PathInfoService for RedbPathInfoService {
                     tokio::runtime::Handle::current()
                         .block_on(tx.send(Ok(
                             PathInfo::decode(elem.1.value().as_slice()).map_err(|e| {
-                                Error::InvalidRequest(format!("invalid PathInfo: {}", e))
+                                warn!(err=%e, "invalid PathInfo");
+                                Error::StorageError("invalid PathInfo".to_string())
                             })?,
                         )))
                         .map_err(|e| Error::StorageError(e.to_string()))?;