Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared Memory settings is not picked up #654

Closed
TieyanFu opened this issue Sep 21, 2023 · 1 comment
Closed

Shared Memory settings is not picked up #654

TieyanFu opened this issue Sep 21, 2023 · 1 comment
Labels
triage Investigation required

Comments

@TieyanFu
Copy link

TieyanFu commented Sep 21, 2023

Expected Behaviour
We are trying to set shared_buffers parameter with following codes

const postgresContainer = new GenericContainer('postgres:14.3-bullseye')
  .withSharedMemorySize(256 * 1024 * 1024)
  .withUser('postgres')
  .withEnvironment({
    POSTGRES_PASSWORD: 'xxxx',
    POSTGRES_DB: 'idmp',
  })
  .withExposedPorts(5432)
  .withHealthCheck({
    test: ['CMD-SHELL', 'pg_isready'],
    interval: 5000,
    timeout: 1000,
    retries: 5,
  })
  .withWaitStrategy(Wait.forHealthCheck());
console.debug(postgresContainer);
const startedTestContainer = await postgresContainer.start();

Actual Behaviour
Below logs show that ShmSize picks up the value 268435456 (256MB), however, further down the logs testcontainers select default value of 128MB.

Testcontainer Logs

GenericContainer {
  createOpts: {
    Image: 'postgres:14.3-bullseye',
    User: 'postgres',
    Env: [ 'POSTGRES_PASSWORD=example', 'POSTGRES_DB=idmp' ],
    ExposedPorts: { '5432': {} },
    Healthcheck: {
      Test: [Array],
      Interval: 5000000000,
      Timeout: 1000000000,
      Retries: 5,
      StartPeriod: 0
    }
  },
  hostConfig: {
    AutoRemove: false,
    **ShmSize: 268435456,**
    PortBindings: { '5432': [Array] }
  },
  imageName: ImageName {
    registry: undefined,
    image: 'postgres',
    tag: '14.3-bullseye',
    string: 'postgres:14.3-bullseye'
  },

testcontainers:containers [9ebe0f3e24e2] fixing permissions on existing directory /var/lib/postgresql/data ... ok +0ms
testcontainers:containers [9ebe0f3e24e2] creating subdirectories ... ok +1ms
testcontainers:containers [9ebe0f3e24e2] selecting dynamic shared memory implementation ... posix +0ms
testcontainers:containers [9ebe0f3e24e2] selecting default max_connections ... 100 +17ms
testcontainers:containers [9ebe0f3e24e2] selecting default shared_buffers ... 128MB +22ms
testcontainers:containers [9ebe0f3e24e2] selecting default time zone ... Etc/UTC +17ms
testcontainers:containers [9ebe0f3e24e2] creating configuration files ... ok +1ms
testcontainers [DEBUG] [9ebe0f3e24e2] Inspecting container... +102ms
testcontainers [DEBUG] [9ebe0f3e24e2] Inspected container +4ms

Steps to Reproduce

  1. In this environment...
  2. With this config...
  3. Run '...'
  4. See error...

Environment Information

  • Operating System: MacOS 13.5.2 (22G91)
  • Docker Version: 20.10.8
  • Node version: v18.17.1
  • Testcontainers version: 10.2.1
@cristianrgreco cristianrgreco added the triage Investigation required label Oct 4, 2023
@cristianrgreco
Copy link
Collaborator

Hi @TieyanFu, the shared memory size is correctly being set by Docker, however I believe that Postgres also needs to be configured to use shared buffers which is currently outside the scope of Testcontainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Investigation required
Projects
None yet
Development

No branches or pull requests

2 participants