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

Events can't be added to invocation logs due to missing ID #4009

Closed
sf-vio opened this issue Mar 3, 2020 · 8 comments
Closed

Events can't be added to invocation logs due to missing ID #4009

sf-vio opened this issue Mar 3, 2020 · 8 comments
Assignees
Labels
c/server Related to server

Comments

@sf-vio
Copy link

sf-vio commented Mar 3, 2020

No events can added to the invocation logs. This means that all events are re-triggered every time the graphql engine is restarted. Error log shows that the events cannot be added to the invocation logs due to a null ID. Example log
{"type":"event-trigger","timestamp":"2020-02-25T09:10:25.557+0000","level":"error","detail":{"internal":{"statement":"\n INSERT INTO hdb_catalog.event_invocation_logs (event_id, status, request, response)\n VALUES ($1, $2, $3, $4)\n ","prepared":true,"error":{"exec_status":"FatalError","hint":null,"message":"null value in column "id" violates not-null constraint","status_code":"23502","description":"Failing row contains (null, c8fbcfca-e3a6-40d4-9d5b-524b1f642c8b, 200

@ecthiender ecthiender added the c/server Related to server label Mar 5, 2020
@marionschleifer marionschleifer added the support/needs-triage Needs to be triaged so that we have enough information to add this to our backlog label Mar 6, 2020
@tirumaraiselvan tirumaraiselvan added support/needs-action support ticket that requires action by team and removed support/needs-triage Needs to be triaged so that we have enough information to add this to our backlog labels Mar 11, 2020
@tirumaraiselvan
Copy link
Contributor

@sf-vio What version of Postgres are you on? Is it hosted on Heroku?

Can you run the result of the following SQL:

SELECT column_name, column_default
FROM information_schema.columns
WHERE (table_schema, table_name) = ('hdb_catalog', 'event_invocation_logs')
ORDER BY ordinal_position;

@tirumaraiselvan tirumaraiselvan removed the support/needs-action support ticket that requires action by team label Mar 18, 2020
@tiagob
Copy link

tiagob commented Mar 27, 2020

Same issue, this is what I see

postgres version

psql (12.2 (Debian 12.2-1.pgdg100+1))
column_name column_default
id NULL
event_id NULL
status NULL
request NULL
response NULL
created_at now()

@tirumaraiselvan
Copy link
Contributor

It appears that the column default is getting dropped. I am not sure how this happens.

The fix, till root cause is found, is to add the column default back:

ALTER TABLE hdb_catalog.event_invocation_logs ALTER COLUMN id SET DEFAULT gen_random_uuid()

@tiagob
Copy link

tiagob commented Mar 27, 2020

Thank you @tirumaraiselvan ! That fixes it.

I see what happened. I ran

DROP SCHEMA public CASCADE;
CREATE SCHEMA public;

Then brought the container back up and the DEFAULT was gone. Is there a better way to wipe all the data? Is there a way to bring back these defaults after I've wiped the data like this? I'm concerned I may have missed something else.

Tested this with the latest docker image https://github.com/hasura/graphql-engine/tree/stable/install-manifests/docker-compose

@tirumaraiselvan
Copy link
Contributor

@tiagob If you run DROP SCHEMA public , it will throw errors that gen_random_uuid() (a function that comes from pgcrypto extension) is being used in hdb_catalog tables. With cascade, the dependencies are dropped and the columns have no default.

Maybe instead of dropping schema, you can just drop all tables (function, views, etc) : https://stackoverflow.com/a/3327326/1911889

Also, created this issue to track a longer-term solution: #4217

@tiagob
Copy link

tiagob commented Mar 27, 2020

Very helpful. Thank you @tirumaraiselvan ! I love this product

@tirumaraiselvan
Copy link
Contributor

tirumaraiselvan commented Oct 24, 2020

A quick script to get the defaults back (on v1.3.2) :

BEGIN;
CREATE EXTENSION IF NOT EXISTS pgcrypto;
ALTER TABLE hdb_catalog.hdb_version
  ALTER COLUMN hasura_uuid
  SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.event_log
  ALTER COLUMN id
  SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.event_invocation_logs
  ALTER COLUMN id
  SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.hdb_action_log
  ALTER COLUMN id
  SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.hdb_cron_events
  ALTER COLUMN id
  SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.hdb_cron_event_invocation_logs
  ALTER COLUMN id
  SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.hdb_scheduled_events
  ALTER COLUMN id
  SET DEFAULT gen_random_uuid();
ALTER TABLE hdb_catalog.hdb_scheduled_event_invocation_logs
  ALTER COLUMN id
  SET DEFAULT gen_random_uuid();
COMMIT;

@tirumaraiselvan
Copy link
Contributor

Closed in #6085

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/server Related to server
Projects
None yet
Development

No branches or pull requests

5 participants