pg_partman icon indicating copy to clipboard operation
pg_partman copied to clipboard

Missing pgxs.mk in Docker installation

Open jdcarey128 opened this issue 3 years ago • 6 comments

I am trying to install the pg_partman v4.0.0 extension in a Docker container with a redhat ubi8 base image and postgresql version 12.6.

Here is the portion of my Dockerfile that attempts the pg_partman installation:

RUN wget -O pg_partman.tar.gz "https://github.com/pgpartman/pg_partman/archive/v4.0.0.tar.gz" \
    && mkdir -p /usr/src/pg_partman \
    && tar \
        --extract \
        --file pg_partman.tar.gz \
        --directory /usr/src/pg_partman \
        --strip-components 1 \
    && rm pg_partman.tar.gz \
    && cd /usr/src/pg_partman \
    && make install 

I receive the following error when I try to build the image:

#7 1.195 Makefile:48: /usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk: No such file or directory
#7 1.195 make: *** No rule to make target '/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk'.  Stop.

Clearly /usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk does not exist, though pg_config --pgxs in the Makefile points to it.

I'm not super familiar with make or why it's necessary to include these pgxs.mk files with the Makefile. Is there a workaround to this problem? Am I missing other dependencies or have version incompatibilities?

Any ideas for a solution?

jdcarey128 avatar Jun 08 '22 20:06 jdcarey128

Typically this sort of error is seen because, in order to build pg_partman, or any pg extension, the development package has to be installed or the source libraries have to be available somehow. That's what provides the pgxs system to allow easier building of extensions.

Can you see if the postgreql development package is available inside your container?

Also, I would highly recommend getting a more recent version of pg_partman. 4.0.0 is quite old and there have been many bug fixes.

keithf4 avatar Jun 09 '22 01:06 keithf4

Thank you @keithf4 for your quick response!

What I'm seeing in the container:

Installed packages

# yum list installed | grep postgresql

postgresql12.x86_64                               12.6-1PGDG.rhel8                @@commandline
postgresql12-libs.x86_64                        12.6-1PGDG.rhel8                @@commandline
postgresql12-server.x86_64                    12.6-1PGDG.rhel8                @@commandline

Available packages

# yum list --available | grep postgres
#

Attempt to install devel package

# yum install postgresql12-devel

Last metadata expiration check: 0:54:36 ago on Thu 09 Jun 2022 03:11:58 PM UTC.
No match for argument: postgresql12-devel
Error: Unable to find a match: postgresql12-devel

jdcarey128 avatar Jun 09 '22 16:06 jdcarey128

That should be the correct package and, if you don't have the source available via some other method, is required in order to build pg_partman and most other PostgreSQL extensions.

keithf4 avatar Jun 09 '22 22:06 keithf4

Were you able to find a solution to this issue?

@jcoleman I know you did some work with pg_partman and Docker based on your PR. Any insight here?

keithf4 avatar Jun 25 '22 21:06 keithf4

I added the following to my Dockerfile before the pg_partman installation to install the postgresql12-devel dependency:

RUN wget -O postgresql12-devel.rpm "https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-8-x86_64/postgresql12-devel-12.6-1PGDG.rhel8.x86_64.rpm"\
    && yum localinstall -y postgresql12-devel.rpm

When running the build, I am now seeing this error:

#9 15.85 cat sql/types/types.sql sql/tables/tables.sql sql/functions/apply_cluster.sql sql/functions/apply_constraints.sql sql/functions/apply_foreign_keys.sql sql/functions/apply_privileges.sql sql/functions/apply_publications.sql sql/functions/autovacuum_off.sql sql/functions/autovacuum_reset.sql sql/functions/check_control_type.sql sql/functions/check_default.sql sql/functions/check_name_length.sql sql/functions/check_subpart_sameconfig.sql sql/functions/check_subpartition_limits.sql sql/functions/create_function_id.sql sql/functions/create_function_time.sql sql/functions/create_parent.sql sql/functions/create_partition_id.sql sql/functions/create_partition_time.sql sql/functions/create_sub_parent.sql sql/functions/create_trigger.sql sql/functions/drop_constraints.sql sql/functions/drop_partition_column.sql sql/functions/drop_partition_id.sql sql/functions/drop_partition_time.sql sql/functions/dump_partition_table_definition.sql sql/functions/inherit_template_properties.sql sql/functions/partition_data_id.sql sql/functions/partition_data_time.sql sql/functions/partition_gap_fill.sql sql/functions/reapply_privileges.sql sql/functions/run_maintenance.sql sql/functions/show_partition_info.sql sql/functions/show_partition_name.sql sql/functions/show_partitions.sql sql/functions/stop_sub_partition.sql sql/functions/undo_partition.sql sql/procedures/partition_data_proc.sql sql/procedures/reapply_constraints_proc.sql sql/procedures/run_maintenance_proc.sql sql/procedures/undo_partition_proc.sql > sql/pg_partman--4.6.0.sql
#9 15.86 gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -I. -I./ -I/usr/pgsql-12/include/server -I/usr/pgsql-12/include/internal  -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include  -c -o src/pg_partman_bgw.o src/pg_partman_bgw.c
#9 15.86 gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory
#9 15.86 make: *** [<builtin>: src/pg_partman_bgw.o] Error 1
------
executor failed running [/bin/sh -c wget -O pg_partman.tar.gz "https://github.com/pgpartman/pg_partman/archive/$PG_PARTMAN_VERSION.tar.gz"     && mkdir -p /usr/src/pg_partman     && tar         --extract         --file pg_partman.tar.gz         --directory /usr/src/pg_partman         --strip-components 1     && rm pg_partman.tar.gz     && cd /usr/src/pg_partman     && make install]: exit code: 2

When manually stepping through the pg_partman install command in the container, I see this permission error with make install:

bash-4.4$ make install
cat sql/types/types.sql sql/tables/tables.sql sql/functions/apply_cluster.sql sql/functions/apply_constraints.sql sql/functions/apply_foreign_keys.sql sql/functions/apply_privileges.sql sql/functions/apply_publications.sql sql/functions/autovacuum_off.sql sql/functions/autovacuum_reset.sql sql/functions/check_control_type.sql sql/functions/check_default.sql sql/functions/check_name_length.sql sql/functions/check_subpart_sameconfig.sql sql/functions/check_subpartition_limits.sql sql/functions/create_function_id.sql sql/functions/create_function_time.sql sql/functions/create_parent.sql sql/functions/create_partition_id.sql sql/functions/create_partition_time.sql sql/functions/create_sub_parent.sql sql/functions/create_trigger.sql sql/functions/drop_constraints.sql sql/functions/drop_partition_column.sql sql/functions/drop_partition_id.sql sql/functions/drop_partition_time.sql sql/functions/dump_partition_table_definition.sql sql/functions/inherit_template_properties.sql sql/functions/partition_data_id.sql sql/functions/partition_data_time.sql sql/functions/partition_gap_fill.sql sql/functions/reapply_privileges.sql sql/functions/run_maintenance.sql sql/functions/show_partition_info.sql sql/functions/show_partition_name.sql sql/functions/show_partitions.sql sql/functions/stop_sub_partition.sql sql/functions/undo_partition.sql sql/procedures/partition_data_proc.sql sql/procedures/reapply_constraints_proc.sql sql/procedures/run_maintenance_proc.sql sql/procedures/undo_partition_proc.sql > sql/pg_partman--4.6.0.sql
/bin/sh: sql/pg_partman--4.6.0.sql: Permission denied
make: *** [Makefile:28: sql/pg_partman--4.6.0.sql] Error 1
bash-4.4$

Here are the permissions for the sql/ directory: drwxrwxr-x 6 root root 4096 Oct 7 2021 sql

I'm assuming the permission error is causing the downstream gcc error that I'm seeing with the failed build, but I'm not sure. I'm also not sure why there would be a permission denied error.

jdcarey128 avatar Jun 27 '22 22:06 jdcarey128

Just checking to see if you were able to find any solutions to this.

keithf4 avatar Aug 12 '22 15:08 keithf4

Closing this issue for now. Please feel free to re-open if you still need assistance.

keithf4 avatar Mar 22 '23 19:03 keithf4