Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop of error log on ALTER TABLE migration serialization #909

Open
JosselinTILLAY opened this issue Feb 1, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@JosselinTILLAY
Copy link

JosselinTILLAY commented Feb 1, 2024

I have a POC project for testing electric SQL and I want to check the comportement of migrations.

Everything work as expected for new table creation and electrification.

But when I want to add a column to an existing table, it doesn't work. The migration on server seems to work as intendeed (I use django and the new column is accessible), but the device enter an infinite loop of errors.

The loop of logs is infinite, so I don't really know where to stop and where to begin to copy / paste it, so here is my try, I can generate more log if needed...

Service log :

poc-electricsql-electric-1  | 15:27:16.937 pid=<0.4294.0> client_id=4ba8fb8e-d89f-4198-9f0a-17875452d7d8 instance_id=4d03eed2-392d-4b7a-b603-17923b7575fe user_id=1234567890 [debug] msg from producer: [{%Electric.Replication.Changes.Transaction{xid: 797, changes: [], commit_timestamp: ~U[2024-02-01 15:09:37.989195Z], origin: "postgres_1", publication: "electric_publication", lsn: #Lsn<0/19D1B80>, ack_fn: nil, origin_type: :postgresql}, 27073408}, {%Electric.Replication.Changes.Transaction{xid: 798, changes: [%Electric.Replication.Changes.NewRecord{relation: {"electric", "ddl_commands"}, record: %{"id" => "5", "query" => "ALTER TABLE \"synchro_neighbour\" ADD COLUMN \"sublabel\" text NULL", "txid" => "798", "txts" => "1706801226376675"}, tags: []}], commit_timestamp: ~U[2024-02-01 15:27:06.458476Z], origin: "postgres_1", publication: "electric_publication", lsn: #Lsn<0/1A16138>, ack_fn: nil, origin_type: :postgresql}, 27353400}, {%Electric.Replication.Changes.Transaction{xid: 799, changes: [], commit_timestamp: ~U[2024-02-01 15:27:06.493983Z], origin: "postgres_1", publication: "electric_publication", lsn: #Lsn<0/1A18708>, ack_fn: nil, origin_type: :postgresql}, 27363080}]
poc-electricsql-electric-1  | 15:27:16.938 pid=<0.4294.0> client_id=4ba8fb8e-d89f-4198-9f0a-17875452d7d8 instance_id=4d03eed2-392d-4b7a-b603-17923b7575fe user_id=1234567890 [debug] Filtering transaction %Electric.Replication.Changes.Transaction{xid: 797, changes: [], commit_timestamp: ~U[2024-02-01 15:09:37.989195Z], origin: "postgres_1", publication: "electric_publication", lsn: #Lsn<0/19D1B80>, ack_fn: nil, origin_type: :postgresql} for user 1234567890
poc-electricsql-electric-1  | 15:27:16.938 pid=<0.4294.0> client_id=4ba8fb8e-d89f-4198-9f0a-17875452d7d8 instance_id=4d03eed2-392d-4b7a-b603-17923b7575fe user_id=1234567890 [debug] trans: %Electric.Replication.Changes.Transaction{xid: 798, changes: [%Electric.Replication.Changes.NewRecord{relation: {"electric", "ddl_commands"}, record: %{"id" => "5", "query" => "ALTER TABLE \"synchro_neighbour\" ADD COLUMN \"sublabel\" text NULL", "txid" => "798", "txts" => "1706801226376675"}, tags: []}], commit_timestamp: ~U[2024-02-01 15:27:06.458476Z], origin: "postgres_1", publication: "electric_publication", lsn: #Lsn<0/1A16138>, ack_fn: nil, origin_type: :postgresql} with offset 27353400
poc-electricsql-electric-1  | 15:27:16.938 pid=<0.4294.0> client_id=4ba8fb8e-d89f-4198-9f0a-17875452d7d8 instance_id=4d03eed2-392d-4b7a-b603-17923b7575fe user_id=1234567890 [info] Serializing migration "20240201152706_376": "ALTER TABLE \"synchro_neighbour\" ADD COLUMN \"sublabel\" text NULL"
poc-electricsql-electric-1  | 15:27:16.942 pid=<0.4294.0> client_id=4ba8fb8e-d89f-4198-9f0a-17875452d7d8 instance_id=4d03eed2-392d-4b7a-b603-17923b7575fe user_id=1234567890 [error] GenServer #PID<0.4294.0> terminating
poc-electricsql-electric-1  | ** (FunctionClauseError) no function clause matching in Electric.Postgres.Dialect.SQLite.map_constraint/2
poc-electricsql-electric-1  |     (electric 0.9.1) lib/electric/postgres/dialect/sqlite.ex:165: Electric.Postgres.Dialect.SQLite.map_constraint(nil, :add_column)
poc-electricsql-electric-1  |     (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
poc-electricsql-electric-1  |     (electric 0.9.1) lib/electric/postgres/dialect/sqlite.ex:137: Electric.Postgres.Dialect.SQLite.alter_table_cmd/3
poc-electricsql-electric-1  |     (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
poc-electricsql-electric-1  |     (electric 0.9.1) lib/electric/postgres/dialect/sqlite.ex:90: Electric.Postgres.Dialect.SQLite.to_sql/2
poc-electricsql-electric-1  |     (electric 0.9.1) lib/electric/postgres/replication.ex:136: anonymous fn/2 in Electric.Postgres.Replication.build_replication_msg/3
poc-electricsql-electric-1  |     (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
poc-electricsql-electric-1  |     (electric 0.9.1) lib/electric/postgres/replication.ex:132: Electric.Postgres.Replication.build_replication_msg/3

Client log :

 LOG  [rpc] send: #SatInStartReplicationReq{lsn: MjcwNTI3MzY=, subscriptions: [ddbee208-0d64-41f9-a814-4f8b11fed981]}
 LOG  [proto] send: #SatRpcRequest{method: startReplication, requestId: 173}
 LOG  [proto] recv: #SatRpcResponse{method: startReplication, requestId: 173}
 LOG  [rpc] recv: #SatInStartReplicationResp{}
 LOG  [proto] recv: #SatRpcRequest{method: startReplication, requestId: 0}
 INFO  Server sent a replication request to start from 0, and options []
 LOG  [proto] send: #SatRpcResponse{method: startReplication, requestId: 0}
 LOG  Connectivity state changed: connected
 WARN  an error occurred in satellite: socket closed
 LOG  Connectivity state changed: disconnected
 WARN  Client disconnected with a non fatal error, reconnecting

My migration is generated from Django, so I don't really know what the SQL is, but the logs seems to point the failure on

ALTER TABLE "synchro_neighbour" ADD COLUMN "sublabel" text NULL
Copy link

linear bot commented Feb 1, 2024

@JosselinTILLAY
Copy link
Author

JosselinTILLAY commented Feb 14, 2024

I have a investigated. The migration serialization work with :

ALTER TABLE "synchro_neighbour" ADD COLUMN "sublabel" text

but not with

ALTER TABLE "synchro_neighbour" ADD COLUMN "sublabel" text NULL

@alco alco added the bug Something isn't working label Feb 15, 2024 — with Linear
@alco alco assigned alco and unassigned alco Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants