@@ -1298,7 +1298,8 @@ def _execute_partitioned_dml_helper(
12981298 ("x-goog-spanner-route-to-leader" , "true" ),
12991299 (
13001300 "x-goog-spanner-request-id" ,
1301- f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .1.2" ,
1301+ # Please note that this try was by an abort and not from service unavailable.
1302+ f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .3.1" ,
13021303 ),
13031304 ],
13041305 )
@@ -1370,14 +1371,32 @@ def _execute_partitioned_dml_helper(
13701371 query_options = expected_query_options ,
13711372 request_options = expected_request_options ,
13721373 )
1374+
1375+ api .begin_transaction .assert_called_with (
1376+ session = self .SESSION_NAME ,
1377+ options = txn_options ,
1378+ metadata = [
1379+ ("google-cloud-resource-prefix" , database .name ),
1380+ ("x-goog-spanner-route-to-leader" , "true" ),
1381+ (
1382+ "x-goog-spanner-request-id" ,
1383+ # Retrying on an aborted response involves creating the transaction afresh
1384+ # and also re-invoking execute_streaming_sql, hence the fresh request 4.1.
1385+ f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .3.1" ,
1386+ ),
1387+ ],
1388+ )
1389+
13731390 api .execute_streaming_sql .assert_called_with (
13741391 request = expected_request ,
13751392 metadata = [
13761393 ("google-cloud-resource-prefix" , database .name ),
13771394 ("x-goog-spanner-route-to-leader" , "true" ),
13781395 (
13791396 "x-goog-spanner-request-id" ,
1380- f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .2.2" ,
1397+ # Retrying on an aborted response involves creating the transaction afresh
1398+ # and also re-invoking execute_streaming_sql, hence the fresh request 4.1.
1399+ f"1.{ REQ_RAND_PROCESS_ID } .{ database ._nth_client_id } .{ database ._channel_id } .4.1" ,
13811400 ),
13821401 ],
13831402 )
0 commit comments