File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,6 +128,8 @@ pub enum Error {
128128 RuntimeTaskJoinError ( #[ from] tokio:: task:: JoinError ) ,
129129 #[ error( "wal error: {0}" ) ]
130130 LibsqlWal ( #[ from] libsql_wal:: error:: Error ) ,
131+ #[ error( "database is not a primary" ) ]
132+ NotAPrimary ,
131133}
132134
133135impl AsRef < Self > for Error {
@@ -224,6 +226,7 @@ impl IntoResponse for &Error {
224226 AttachInMigration => self . format_err ( StatusCode :: BAD_REQUEST ) ,
225227 RuntimeTaskJoinError ( _) => self . format_err ( StatusCode :: INTERNAL_SERVER_ERROR ) ,
226228 LibsqlWal ( _) => self . format_err ( StatusCode :: INTERNAL_SERVER_ERROR ) ,
229+ NotAPrimary => self . format_err ( StatusCode :: BAD_REQUEST ) ,
227230 }
228231 }
229232}
Original file line number Diff line number Diff line change @@ -98,11 +98,13 @@ pub(super) async fn handle_dump(
9898 let conn_maker = state
9999 . namespaces
100100 . with ( namespace, |ns| {
101- assert ! ( ns. db. is_primary( ) ) ;
102- ns. db . connection_maker ( )
101+ if !ns. db . is_primary ( ) {
102+ return Err ( Error :: NotAPrimary ) ;
103+ }
104+
105+ Ok :: < _ , crate :: Error > ( ns. db . connection_maker ( ) )
103106 } )
104- . await
105- . unwrap ( ) ;
107+ . await ??;
106108
107109 let conn = conn_maker. create ( ) . await . unwrap ( ) ;
108110
You can’t perform that action at this time.
0 commit comments