diff --git a/core/lib.rs b/core/lib.rs
index b4197f6d7..dd4a45718 100644
--- a/core/lib.rs
+++ b/core/lib.rs
@@ -518,7 +518,7 @@ impl Database {
view_transaction_states: AllViewsTxState::new(),
metrics: RwLock::new(ConnectionMetrics::new()),
is_nested_stmt: AtomicBool::new(false),
- encryption_key: RefCell::new(None),
+ encryption_key: RwLock::new(None),
encryption_cipher_mode: Cell::new(None),
sync_mode: Cell::new(SyncMode::Full),
data_sync_retry: AtomicBool::new(false),
@@ -1014,7 +1014,7 @@ pub struct Connection {
/// Whether the connection is executing a statement initiated by another statement.
/// Generally this is only true for ParseSchema.
is_nested_stmt: AtomicBool,
- encryption_key: RefCell