Skip to content

Commit 588711d

Browse files
author
Goshawk
committed
Handle persist_chunk call error
1 parent 91c7898 commit 588711d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/data_manager.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,19 @@ impl<T: StorageEngine> DataManagerImpl<T> {
220220
if !exists {
221221
// Due to the usage RocksDB::OptimisticTransaction it is safe here to use read lock
222222
// Any write conflict will be detected by the RocksDB::commit itself.
223-
// However, we don't expect high lock contention here.
224-
if db
223+
// However, we don't expect any lock-per-key contention here so commit errors due to
224+
// conflicts are not expected.
225+
if let Err(err) = db
225226
.read()
226227
.await
227228
.persist_chunk(chunk, chunk_size)
228-
.is_err()
229229
{
230+
println!(
231+
"Failed to persist chunk: {:?}",
232+
err
233+
);
230234
// chunk could not be persisted.
235+
// It could be due to IO error or reaching the max-size limit
231236
// Rollback it from the cache to keep the cache consistent
232237
cache.write().await.remove(&id);
233238
}

0 commit comments

Comments
 (0)