@@ -126,33 +126,39 @@ pub async fn resolve_parseable_metadata() -> Result<StorageMetadata, ObjectStora
126126 Err ( "Could not start the server because staging directory indicates stale data from previous deployment, please choose an empty staging directory and restart the server" )
127127 }
128128 EnvChange :: NewStaging ( mut metadata) => {
129- create_dir_all ( CONFIG . staging_dir ( ) ) ?;
130- metadata. staging = CONFIG . staging_dir ( ) . canonicalize ( ) ?;
131- // this flag is set to true so that metadata is copied to staging
132- overwrite_staging = true ;
133- // overwrite remote in all and query mode
134- // because staging dir has changed.
135- match CONFIG . parseable . mode {
136- Mode :: All => {
137- standalone_when_distributed ( Mode :: from_string ( & metadata. server_mode ) . expect ( "mode should be valid at here" ) )
138- . map_err ( |err| {
139- ObjectStorageError :: Custom ( err. to_string ( ) )
140- } ) ?;
129+ // if server is started in ingest mode,we need to make sure that query mode has been started
130+ // i.e the metadata is updated to reflect the server mode = Query
131+ if Mode :: from_string ( & metadata. server_mode ) . unwrap ( ) == Mode :: All || CONFIG . parseable . mode == Mode :: Ingest {
132+ Err ( "Starting Ingest Mode is not allowed, Since Query Server has not been started yet" )
133+ } else {
134+ create_dir_all ( CONFIG . staging_dir ( ) ) ?;
135+ metadata. staging = CONFIG . staging_dir ( ) . canonicalize ( ) ?;
136+ // this flag is set to true so that metadata is copied to staging
137+ overwrite_staging = true ;
138+ // overwrite remote in all and query mode
139+ // because staging dir has changed.
140+ match CONFIG . parseable . mode {
141+ Mode :: All => {
142+ standalone_when_distributed ( Mode :: from_string ( & metadata. server_mode ) . expect ( "mode should be valid at here" ) )
143+ . map_err ( |err| {
144+ ObjectStorageError :: Custom ( err. to_string ( ) )
145+ } ) ?;
146+ overwrite_remote = true ;
147+ } ,
148+ Mode :: Query => {
141149 overwrite_remote = true ;
142- } ,
143- Mode :: Query => {
144- overwrite_remote = true ;
145- metadata. server_mode = CONFIG . parseable . mode . to_string ( ) ;
146- metadata. staging = CONFIG . staging_dir ( ) . to_path_buf ( ) ;
147- } ,
148- Mode :: Ingest => {
149- // if ingest server is started fetch the metadata from remote
150- // update the server mode for local metadata
151- metadata. server_mode = CONFIG . parseable . mode . to_string ( ) ;
152- metadata. staging = CONFIG . staging_dir ( ) . to_path_buf ( ) ;
153- } ,
150+ metadata. server_mode = CONFIG . parseable . mode . to_string ( ) ;
151+ metadata. staging = CONFIG . staging_dir ( ) . to_path_buf ( ) ;
152+ } ,
153+ Mode :: Ingest => {
154+ // if ingest server is started fetch the metadata from remote
155+ // update the server mode for local metadata
156+ metadata. server_mode = CONFIG . parseable . mode . to_string ( ) ;
157+ metadata. staging = CONFIG . staging_dir ( ) . to_path_buf ( ) ;
158+ } ,
159+ }
160+ Ok ( metadata)
154161 }
155- Ok ( metadata)
156162 }
157163 EnvChange :: CreateBoth => {
158164 create_dir_all ( CONFIG . staging_dir ( ) ) ?;
0 commit comments