Skip to content

Add some performance-related environment variables #320

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

Closed
kocio-pl opened this issue Jul 28, 2017 · 4 comments
Closed

Add some performance-related environment variables #320

kocio-pl opened this issue Jul 28, 2017 · 4 comments

Comments

@kocio-pl
Copy link

I think it would be good to have some basic performance-related environment variables available out of the box to make it more suitable for real-life cases. I'm interested in something like POSTGRES_WORK_MEM and POSTGRES_MAINTENANCE_WORK_MEM, because that's what should be enough for OpenStreetMap data importing into Docker-enabled environment.

@tianon
Copy link
Member

tianon commented Jul 28, 2017

Any reason you can't just use -c work_mem=abc -c maintenance_work_mem=xyz ?

$ docker run -it --rm postgres -c work_mem=8MB
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

****************************************************
WARNING: No password has been set for the database.
         This will allow anyone with access to the
         Postgres port to access your database. In
         Docker's default configuration, this is
         effectively any other container on the same
         system.

         Use "-e POSTGRES_PASSWORD=password" to set
         it in "docker run".
****************************************************
waiting for server to start....LOG:  could not bind IPv6 socket: Cannot assign requested address
HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG:  database system was shut down at 2017-07-28 00:51:24 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
 done
server started
ALTER ROLE


/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

LOG:  received fast shutdown request
waiting for server to shut down....LOG:  aborting any active transactions
LOG:  autovacuum launcher shutting down
LOG:  shutting down
LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

LOG:  database system was shut down at 2017-07-28 00:51:26 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
$ docker ps -l
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
9c2a125537ef        postgres            "docker-entrypoint..."   8 seconds ago       Up 7 seconds        5432/tcp            frosty_ride
$ docker exec -it frosty_ride psql -U postgres
psql (9.6.2)
Type "help" for help.

postgres=# SHOW work_mem
postgres-# ;
 work_mem 
----------
 8MB
(1 row)

@kocio-pl
Copy link
Author

kocio-pl commented Jul 28, 2017

Yes, I want to make it user-friendly for people that are not familiar with database and Docker configuration (gravitystorm/openstreetmap-carto#2698).

The problem is that if I want to use such variables and they are not defined, Postgres fails (FATAL: invalid value for parameter "work_mem": ""). I think it should use standard values then.

@bjuergens
Copy link

I think tianon's solution is fine, as long as it's in the official documentation (which it isn't, as far as I know)

@yosifkit
Copy link
Member

Closed via docker-library/docs#1095

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

No branches or pull requests

4 participants