From 7668096e510ab192dee03c4eabd0b91ad74b9b9a Mon Sep 17 00:00:00 2001 From: Chris H-C Date: Mon, 16 Jan 2023 15:38:33 +0000 Subject: [PATCH] Bug 1810205 - Eat notfound io errors in kvstore r=jstutte,janerik Differential Revision: https://phabricator.services.mozilla.com/D166816 --- toolkit/components/kvstore/src/task.rs | 40 +++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/toolkit/components/kvstore/src/task.rs b/toolkit/components/kvstore/src/task.rs index 38beb6b0fa97..3608dc9665ab 100644 --- a/toolkit/components/kvstore/src/task.rs +++ b/toolkit/components/kvstore/src/task.rs @@ -278,7 +278,15 @@ impl Task for PutTask { Err(err) => return Err(KeyValueError::StoreError(err)), } - writer.commit()?; + // Ignore errors caused by simultaneous access. + // We intend to investigate/revert this in bug 1810212. + match writer.commit() { + Err(StoreError::IoError(e)) if e.kind() == std::io::ErrorKind::NotFound => { + // Explicitly ignore errors from simultaneous access. + } + Err(e) => return Err(From::from(e)), + _ => (), + }; break; } @@ -383,7 +391,15 @@ impl Task for WriteManyTask { } } - writer.commit()?; + // Ignore errors caused by simultaneous access. + // We intend to investigate/revert this in bug 1810212. + match writer.commit() { + Err(StoreError::IoError(e)) if e.kind() == std::io::ErrorKind::NotFound => { + // Explicitly ignore errors from simultaneous access. + } + Err(e) => return Err(From::from(e)), + _ => (), + }; break; // 'outer: loop } @@ -543,7 +559,15 @@ impl Task for DeleteTask { Err(err) => return Err(KeyValueError::StoreError(err)), }; - writer.commit()?; + // Ignore errors caused by simultaneous access. + // We intend to investigate/revert this in bug 1810212. + match writer.commit() { + Err(StoreError::IoError(e)) if e.kind() == std::io::ErrorKind::NotFound => { + // Explicitly ignore errors from simultaneous access. + } + Err(e) => return Err(From::from(e)), + _ => (), + }; Ok(()) }())); @@ -582,7 +606,15 @@ impl Task for ClearTask { let env = self.rkv.read()?; let mut writer = env.write()?; self.store.clear(&mut writer)?; - writer.commit()?; + // Ignore errors caused by simultaneous access. + // We intend to investigate/revert this in bug 1810212. + match writer.commit() { + Err(StoreError::IoError(e)) if e.kind() == std::io::ErrorKind::NotFound => { + // Explicitly ignore errors from simultaneous access. + } + Err(e) => return Err(From::from(e)), + _ => (), + }; Ok(()) }()));