pgvecto.rs icon indicating copy to clipboard operation
pgvecto.rs copied to clipboard

Container image ignores additional shared_preload_libraries added via postgresql.conf

Open kiguigui opened this issue 1 year ago • 7 comments
trafficstars

In the dockerfile, psql is started with CMD ["postgres" "-c" "shared_preload_libraries=vectors.so" "-c" "search_path=\"$user\", public, vectors"].

When adding shared_preload_libraries like pg_stat_statements to postgresql.conf, these settings are ignored.

postgresql.conf:

#local_preload_libraries = ''
#session_preload_libraries = ''
shared_preload_libraries = 'vectors.so,pg_stat_statements'
#jit_provider = 'llvmjit'               # JIT library to use

output of pg_settings:

grafik

However it is possible to overwrite this in Kubernetes by specifying:

          args:
          - "postgres"
          - "-c" 
          - "shared_preload_libraries=vectors.so,pg_stat_statements"
          - "-c" 
          - "search_path=\"$user\", public, vectors"

in your stateful set or deployment.

After that, all libraries are loaded:

grafik

EDIT: args were not complete

kiguigui avatar Mar 03 '24 11:03 kiguigui

@VoVAllen Should it be expected?

usamoi avatar Mar 04 '24 07:03 usamoi

I didn't see what we can fix here. Probably mention it in the documentations should be enough? If we put it in the postgresql.conf, then use -c vectors.so will overrider that. Only one will work.

VoVAllen avatar Mar 04 '24 07:03 VoVAllen

We could just remove -c ... -c ... in dockerfile. But users have to read documentation before using the image (it sounds weird that users could use it without reading documentation).

usamoi avatar Mar 04 '24 07:03 usamoi

How about using entrypoint and cmd in dockerfile: https://spacelift.io/blog/docker-entrypoint-vs-cmd

gaocegege avatar Mar 04 '24 08:03 gaocegege

ENTRYPOINT ['postgres']
CMD ["-c" "shared_preload_libraries=vectors.so" "-c" "search_path=\"$user\", public, vectors"]

gaocegege avatar Mar 04 '24 08:03 gaocegege

I have encountered this problem when I was configuring the container on my NAS:

image

The solution is simple, just execute psql -U postgres -c 'ALTER SYSTEM SET shared_preload_libraries = "vectors.so"' and restart the container, but I remember this wasn't happened in 0.1.x.

LancerComet avatar Mar 06 '24 15:03 LancerComet