@@ -1627,20 +1627,17 @@ public void testPartitionedQuery_receivesUnimplemented_fallsBackToRegularSession
16271627 // will then fail.
16281628 mockSpanner .unfreeze ();
16291629
1630- SpannerException e =
1631- assertThrows (
1632- SpannerException .class ,
1633- () ->
1634- runner .run (
1635- transaction -> {
1636- ResultSet resultSet = transaction .executeQuery (STATEMENT );
1637- //noinspection StatementWithEmptyBody
1638- while (resultSet .next ()) {
1639- // ignore
1640- }
1641- return null ;
1642- }));
1643- assertEquals (ErrorCode .UNIMPLEMENTED , e .getErrorCode ());
1630+ // The ExecuteStreamingSql call fails with UNIMPLEMENTED error, but the retry should happen
1631+ // internally with regular session.
1632+ runner .run (
1633+ transaction -> {
1634+ ResultSet resultSet = transaction .executeQuery (STATEMENT );
1635+ //noinspection StatementWithEmptyBody
1636+ while (resultSet .next ()) {
1637+ // ignore
1638+ }
1639+ return null ;
1640+ });
16441641
16451642 // Wait until the client sees that MultiplexedSessions are not supported for read-write.
16461643 assertNotNull (client .multiplexedSessionDatabaseClient );
@@ -1667,17 +1664,25 @@ public void testPartitionedQuery_receivesUnimplemented_fallsBackToRegularSession
16671664
16681665 // Verify that two ExecuteSqlRequests were received: the first using a multiplexed session and
16691666 // the second using a regular session.
1670- assertEquals (2 , mockSpanner .countRequestsOfType (ExecuteSqlRequest .class ));
1667+ assertEquals (3 , mockSpanner .countRequestsOfType (ExecuteSqlRequest .class ));
16711668 List <ExecuteSqlRequest > requests = mockSpanner .getRequestsOfType (ExecuteSqlRequest .class );
16721669
1670+ // The ExecuteSqlRequest of the first read-write transaction should use multiplexed session.
16731671 Session session1 = mockSpanner .getSession (requests .get (0 ).getSession ());
16741672 assertNotNull (session1 );
16751673 assertTrue (session1 .getMultiplexed ());
16761674
1675+ // Retry of the ExecuteSqlRequest of the first read-write transaction should use regular
1676+ // session.
16771677 Session session2 = mockSpanner .getSession (requests .get (1 ).getSession ());
16781678 assertNotNull (session2 );
16791679 assertFalse (session2 .getMultiplexed ());
16801680
1681+ // The ExecuteSqlRequest of the second read-write transaction should use regular session.
1682+ Session session3 = mockSpanner .getSession (requests .get (2 ).getSession ());
1683+ assertNotNull (session3 );
1684+ assertFalse (session3 .getMultiplexed ());
1685+
16811686 assertNotNull (client .multiplexedSessionDatabaseClient );
16821687 assertEquals (1L , client .multiplexedSessionDatabaseClient .getNumSessionsAcquired ().get ());
16831688 assertEquals (1L , client .multiplexedSessionDatabaseClient .getNumSessionsReleased ().get ());
@@ -1711,22 +1716,17 @@ public void testReadWriteUnimplemented_firstReceivesError_secondFallsBackToRegul
17111716 assertNotNull (txn .getId ());
17121717 assertFalse (client .multiplexedSessionDatabaseClient .unimplementedForRW .get ());
17131718
1714- SpannerException e =
1715- assertThrows (
1716- SpannerException .class ,
1717- () ->
1718- client
1719- .readWriteTransaction ()
1720- .run (
1721- transaction -> {
1722- ResultSet resultSet = transaction .executeQuery (STATEMENT );
1723- //noinspection StatementWithEmptyBody
1724- while (resultSet .next ()) {
1725- // ignore
1726- }
1727- return null ;
1728- }));
1729- assertEquals (ErrorCode .UNIMPLEMENTED , e .getErrorCode ());
1719+ client
1720+ .readWriteTransaction ()
1721+ .run (
1722+ transaction -> {
1723+ ResultSet resultSet = transaction .executeQuery (STATEMENT );
1724+ //noinspection StatementWithEmptyBody
1725+ while (resultSet .next ()) {
1726+ // ignore
1727+ }
1728+ return null ;
1729+ });
17301730
17311731 // Verify that the previous failed transaction has marked multiplexed session client to be
17321732 // unimplemented for read-write.
@@ -1748,17 +1748,25 @@ public void testReadWriteUnimplemented_firstReceivesError_secondFallsBackToRegul
17481748
17491749 // Verify that two ExecuteSqlRequests were received: the first using a multiplexed session and
17501750 // the second using a regular session.
1751- assertEquals (2 , mockSpanner .countRequestsOfType (ExecuteSqlRequest .class ));
1751+ assertEquals (3 , mockSpanner .countRequestsOfType (ExecuteSqlRequest .class ));
17521752 List <ExecuteSqlRequest > requests = mockSpanner .getRequestsOfType (ExecuteSqlRequest .class );
17531753
1754+ // The ExecuteSqlRequest of the first read-write transaction should use multiplexed session.
17541755 Session session1 = mockSpanner .getSession (requests .get (0 ).getSession ());
17551756 assertNotNull (session1 );
17561757 assertTrue (session1 .getMultiplexed ());
17571758
1759+ // Retry of the ExecuteSqlRequest of the first read-write transaction should use regular
1760+ // session.
17581761 Session session2 = mockSpanner .getSession (requests .get (1 ).getSession ());
17591762 assertNotNull (session2 );
17601763 assertFalse (session2 .getMultiplexed ());
17611764
1765+ // The ExecuteSqlRequest of the second read-write transaction should use regular session.
1766+ Session session3 = mockSpanner .getSession (requests .get (1 ).getSession ());
1767+ assertNotNull (session3 );
1768+ assertFalse (session3 .getMultiplexed ());
1769+
17621770 assertNotNull (client .multiplexedSessionDatabaseClient );
17631771 assertEquals (1L , client .multiplexedSessionDatabaseClient .getNumSessionsAcquired ().get ());
17641772 assertEquals (1L , client .multiplexedSessionDatabaseClient .getNumSessionsReleased ().get ());
0 commit comments