Open flixman opened 2 years ago
Found the issue. This docker file successfully builds the toolkit:
FROM timescale/timescaledb:latest-pg14 AS toolkit-tools
RUN apk add --no-cache clang pkgconfig openssl-dev gcc postgresql14-dev curl jq make musl-dev
RUN chown postgres /usr/local/share/postgresql/extension /usr/local/lib/postgresql
USER postgres
ENV PATH="/var/lib/postgresql/.cargo/bin:${PATH}" RUSTFLAGS='-C target-feature=-crt-static'
WORKDIR /var/lib/postgresql
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --profile=minimal -c rustfmt && \
cargo install --version 0.2.4 cargo-pgx && \
cargo pgx init --pg14 `which pg_config`
RUN mkdir timescaledb-toolkit && \
curl -s -L `curl -s https://api.github.com/repos/timescale/timescaledb-toolkit/releases/latest | jq -r ".tarball_url"` | tar -zx -C timescaledb-toolkit --strip-components 1
RUN cd timescaledb-toolkit/extension && \
cargo pgx install --release && \
cargo run --manifest-path ../tools/post-install/Cargo.toml -- pg_config
FROM timescale/timescaledb:latest-pg14 AS final
COPY --from=toolkit-tools /usr/local/share/postgresql/extension/timescaledb_toolkit* /usr/local/share/postgresql/extension/
COPY --from=toolkit-tools /usr/local/lib/postgresql/timescaledb_toolkit* /usr/local/lib/postgresql/
Now, the next problem: when timescaledb gets started I execute the following statement (which succeeds):
CREATE EXTENSION timescaledb_toolkit;
However, if I try to use any function from the library, I get back an error saying the function cannot be found:
db=# SELECT time_bucket('5m'::interval, time) AS five_min, delta(counter_agg(time, energy_t1_in)) AS net_in FROM electricity GROUP BY five_min;
ERROR: function counter_agg(timestamp without time zone, numeric) does not exist
LINE 1: ...e_bucket('5m'::interval, time) AS five_min, delta(counter_ag...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Thanks for figuring out the above! I got to the same point and then compared my docker image to the timescaledb-ha images that they have just started publishing, which include the extension.
It looks like the SQL files generated by pgx in /usr/local/share/postgresql/extension/timescaledb_toolkit*
are tiny compared to the ones in /usr/share/postgresql/13/extension
in the HA image.
As a temporary hack I overwrote these files with the ones from the HA image and the functions now seem to work.
Relevant system information:
SELECT version();
): 14\dx timescaledb_toolkit
inpsql
): current masterDescribe the bug Trying to build timescaledb-toolkit for docker image timescale/timescaledb:latest-pg14 is giving trouble. Using this dockerfile, generated from the CD pipeline of timescaledb-toolkit,
Results in the following error when compiling counter-agg:
I am not an expert on rust, so I do not know how to proceed to fix the issue. However, I have noted that there is a library /usr/lib/libclang.a, so... in case the dynamic library is not supported, shouldn't be the static?
To Reproduce Steps to reproduce the behavior: