Skip to content

chore(compose)!: share one pgvector PostgreSQL instance between OpenAEV and XTM One (#51) - #52

Merged
Samuel Hassine (SamuelHassine) merged 2 commits into
mainfrom
chore/shared-postgres-51
Oct 6, 2026
Merged

Samuel Hassine (SamuelHassine) merged 2 commits into
mainfrom
chore/shared-postgres-51

Conversation

@SamuelHassine

@SamuelHassine Samuel Hassine (SamuelHassine) commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Proposed changes

  • OpenAEV and XTM One share one pgsql service on pgvector/pgvector:pg17, with one database each (openaev, xtm_one). The pgsql-xtm-one service and its volume are gone.
  • New one-shot xtm-one-db-init service, same pattern as opencrq-db-init in feat(compose): add OpenCRQ to the XTM stack (#49) #50. On every start it:
    • refuses an XTM_ONE_POSTGRES_USER equal to POSTGRES_USER before psql runs: the init would otherwise reset the superuser's password, or leave XTM One running as a superuser;
    • creates the XTM_ONE_POSTGRES_USER role, which is no longer a superuser, and keeps its password in sync with .env;
    • creates the xtm_one database, owned by that role;
    • creates the vector extension in it. pgvector is not a trusted extension, so only a superuser can create it, and XTM One's own CREATE EXTENSION IF NOT EXISTS vector then finds it already there.
    • xtm-one waits for it (service_completed_successfully).
  • pgsql changes:
    • It runs with max_connections=200, the value XTM One's own compose file uses. OpenAEV (Hikari, 20) and XTM One (up to 35 per process with its tracing pool, over 2 web workers and the worker) go past the default of 100.
    • Its healthcheck goes over TCP (pg_isready -h localhost). On a new volume, the temporary server that initialises it listens on the Unix socket only, so the socket check could report healthy before any TCP client can connect.
  • The data lives on a new pgsqlshareddata volume (see Further comments).
  • README:
    • PostgreSQL + pgvector moves into "Shared Infrastructure" in the overview and the diagram, and the "Dedicated databases" group is removed.
    • A new "Upgrade from separate PostgreSQL instances" section gives the dump and restore procedure. It also covers a deployment that already started the new version: removing the new volume deletes what the platforms wrote since, so it says to dump it first.
  • .env.sample: comments for POSTGRES_USER and XTM_ONE_POSTGRES_USER. No variable is added, renamed or removed.

Related issues

How to test this PR

  1. docker compose -f docker-compose.yml --env-file .env.sample config -q passes, and config --services lists 29 services, as on main (one removed, one added).
  2. Fresh install: docker compose up -d. xtm-one-db-init exits 0, xtm-one turns healthy, and OpenAEV starts on the openaev database.
  3. Run docker compose up -d again: xtm-one-db-init replays without error.
  4. Upgrade: from a deployment on main, follow the README section, then check that OpenAEV and XTM One show their data.

Already checked locally (Docker 29.8.2, Compose 5.5.1), under throwaway project names, all removed afterwards:

  • Fresh volume:
    • xtm-one-db-init exits 0 on the first run and on a re-run.
    • xtmone can log in but is not a superuser, and owns xtm_one.
    • vector 0.8.6 exists in xtm_one only, and max_connections reads 200.
    • Over TCP, xtmone can create and query a vector(3) table, but gets permission denied for schema public in openaev.
    • With XTM_ONE_POSTGRES_USER equal to POSTGRES_USER, xtm-one-db-init exits 1 with its message, the superuser still logs in with its own password, and no xtm_one database is created.
  • xtmone/platform:latest on the shared instance, with Redis and Silo:
    • It turns healthy and logs "pgvector extension ensured", "Fresh database - stamped Alembic migration head" and "Database migrations applied".
    • Its pool check reads "75 estimated max connections (PostgreSQL max_connections=200, usable=197)".
    • 127 tables, all owned by xtmone. No error-level log line, and no permission error.
    • OpenAEV itself was not started, since its connection settings are unchanged.
  • Upgrade, with the README commands verbatim (Git Bash):
    • Started from main's pgsql and pgsql-xtm-one with sample data: 500 rows behind unique text indexes in openaev, 200 rows behind an HNSW index plus alembic_version in xtm_one.
    • Dumped, down, switched to this branch, ran xtm-one-db-init, then restored. Both pg_restore runs exit 0 with no errors.
    • Row counts and table owners (openaev, xtmone) are preserved, a nearest-neighbour query returns the expected row, and xtmone can insert.
    • The two old volumes are untouched, and the README's docker volume rm removes them.

Checklist

  • The PR title follows the Conventional Commits convention type(scope?): description (#issue)
  • I signed my commits
  • This PR is linked to an issue
  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I added/updated the relevant documentation
  • Where necessary, I refactored code to improve the overall quality

Further comments

…EV and XTM One (#51)

OpenAEV and XTM One now use a single pgsql service on
pgvector/pgvector:pg17, with one database each. The xtm-one-db-init
one-shot service creates the XTM One role (no longer a superuser), its
xtm_one database and the vector extension on every start. max_connections
is raised to 200 so both connection pools fit, and the healthcheck goes
over TCP so it no longer passes while a new volume is being initialised.

The README diagram shows PostgreSQL in the shared infrastructure, and a
new section explains how to upgrade an existing deployment.

BREAKING CHANGE: the shared instance starts on a new pgsqlshareddata
volume. Existing deployments dump the openaev and xtm_one databases
before upgrading and restore them afterwards (README, "Upgrade from
separate PostgreSQL instances").
Copilot AI balanced review requested due to automatic review settings October 6, 2026 20:22
@SamuelHassine Samuel Hassine (SamuelHassine) added filigran team vibe-coded PR: AI-assisted change — the author reviews it before requesting others' review. labels Oct 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Matching database usernames can overwrite shared administrator credentials and leave XTM One running as a superuser.

Review effort: Balanced
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Consolidates OpenAEV and XTM One onto one PostgreSQL + pgvector instance with separate databases.

Changes:

  • Adds XTM One database initialization and shared connection settings.
  • Uses a new shared volume and documents migration.
  • Clarifies PostgreSQL role credentials.
File Description
README.md Updates architecture and adds upgrade instructions.
docker-compose.yml Shares PostgreSQL and adds database initialization.
.env.sample Clarifies role credentials in comments.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docker-compose.yml
Comment thread README.md Outdated
#51)

xtm-one-db-init now exits before psql when XTM_ONE_POSTGRES_USER equals
POSTGRES_USER. With separate instances the two names could match; on the
shared instance the init would have reset the superuser's password,
breaking OpenAEV and the next init, or left XTM One running as a
superuser.

The README recovery note now warns that the shared volume holds what the
platforms wrote since they started, and says to dump it before removing
it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The breaking database migration needs human validation with a live OpenAEV deployment, which the reported testing did not cover.

Review effort: Balanced
Findings: None

Resolved since last review (2)

Samuel Hassine (SamuelHassine) added a commit that referenced this pull request Oct 6, 2026
…CRQ (#49)

Brings chore/shared-postgres-51 (#52) in, so OpenCRQ is built on the
single pgvector pgsql instance OpenAEV and XTM One share. Conflicts
resolved by keeping both sides: the pgsql block keeps the pgvector image,
max_connections and TCP healthcheck of #52 and the shm_size of #49, and
the README keeps PostgreSQL in the shared infrastructure with OpenCRQ
pointing at it.
Samuel Hassine (SamuelHassine) added a commit that referenced this pull request Oct 6, 2026
…#49)

opencrq-db-init now uses pgvector/pgvector:pg17, the image pgsql runs, so
the stack pulls one PostgreSQL image instead of two. Like xtm-one-db-init
in #52, it refuses a role name equal to POSTGRES_USER, and also to
XTM_ONE_POSTGRES_USER: the shared instance holds both roles, and the init
would otherwise reset the superuser's or XTM One's password. The pgsql
comments and the README count OpenCRQ among the platforms sharing the
instance.
@SamuelHassine
Samuel Hassine (SamuelHassine) merged commit f008ee8 into main Oct 6, 2026
3 checks passed
@SamuelHassine

Copy link
Copy Markdown
Member Author

Live validation of the upgrade with the real openaev/platform:latest image (version 3.261005.0), done after the merge, under a throwaway project:

  • Started on main before this PR, with OpenAEV on postgres:17-alpine: it applied 453 migrations (176 tables), and a tag was created through its API.
  • Followed the README section verbatim: dump, down, switch to this version, docker compose run --rm xtm-one-db-init, restore, up -d. Both pg_restore runs exit 0.
  • On the shared pgvector/pgvector:pg17 instance, OpenAEV turned healthy in 40 s:
    • same migration history (453, none failed), tables (176), users and tags as before;
    • the tag read back through the API;
    • no error line in its log.

Not from this PR, but found on the way: with the current OpenAEV image, /actuator/health/ping answers 401. So on main, openaev stays unhealthy and the collectors and injectors that wait for it never start. #40 fixes it with /api/health?health_access_key=..., which the test above used in an override.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team vibe-coded PR: AI-assisted change — the author reviews it before requesting others' review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(compose): share one pgvector PostgreSQL instance between OpenAEV and XTM One

2 participants