Allow configuring PostgreSQL lc_messages locale for Electric's replication connection

オープン
#3 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
elixir, postgresql
領域
backend, databases

調査の方向性

まず、Electric のレプリケーション接続のセットアップと、publication 作成時のエラー処理を特定します。Issue に記載された接続パラメータと重複する publication の照合方法を比較し、そのうえで、提案されたアプローチのどれがプロジェクトに適しているかを判断します。PostgreSQL サーバーの lc_messages が英語以外の場合でも、レプリケーション接続がクラッシュループに入らなくなり、影響を受けるケースがカバレッジされていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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)

主要言語
Elixir
スター
1
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

似ている issue

Elixir の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。