Docker Community Forums

Share and learn in the Docker community.

Beta 9: Postgres stat files corrupted when data stored on host mapped volume


(Mark Anders) #1

Expected behavior

Postgres should work properly when its data files reside in a host directory mapped as a data volume.

Actual behavior

I’m seeing repeatable warnings from postgres that various statistics files are corrupted like this:

postgres_1  | WARNING:  corrupted statistics file "pg_stat_tmp/global.stat"

I was seeing this in my app setup and was able to put together a reproducible example.

Information

OS X: version 10.11.5 (build: 15F28b)
Docker.app: version v1.11.0-beta9
Running diagnostic tests:
[OK] docker-cli
[OK] Moby booted
[OK] driver.amd64-linux
[OK] vmnetd
[OK] osxfs
[OK] db
[OK] slirp
[OK] menubar
[OK] environment
[OK] Docker
[OK] VT-x
Docker logs are being collected into /tmp/20160503-091155.tar.gz
Most specific failure is: No error was detected
Your unique id is: 86DF8E94-5D0E-4814-8A71-11F007590D3D
Please quote this in all correspondence.

Steps to reproduce the behavior

Docker file

FROM postgres:latest
ENV POSTGRES_USER=csroot
ENV POSTGRES_PASSWORD=password
ENV POSTGRES_DB=csdb
ENV PGDATA=/pgdata

docker-compose.yml

postgres:
restart: always
build: .
volumes:
- ./data/pgdata:/pgdata
ports:
- “5432:5432”

  1. Create a dir with the above Dockerfile and docker-compose.yml
  2. mkdir -p data/pgdata
  3. docker-compose build
  4. docker-compose up

Sorry about this next step. After doing this and running it, I was not seeing the errors. However, after I created a table in the database I created, I see them. I wasn’t able to figure out how to do this in the dockerfile so it needs to be done manually.

Since the docker containers are not run in the background, open up another terminal window:

  1. docker exec -it <name_of_the_postgres_container> bash
  2. psql --username=csroot --dbname=csdb
  3. Run the following command:

CREATE TABLE COMPANY(
ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL
);

  1. You can exit psql via \q

Now it may take a while but if you wait, you should see the corrupted message.


(Colton J. Provias) #2

This issue is still prevalent in the latest tag (9.5.3) and 9.6-beta1. I have run the containers in background mode and even tried without creating any data; the warning still appears.


(Mark Anders) #3

@coltonprovias - did you edit your post? I received an email where it read that it was NOT happening with 9.6 but it now says that does still occur. Correct to assume that it did begin happening?


(Colton J. Provias) #4

Yes, I did edit after I noticed it starting with 9.6 after approx 30 minutes.


(Mark Anders) #5

Thanks - that’s a great point. I had noted that “it may take a while”, but it can take around 30 minutes. I haven’t gotten any reply or acknowledgment that it’s a bug, so hopefully this will help in figuring out what’s wrong.


(Colton J. Provias) #6

So far it’s just a minor annoyance, but it would still be good to get fixed eventually. I should note that I’m on Docker 0.10.3 as 0.11 doesn’t play well with Rancher.


(Lessless) #7

In my case, it also randomly drops connection :frowning:

lient:
 Version:      1.12.0-rc2
 API version:  1.24
 Go version:   go1.6.2
 Git commit:   906eacd
 Built:        Fri Jun 17 20:35:33 2016
 OS/Arch:      darwin/amd64
 Experimental: true

Server:
 Version:      1.12.0-rc2
 API version:  1.24
 Go version:   go1.6.2
 Git commit:   a7119de
 Built:        Wed Jun 29 10:03:33 2016
 OS/Arch:      linux/amd64
 Experimental: true

(Highsierra7) #8

Hello All

I am getting the same error on my mac although postgres 9.6 seems to be operating normally.

Is anybody experiencing downstream problems related to this problem?

Thx


(Michael Kyed) #9

Hello,

I see it too, shortly after mapping the data volume to a mac folder.


(Mo0o) #10

This issue is still present on Version 1.12.0-rc3-beta18 (build: 9996) - ec40b14c72adc0bff3b01fa8886dae7f2eee1541

regarding docker’s logs this error is related to docker chmod capabilities, see lines after 2695 on the log file -starting from the end of this file will save you some scrolling time

here is one of those lines:

Jul 11 15:36:06 macbook-pro-de-me Docker[66787] <Error>: transfused: Event chmod /Users/scl/Project/them/foobar/db/pg_stat_tmp/global.stat error: I/O error