File tree Expand file tree Collapse file tree
libsql-server/src/namespace Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -495,11 +495,18 @@ impl MetaStore {
495495 pub fn remove ( & self , namespace : NamespaceName ) -> Result < Option < Arc < DatabaseConfig > > > {
496496 tracing:: debug!( "removing namespace `{}` from meta store" , namespace) ;
497497
498+ // "configs" lock can be used in both async and sync contexts while "conn" lock always used
499+ // in blocking context
500+ //
501+ // so, we better to acquire "conn" lock first in order to prevent situation when "configs"
502+ // lock is taken but "conn" lock is not free (so, we potentially will block async tasks for
503+ // indefinite amount of time while "conn" lock will be acquired by other thread)
504+ let mut conn = self . inner . conn . blocking_lock ( ) ;
505+
498506 let mut configs = self . inner . configs . blocking_lock ( ) ;
499507 let r = if let Some ( sender) = configs. get ( & namespace) {
500508 tracing:: debug!( "removed namespace `{}` from meta store" , namespace) ;
501509 let config = sender. borrow ( ) . clone ( ) ;
502- let mut conn = self . inner . conn . blocking_lock ( ) ;
503510 let tx = conn. transaction ( ) ?;
504511 if config. config . is_shared_schema {
505512 if crate :: schema:: db:: schema_has_linked_dbs ( & tx, & namespace) ? {
You can’t perform that action at this time.
0 commit comments