@@ -483,13 +483,14 @@ public void test_failFromWriterWhereKeepSessionStateOnFailoverIsTrue()
483
483
conn .setAutoCommit (false );
484
484
485
485
final Statement testStmt1 = conn .createStatement ();
486
- testStmt1 .executeUpdate ("DROP TABLE IF EXISTS test3_2 " );
486
+ testStmt1 .executeUpdate ("DROP TABLE IF EXISTS test3_3 " );
487
487
testStmt1 .executeUpdate (
488
- "CREATE TABLE test3_2 (id int not null primary key, test3_2_field varchar(255) not null)" );
488
+ "CREATE TABLE test3_3 (id int not null primary key, test3_3_field varchar(255) not null)" );
489
489
conn .setAutoCommit (false ); // open a new transaction
490
+ conn .commit ();
490
491
491
492
final Statement testStmt2 = conn .createStatement ();
492
- testStmt2 .executeUpdate ("INSERT INTO test3_2 VALUES (1, 'test field string 1')" );
493
+ testStmt2 .executeUpdate ("INSERT INTO test3_3 VALUES (1, 'test field string 1')" );
493
494
494
495
auroraUtil .failoverClusterAndWaitUntilWriterChanged ();
495
496
@@ -498,7 +499,7 @@ public void test_failFromWriterWhereKeepSessionStateOnFailoverIsTrue()
498
499
assertThrows (
499
500
SQLException .class ,
500
501
() ->
501
- testStmt2 .executeUpdate ("INSERT INTO test3_2 VALUES (2, 'test field string 2')" ));
502
+ testStmt2 .executeUpdate ("INSERT INTO test3_3 VALUES (2, 'test field string 2')" ));
502
503
assertEquals (
503
504
SqlState .CONNECTION_FAILURE_DURING_TRANSACTION .getState (), exception .getSQLState ());
504
505
@@ -513,12 +514,13 @@ public void test_failFromWriterWhereKeepSessionStateOnFailoverIsTrue()
513
514
// testStmt2 can NOT be used anymore since it's invalid
514
515
515
516
final Statement testStmt3 = conn .createStatement ();
516
- final ResultSet rs = testStmt3 .executeQuery ("SELECT count(*) from test3_2 " );
517
+ final ResultSet rs = testStmt3 .executeQuery ("SELECT count(*) from test3_3 " );
517
518
rs .next ();
518
519
// Assert that NO row has been inserted to the table;
519
520
assertEquals (0 , rs .getInt (1 ));
520
521
521
- testStmt3 .executeUpdate ("DROP TABLE IF EXISTS test3_2" );
522
+ testStmt3 .executeUpdate ("DROP TABLE IF EXISTS test3_3" );
523
+ conn .commit ();
522
524
523
525
// Assert autocommit is still false after failover.
524
526
assertFalse (conn .getAutoCommit ());
0 commit comments