Closed aeturnum closed 3 years ago
I ran into this error when trying to test the base case of a fresh commanded setup. This is on postgres 10.15 on the official apline image.
I've created a small sample project that reproduces this error for me: https://github.com/aeturnum/eventstore_problem
I'm just not sure how to further diagnose this issue.
Here is the full error as reproduced by running the test in the above project:
Some other details that might be useful:
Thanks for the bug report @aeturnum. I believe this is related to the event_notification trigger. If you can upgrade to Postgres v12 or later you should not encounter the problem.
event_notification
I ran into this error when trying to test the base case of a fresh commanded setup. This is on postgres 10.15 on the official apline image.
I've created a small sample project that reproduces this error for me: https://github.com/aeturnum/eventstore_problem
I'm just not sure how to further diagnose this issue.
Here is the full error as reproduced by running the test in the above project:
`mix test` output
```elixir ddrexler@Drexbook-Pro:commanded_test| git:(upstream ⚡ master)$ mix test 09:52:43.781 [debug] Attempting to start Postgrex 09:52:43.821 [debug] Successfully started Postgrex (#PID<0.234.0>) 09:52:43.821 [debug] Attempting to start Postgrex 09:52:43.822 [debug] Successfully started Postgrex (#PID<0.247.0>) 09:52:43.828 [debug] Attempting to start Postgrex.Notifications 09:52:43.832 [debug] Successfully started Postgrex.Notifications (#PID<0.258.0>) 09:52:44.108 [debug] Locating aggregate process for `CommandedTest.Credits.AccountCredits` with UUID "test id" 09:52:44.131 [debug] CommandedTest.Credits.AccountCreditsSome other details that might be useful:
SQL statement generated from template
```sql WITH new_events_indexes (event_id, index, stream_version) AS ( VALUES ($3::uuid, $10::int, $11::bigint) ), events AS ( INSERT INTO public.events ( event_id, event_type, causation_id, correlation_id, data, metadata, created_at ) VALUES ($3, $4, $5, $6, $7, $8, $9) ), stream AS ( INSERT INTO public.streams (stream_uuid, stream_version) VALUES ($1, $2::bigint) returning stream_id ), source_stream_events AS ( INSERT INTO public.stream_events ( event_id, stream_id, stream_version, original_stream_id, original_stream_version ) SELECT new_events_indexes.event_id, stream.stream_id, new_events_indexes.stream_version, stream.stream_id, new_events_indexes.stream_version FROM new_events_indexes, stream ), linked_stream AS ( UPDATE public.streams SET stream_version = stream_version + $2::bigint WHERE stream_id = 0 RETURNING stream_version - $2::bigint as initial_stream_version ) INSERT INTO public.stream_events ( event_id, stream_id, stream_version, original_stream_id, original_stream_version ) SELECT new_events_indexes.event_id, 0, linked_stream.initial_stream_version + new_events_indexes.index, stream.stream_id, new_events_indexes.stream_version FROM new_events_indexes, linked_stream, stream; ```SQL parameters (with associated fields in the SQL statement)
```elixir [ "test id", // stream_uuid 1, // stream_version <<44, 220, 233, 219, 162, 170, 70, 136, 186, 60, 85, 7, 173, 168, 248, 152>>, // event_id "Elixir.CommandedTest.Credits.CreditsSetTo", // event_type <<21, 144, 181, 246, 217, 241, 67, 72, 189, 72, 171, 185, 97, 118, 199, 216>>, //causation_id <<200, 10, 143, 86, 22, 29, 73, 166, 155, 73, 201, 4, 92, 137, 146, 95>>, // correlation_id "{\"account_id\":\"test id\",\"new_balance\":0,\"prev_balance\":0,\"reason\":null,\"timestamp\":\"2021-06-07T22:32:46.944721Z\"}", // data "{}", // metadata ~U[2021-06-07 22:32:46.971443Z], // created_at 1, // index 1 // stream_version ] ```Postgrex Error
```elixir %Postgrex.Error{ connection_id: 1717, message: nil, postgres: %{ code: :object_not_in_prerequisite_state, detail: "The tuple structure of a not-yet-assigned record is indeterminate.", file: "pl_exec.c", line: "4905", message: "record \"old\" is not assigned yet", pg_code: "55000", routine: "exec_eval_datum", severity: "ERROR", unknown: "ERROR", where: "PL/pgSQL function notify_events() line 14 at assignment" }, query: nil } ```