spring-ai
spring-ai copied to clipboard
Spring AI PG Vector store does not find vector.control
Bug description Setup of Spring AI with PG Vector store fails. It cannot find the file vector.control even if it exists. The problem seems to be that it is looking for a Postgres 14 installation, although PG Vector store is for Postgres 15 or 16. The error message is:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vectorStore' defined in class path resource [org/springframework/ai/autoconfigure/vectorstore/pgvector/PgVectorStoreAutoConfiguration.class]: StatementCallback; SQL [CREATE EXTENSION IF NOT EXISTS vector]; ERROR: could not open extension control file "/usr/share/postgresql/14/extension/vector.control"
I linked from postgres/14 to postgres/16, so that the path exists. I ensured the file is read/writable. Yet, the error message remains.
Environment
- Spring AI version: 3.2.4
- Java version: 17 & 21
- Vector store: PG Vector on Postgres 16.
- OS: Ubuntu 22.04
- DB: Postgres 16
Steps to reproduce
- Install Postgres 16.
- Install PG Vector.
- Download the starter package: https://start.spring.io/starter.zip?type=maven-project&language=java&name=demoai&groupId=com.example&artifactId=demoai&packageName=com.example.demoai&javaVersion=17&packaging=jar&dependencies=spring-ai-ollama,web,spring-ai-vectordb-pgvector
- Fill out application.yml: spring: application: name: spring-demoai datasource: url: jdbc:postgresql://localhost:5432/demoai username: postgres password: postgres ai: vectorstore: pgvector: index-type: HNSW distance-type: COSINE_DISTANCE dimension: 1536
Expected behavior The application shall be able to find the correct vector.control file of the Posgres 15 or 16 version instead of looking for Postgres 14.
Minimal Complete Reproducible example The error occurs with the start.spring.io package setup, link with parameters is provided in the section "Steps to reproduce".
The error occurs only if Postgres was updated from 14 to 16. After removing Postgres and do a fresh installation from scratch it works fine.
I'm not sure what we can do to solve this. Seems that you found a (crude) workaround. Closing for now, open to suggestions for a fix.