Hello, Team:
We will report the condition judgment that seems to be inappropriate in the test code of LogicalReplicationTest.
This issue does not affect the behavior of the JDBC Driver, but we would appreciate it if you could consider fixing
it.
[Overview]
The conditions for the replication slot status check are opposite.
The current code is to wait for 2 seconds if the value of pg_replication_slots.active is false.
Originally, if the value of pg_replication_slots.active is true, you need to wait for 2 seconds.
This can be worked around by modifying "!isActive" at line 367 in the source code below to "isActive".
Target source code:
/pgjdbc/src/test/java/org/postgresql/replication/LogicalReplicationTest.java
Line 367
------------------------------------------------
363 replConnection.close();
364
365 boolean isActive = isActiveOnView();
366 //we doesn't wait replay from server about stop connection that why some delay exists on update view and should
waitsome time before check view
367 if (!isActive) {
368 TimeUnit.SECONDS.sleep(2L);
369 isActive = isActiveOnView();
370 }
371
372 assertThat(
373 "Execute close method on Connection should lead to stop replication as fast as possible, "
374 + "as result we wait that
375 isActive, equalTo(false)
376 );
------------------------------------------------
In the original code, the following error could occur when tested on a slow machine.
(Failure did not occur on the high performance machines, probably because the replication slots would soon become
inactive.)
Test Error Messages:
----
> Task :postgresql:test
Gradle Test Executor 3 STANDARD_OUT
Configuration file /var/lib/pgsql/postgresql-jdbc-42.2-14.src/pgjdbc/../build.local.properties does not exist.
Consideradding it to specify test db host and login
Configuration file /var/lib/pgsql/postgresql-jdbc-42.2-14.src/pgjdbc/../ssltest.local.properties does not exist.
Consideradding it to specify test db host and login
enableSslTests is null, skipping SSL tests
LogicalReplicationTest > testReplicationRestartFromLastFeedbackPositionParallelTransaction STANDARD_OUT
Configuration file /var/lib/pgsql/postgresql-jdbc-42.2-14.src/pgjdbc/../build.local.properties does not exist.
Consideradding it to specify test db host and login
FAILURE 2.0sec, org.postgresql.replication.LogicalReplicationTest >
testDuringSendBigTransactionConnectionCloseSlotStatusNotActive
java.lang.AssertionError: Execute close method on Connection should lead to stop replication as fast as possible,
asresult we wait that on view pg_replication_slots status for slot will change to no active
Expected: <false>
but: was <true>
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.junit.Assert.assertThat(Assert.java:964)
at
org.postgresql.replication.LogicalReplicationTest.testDuringSendBigTransactionConnectionCloseSlotStatusNotActive(LogicalReplicationTest.java:372)
----
JDBC Driver 42.2.14
openjdk-1.8.0
PostgreSQL 12.3
CentOS 7.1
Best Regard.
Kenichi Nakamura