You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by ms...@apache.org on 2021/12/02 23:55:40 UTC

[incubator-teaclave] branch master updated: [Mod] Flush DB and compact_range after dequeue operation. (#585)

This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git


The following commit(s) were added to refs/heads/master by this push:
     new 2fcf051  [Mod] Flush DB and compact_range after dequeue operation. (#585)
2fcf051 is described below

commit 2fcf051298ab93057c7553303c5e24e4eb695c36
Author: Zhaofeng Chen <zf...@apache.org>
AuthorDate: Thu Dec 2 15:55:33 2021 -0800

    [Mod] Flush DB and compact_range after dequeue operation. (#585)
---
 services/storage/enclave/src/service.rs | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/services/storage/enclave/src/service.rs b/services/storage/enclave/src/service.rs
index 5a10341..6651ada 100644
--- a/services/storage/enclave/src/service.rs
+++ b/services/storage/enclave/src/service.rs
@@ -113,6 +113,10 @@ impl<'a> DBQueue<'a> {
         self.database
             .put(&self.get_tail_key(), &tail_index.to_le_bytes())
             .map_err(TeaclaveStorageError::LevelDb)?;
+
+        self.database
+            .flush()
+            .map_err(TeaclaveStorageError::LevelDb)?;
         Ok(())
     }
 
@@ -134,8 +138,12 @@ impl<'a> DBQueue<'a> {
             self.database
                 .put(&self.get_head_key(), &head_index.to_le_bytes())
                 .map_err(TeaclaveStorageError::LevelDb)?;
-            // delete element; it's ok to ignore the error
-            let _ = self.database.delete(&element_key);
+            self.database
+                .delete(&element_key)
+                .map_err(TeaclaveStorageError::LevelDb)?;
+            self.database
+                .compact_range(b"queue", b"queuf")
+                .map_err(TeaclaveStorageError::LevelDb)?;
             Ok(result)
         }
     }
@@ -189,6 +197,11 @@ impl TeaclaveStorage for TeaclaveStorageService {
             .borrow_mut()
             .put(&request.key, &request.value)
             .map_err(TeaclaveStorageError::LevelDb)?;
+
+        self.database
+            .borrow_mut()
+            .flush()
+            .map_err(TeaclaveStorageError::LevelDb)?;
         Ok(PutResponse)
     }
 
@@ -201,6 +214,11 @@ impl TeaclaveStorage for TeaclaveStorageService {
             .borrow_mut()
             .delete(&request.key)
             .map_err(TeaclaveStorageError::LevelDb)?;
+
+        self.database
+            .borrow_mut()
+            .flush()
+            .map_err(TeaclaveStorageError::LevelDb)?;
         Ok(DeleteResponse)
     }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org