LogicalReplicationTest pg_replication_slots status check

From: 中村憲一 <nakamura(dot)kenichi(at)ntt-tx(dot)co(dot)jp>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: LogicalReplicationTest pg_replication_slots status check
Date: 2020-06-19 06:32:20
Message-ID: e30229fd-fb02-5aa2-135d-b0e9822d5b32@ntt-tx.co.jp_1
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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 wait some 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. Consider adding 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. Consider adding 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. Consider adding 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, as result 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

Browse pgsql-jdbc by date

  From Date Subject
Next Message Vladimir Sitnikov 2020-06-19 15:07:10 [pgjdbc/pgjdbc] f0301e: chore: shade dependencies when building from the s...
Previous Message Vladimir Sitnikov 2020-06-11 09:13:53 [pgjdbc/pgjdbc] 075bd1: fix: use Assertions#assertThrows instead of Assert...