Created
July 10, 2019 23:31
-
-
Save tomaszalusky/9573c8130ebd0e413735ac46ee5aa1e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# docker build -t tomaszalusky/xmin-example . | |
# docker run -d --name xmin-example tomaszalusky/xmin-example | |
# docker exec -it xmin-example /bin/bash -c ./test.sh | |
FROM postgres:9.6.11 | |
WORKDIR /docker-entrypoint-initdb.d | |
RUN apt-get update && \ | |
apt-get install vim -y && \ | |
echo "sed -i 's/#track_commit_timestamp = off/track_commit_timestamp = on/g' /var/lib/postgresql/data/postgresql.conf" > updateconf.sh && \ | |
chmod a+r updateconf.sh && \ | |
echo "create table my_test (id bigserial primary key, text text, ins_time timestamp with time zone not null default now());" > createdb.sql | |
WORKDIR / | |
RUN echo "psql -U postgres -c \"begin; select pg_sleep(4); insert into my_test (text) values ('tx1 started first, committed second'); select pg_sleep(6); commit;\" &" > /test.sh && \ | |
echo "psql -U postgres -c \"select pg_sleep(2); begin; select pg_sleep(4); insert into my_test (text) values ('tx2 committed first'); select pg_sleep(2); commit;\" &" >> /test.sh && \ | |
echo "sleep 13" >> /test.sh && \ | |
echo "psql -U postgres -c \"select *,pg_xact_commit_timestamp(xmin) from my_test\"" >> /test.sh && \ | |
chmod +x /test.sh | |
ENTRYPOINT ["/docker-entrypoint.sh"] | |
CMD ["postgres"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment