reorg / pg_repack

Reorganize tables in PostgreSQL databases with minimal locks
BSD 3-Clause "New" or "Revised" License
1.89k stars 176 forks source link

Parallel processing fails for indexes with operators/functions from `public` schema #185

Open vyegorov opened 6 years ago

vyegorov commented 6 years ago

If one has indexes with operators/functions delivered by extensions, that typically land into public schema, such indexes will cause pg_repack to fail when parallel processing is used (-j switch).

The reason is — initially, all processes do SET search_path TO pg_catalog, pg_temp. Later, main process will adjust it's config SET search_path = pg_catalog, pg_temp, public, but parallel workers will not do so. Obviously, this causes errors, like this:

LINE 1: ...870943 ON repack.table_870934 USING btree (((data -> 'val'::...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

Reproducer:

CREATE DATABASE repack;
\c repack
CREATE EXTENSION hstore;
CREATE EXTENSION pg_repack;
CREATE TABLE repack (id serial PRIMARY KEY, data hstore);
CREATE INDEX i_repack_data_val ON repack ((data -> 'val'::text));
\q

pg_repack -t repack -j 2 repack
MasahikoSawada commented 6 years ago

Thank you for the report! PR #192 will solve it.