arkhipov / temporal_tables

Temporal Tables PostgreSQL Extension
BSD 2-Clause "Simplified" License
927 stars 46 forks source link

Trigger execution causes server to close the connection unexpectedly #77

Open peterthesaint opened 1 month ago

peterthesaint commented 1 month ago

I recently installed the extension _temporaltables on our PostgreSQL database (version 15.2, installed on Microsoft Windows Server 2022 Standard - x64).

As per the extension's installation instructions, I created a new "insert/update/delete" trigger on my existing, target table (myschema.mytable):

CREATE TRIGGER versioning_trigger BEFORE INSERT OR UPDATE OR DELETE ON myschema.mytable FOR EACH ROW EXECUTE PROCEDURE versioning('sys_period','myschema.mytablehistory',true);`

Now, however, whenever I execute any SQL command using pgAdmin 4 (Version 6.21) that inserts, updates or deletes a row in myschema.mytable, I receive the following message:

ERROR: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.

The PostgreSQL log file contains the following messages:

2024-08-15 07:06:58.500 EDT [12380] FATAL: the database system is in recovery mode 2024-08-15 07:06:58.611 EDT [18000] LOG: database system was interrupted; last known up at 2024-08-15 07:05:48 EDT 2024-08-15 07:07:01.261 EDT [18000] LOG: database system was not properly shut down; automatic recovery in progress 2024-08-15 07:07:01.278 EDT [18000] LOG: redo starts at F/69CBB4E8 2024-08-15 07:07:01.279 EDT [18000] LOG: invalid record length at F/69CBBC28: wanted 24, got 0 2024-08-15 07:07:01.279 EDT [18000] LOG: redo done at F/69CBBBF0 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s 2024-08-15 07:07:01.299 EDT [10208] LOG: checkpoint starting: end-of-recovery immediate wait 2024-08-15 07:07:01.333 EDT [10208] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.008 s, sync=0.006 s, total=0.037 s; sync files=4, longest=0.002 s, average=0.002 s; distance=1 kB, estimate=1 kB

I can't tell if the _temporaltables extension (or its trigger function) is failing or if there's a PostgreSQL setting I need to change in order to make this work.

Any and all advice much appreciated.