@@ -374,6 +374,30 @@ pub async fn status_2pc<S: ControlStateDelegate + NodeDelegate>(
374374 Ok ( ( StatusCode :: OK , decision) )
375375}
376376
377+ /// 2PC commit-ack endpoint.
378+ ///
379+ /// Called by participant B after it commits via the status-poll recovery path,
380+ /// so that the coordinator can delete its `st_2pc_coordinator_log` entry.
381+ ///
382+ /// `POST /v1/database/:name_or_identity/2pc/ack-commit/:prepare_id`
383+ pub async fn ack_commit_2pc < S : ControlStateDelegate + NodeDelegate > (
384+ State ( worker_ctx) : State < S > ,
385+ Extension ( _auth) : Extension < SpacetimeAuth > ,
386+ Path ( TwoPcParams {
387+ name_or_identity,
388+ prepare_id,
389+ } ) : Path < TwoPcParams > ,
390+ ) -> axum:: response:: Result < impl IntoResponse > {
391+ let ( module, _database) = find_module_and_database ( & worker_ctx, name_or_identity) . await ?;
392+
393+ module. ack_2pc_coordinator_commit ( & prepare_id) . map_err ( |e| {
394+ log:: error!( "2PC ack-commit failed: {e}" ) ;
395+ ( StatusCode :: INTERNAL_SERVER_ERROR , e. to_string ( ) ) . into_response ( )
396+ } ) ?;
397+
398+ Ok ( StatusCode :: OK )
399+ }
400+
377401fn reducer_outcome_response (
378402 module : & ModuleHost ,
379403 owner_identity : & Identity ,
@@ -1388,6 +1412,8 @@ pub struct DatabaseRoutes<S> {
13881412 pub abort_2pc_post : MethodRouter < S > ,
13891413 /// GET: /database/:name_or_identity/2pc/status/:prepare_id
13901414 pub status_2pc_get : MethodRouter < S > ,
1415+ /// POST: /database/:name_or_identity/2pc/ack-commit/:prepare_id
1416+ pub ack_commit_2pc_post : MethodRouter < S > ,
13911417}
13921418
13931419impl < S > Default for DatabaseRoutes < S >
@@ -1417,6 +1443,7 @@ where
14171443 commit_2pc_post : post ( commit_2pc :: < S > ) ,
14181444 abort_2pc_post : post ( abort_2pc :: < S > ) ,
14191445 status_2pc_get : get ( status_2pc :: < S > ) ,
1446+ ack_commit_2pc_post : post ( ack_commit_2pc :: < S > ) ,
14201447 }
14211448 }
14221449}
@@ -1445,7 +1472,8 @@ where
14451472 . route ( "/prepare/:reducer" , self . prepare_post )
14461473 . route ( "/2pc/commit/:prepare_id" , self . commit_2pc_post )
14471474 . route ( "/2pc/abort/:prepare_id" , self . abort_2pc_post )
1448- . route ( "/2pc/status/:prepare_id" , self . status_2pc_get ) ;
1475+ . route ( "/2pc/status/:prepare_id" , self . status_2pc_get )
1476+ . route ( "/2pc/ack-commit/:prepare_id" , self . ack_commit_2pc_post ) ;
14491477
14501478 axum:: Router :: new ( )
14511479 . route ( "/" , self . root_post )
0 commit comments