electric-sql / electric-sql/electric-telemetry
Allow configuring PostgreSQL lc_messages locale for Electric's replication connection
- Dominant language
- Elixir
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
### Problem
Electric matches PostgreSQL error messages by their text content using pattern matching. However, replication connections in PostgreSQL ignore session-level locale settings (ALTER ROLE SET lc_messages and ALTER DATABASE SET lc_messages) and use only the server-level lc_messages from postgresql.conf.
This means that if a PostgreSQL server is configured with a non-English locale, Electric will receive error messages in that language, the pattern match will fail, and Electric will enter an infinite crash loop.
### Example
On a PostgreSQL server with Russian locale, the duplicate publication error comes as "публикация "electric_publication_default" уже существует" instead of the expected "publication "electric_publication_default" already exists". The pin operator match fails and Electric raises the error instead of handling it gracefully.
### Possible solutions
1. Match only by error code, not message text — simplest fix, already proposed in PR #XXXX. Change the pattern from matching on message text to just code and pg_code: duplicate_object / 42710.
2. Use CREATE PUBLICATION IF NOT EXISTS — avoids the duplicate error entirely.
3. Allow configuring lc_messages via an Electric environment variable (e.g. ELECTRIC_PG_LC_MESSAGES) passed as a connection parameter, so Electric can force English error messages without requiring changes to the PostgreSQL server configuration.
### Workaround
Drop the publication before each Electric restart (e.g. via a Kubernetes init container), so Electric always creates it fresh and never encounters the duplicate error.
### Environment
Electric version: 1.7.4 / 1.7.5
PostgreSQL version: 18
PostgreSQL locale: Russian (ru_RU.UTF-8)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating Electric's replication connection setup and the publication-creation error handling. Compare the connection parameters and duplicate-publication matching described in the issue, then determine which proposed approach fits the project. Done means PostgreSQL servers with non-English lc_messages no longer cause the replication connection to enter a crash loop, with coverage for the affected case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir, postgresql
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100