1

I am not very confident if this issue is related to r2dbc-postgresql but now it only happens to us in R2DBC connection, not with Liquibase which uses JDBC...

We have 3 integration tests for our tiny project and they use Testcontainer to run a PostgreSQL to support the Repository. When building the project on our company cluster, we notice that occasionally some of the tests fail because R2DBC connection to localhost/0:0:0:0:0:0:0:1:<container_exposed_port> is refused. Note that all 3 tests depend on DB access and when we repeat the build, each of them has failed in some runs, i.e., in some builds, all 3 tests pass; in some builds, only test 1 fails but 2 and 3 pass; in some builds, only test 2 fails but 1 and 3 pass; in some builds, tests 1 and 2 fail but 3 passes, etc. When one test fails, other tests still run and may pass.

We've done some debugging and find in netstat -a -n --tcp is suggesting that only 0.0.0.0:<container_exposed_port> is being listened on, but not :::<container_exposed_port>.

After setting system properties for the integration tests to prefer IPv4 stack, the issue goes away, i.e.,

task integrationTest(type: Test) {
    // ...
    systemProperties = ['java.net.preferIPv4Stack': true] as Map<String, Object>
}

What I am confused about here is, why when the IPv4 preference is not set, only some of the tests fail. Also, why it does not happen to JDBC connections.

bfrguci
  • 137
  • 2
  • 8

0 Answers0