From f70a519524d2ce4efbdf739ed874c2bad574c920 Mon Sep 17 00:00:00 2001 From: Chris Tam Date: Wed, 22 Nov 2023 13:10:54 -0500 Subject: [PATCH] Do not try to flush on secondary instances --- src/rdict.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/rdict.rs b/src/rdict.rs index 64161eb..1891f80 100644 --- a/src/rdict.rs +++ b/src/rdict.rs @@ -1020,11 +1020,14 @@ impl Rdict { fn close(&mut self) -> PyResult<()> { let f_opt = &self.flush_opt; let db = self.get_db()?.borrow(); - if let AccessTypeInner::ReadOnly { .. } = self.access_type.0 { - drop(db); - drop(self.column_family.take()); - drop(self.db.take()); - return Ok(()); + match &self.access_type.0 { + AccessTypeInner::ReadOnly { .. } | AccessTypeInner::Secondary { .. } => { + drop(db); + drop(self.column_family.take()); + drop(self.db.take()); + return Ok(()); + } + _ => (), }; let flush_wal_result = db.flush_wal(true); let flush_result = if let Some(cf) = &self.column_family {