electric icon indicating copy to clipboard operation
electric copied to clipboard

Insertion into tables with generated columns causes shape termination

Open AntonOfTheWoods opened this issue 11 months ago • 1 comments

To reproduce, add the following https://github.com/electric-sql/electric/compare/main...AntonOfTheWoods:electric:generated_bug and do a normal run of the todo-app example. Any insertion (e.g, via the demo web interface) causes the following message in the log:

01:12:57.837 pid=<0.3097.0> shape_handle=91872063-1737681148357 [info] Schema for the table "public"."todos" changed - terminating shape 91872063-1737681148357

This, in turn, causes a must-revalidate on all clients and the obligatory re-syncing of the entire shape

AntonOfTheWoods avatar Jan 24 '25 01:01 AntonOfTheWoods

Electric does not handle generated columns and seems unlikely that it will since they are skipped in logical replication https://www.postgresql.org/docs/current/ddl-generated-columns.html. We need to look into the messages in the replication stream to see if we can handle the special case.

balegas avatar Jan 24 '25 23:01 balegas

Seems to be coming in Postgres 18! https://www.postgresql.fastware.com/pzone/2025-04-logical-replication-of-generated-columns https://www.postgresql.org/docs/18/logical-replication-gencols.html

KazimirPodolski avatar Jun 10 '25 22:06 KazimirPodolski

Oooh, that’s great!

thruflo avatar Jun 11 '25 07:06 thruflo