Skip to content

Commit cee85b6

Browse files
authored
Merge pull request #33100 from def-/pr-speedup-materialized-container
docker: Speed up startup of the materialized container
2 parents b7c6a3e + 29b5e7a commit cee85b6

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

misc/images/materialized-base/Dockerfile

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,18 @@ FROM materialize/console:25.2.3 AS console
1919

2020
MZFROM ubuntu-base
2121

22-
RUN groupadd --system --gid=999 materialize \
23-
&& useradd --system --gid=999 --uid=999 --create-home materialize
24-
2522
ARG CI_SANITIZER=none
2623

27-
RUN apt-get update \
24+
RUN groupadd --system --gid=999 materialize \
25+
&& useradd --system --gid=999 --uid=999 --create-home materialize \
26+
&& apt-get update \
2827
&& TZ=UTC DEBIAN_FRONTEND=noninteractive apt-get -qy install --no-install-recommends \
29-
ca-certificates \
3028
curl \
3129
gettext-base \
3230
nginx \
3331
postgresql \
34-
postgresql-contrib \
35-
tini \
3632
ssh \
33+
tini \
3734
&& if [ "$CI_SANITIZER" != "none" ]; then \
3835
TZ=UTC DEBIAN_FRONTEND=noninteractive apt-get -qy install --no-install-recommends llvm; \
3936
fi \
@@ -57,7 +54,3 @@ RUN MZ_ENDPOINT=http://localhost:6876 \
5754
&& rm /etc/nginx/templates/default.conf.template
5855

5956
USER materialize
60-
61-
RUN pg_ctlcluster 16 main start \
62-
&& psql -U postgres -c "CREATE ROLE root WITH LOGIN PASSWORD 'root'" \
63-
&& psql -U postgres -c "CREATE DATABASE root OWNER root"

misc/python/materialize/mzcompose/services/materialized.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def __init__(
114114

115115
environment = [
116116
"MZ_NO_TELEMETRY=1",
117+
"MZ_NO_BUILTIN_CONSOLE=1",
117118
"MZ_TEST_ONLY_DUMMY_SEGMENT_CLIENT=true",
118119
f"MZ_SOFT_ASSERTIONS={int(soft_assertions)}",
119120
# The following settings can not be baked in the default image, as they

src/materialized/ci/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ COPY materialized entrypoint.sh /usr/local/bin/
1515
USER root
1616
RUN ln -s /usr/local/bin/materialized /usr/local/bin/environmentd \
1717
&& ln -s /usr/local/bin/materialized /usr/local/bin/clusterd
18+
1819
USER materialize
1920

21+
RUN bash -c '\
22+
set -euo pipefail; \
23+
tini -- entrypoint.sh & \
24+
tini_pid=$!; \
25+
until curl -sf localhost:6878/api/readyz; do sleep 0.1; done; \
26+
kill -TERM "$tini_pid"; \
27+
wait "$tini_pid" || true; \
28+
pg_ctlcluster 16 main stop --mode=fast --force'
29+
2030
ENTRYPOINT ["tini", "--", "entrypoint.sh"]

src/materialized/ci/entrypoint.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,18 @@ EOF
4141

4242
# Start PostgreSQL, unless suppressed.
4343
if [ -z "${MZ_NO_BUILTIN_POSTGRES:-}" ]; then
44+
(trap 'pg_ctlcluster 16 main stop --mode=fast --force' SIGTERM SIGINT
45+
rm -f /var/run/postgresql/.s.PGSQL.26257.lock
4446
pg_ctlcluster 16 main start
45-
psql -U root -c "CREATE SCHEMA IF NOT EXISTS consensus"
46-
psql -U root -c "CREATE SCHEMA IF NOT EXISTS storage"
47-
psql -U root -c "CREATE SCHEMA IF NOT EXISTS adapter"
48-
psql -U root -c "CREATE SCHEMA IF NOT EXISTS tsoracle"
47+
psql -U postgres -c "CREATE ROLE root WITH LOGIN PASSWORD 'root'" || true
48+
psql -U postgres -c "CREATE DATABASE root OWNER root" || true
49+
psql -U root -c "CREATE SCHEMA IF NOT EXISTS consensus; CREATE SCHEMA IF NOT EXISTS storage; CREATE SCHEMA IF NOT EXISTS adapter; CREATE SCHEMA IF NOT EXISTS tsoracle") &
4950
fi
5051

5152
# Start nginx to serve the console.
52-
nginx
53+
if [ -z "${MZ_NO_BUILTIN_CONSOLE:-}" ]; then
54+
nginx &
55+
fi
5356

5457
if [[ ! -f /mzdata/environment-id ]]; then
5558
echo "docker-container-$(cat /proc/sys/kernel/random/uuid)-0" > /mzdata/environment-id

test/sqllogictest/cardinality.slt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ SHOW optimizer_oneshot_stats_timeout;
430430
COMPLETE 1
431431

432432
statement ok
433-
SELECT mz_unsafe.mz_sleep(2)
433+
SELECT mz_unsafe.mz_sleep(3)
434434

435435
query T multiline
436436
EXPLAIN OPTIMIZED PLAN WITH(join implementations, humanized expressions) AS VERBOSE TEXT FOR SELECT * FROM t JOIN t2 ON t.x = t2.x JOIN t3 ON t.x = t3.x JOIN t4 ON t.x = t4.x JOIN t5 ON t.x = t5.x JOIN t6 ON t.x = t6.x JOIN t7 ON t.x = t7.x JOIN t8 ON t.x = t8.x JOIN t9 ON t.x = t9.x JOIN t10 ON t.x = t10.x;

0 commit comments

Comments
 (0)