testcontainers / testcontainers/testcontainers-java

Using a postgres image with mounted `/data` fails on LogWaitStrategy

Open
#3,372 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

modules/postgres resolution/acknowledged type/bug
Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

Testcontainer:
version: 1.14.3

Postgres:
version: 5.6-alpine
output:

PostgreSQL Database directory appears to contain a database; Skipping initialization

LOG:  database system was interrupted; last known up at 2020-10-13 08:45:54 UTC
LOG:  database system was not properly shut down; automatic recovery in progress
LOG:  redo starts at 0/14F0430
LOG:  invalid record length at 0/3356CD0: wanted 24, got 0
LOG:  redo done at 0/3356CA8
LOG:  last completed transaction was at log time 2020-10-13 08:46:42.609873+00
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

Expected behavior:

  • Container started successfully

Exception:

org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '.*database system is ready to accept connections.*\s'
	at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:31)

Issue:
Because the image skep the initialization and the code on PostgresSQLContainer:56 is registering the LogMessageWaitStrategy to match the line ".*database system is ready to accept connections.*\\s" twice withTimes(2), the container readiness check fails.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java at the referenced wait-strategy registration, then read LogMessageWaitStrategy.waitUntilReady. Reproduce the case with a PostgreSQL container using a mounted /data directory and verify that startup completes without the readiness timeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java, postgresql
Domain
databases, testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.