hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
30.94k stars 2.74k forks source link

Startup error when attempting to start a new Hasura instance in a db that was using Hasura previously #7451

Open dougg0k opened 2 years ago

dougg0k commented 2 years ago

Docker container keeps restarting after timeout is reached. Scripts v3 and Hasura v2.0.4

{
  "type": "startup",
  "timestamp": "2021-08-23T22:16:21.923+0000",
  "level": "error",
  "detail": {
    "kind": "catalog_migrate",
    "info": {
      "internal": {
        "statement": "/* We define our own uuid generator function that uses gen_random_uuid() underneath.\nSince the column default is not directly referencing gen_random_uuid(),\nit prevents the column default to be dropped when pgcrypto or public schema is dropped unwittingly.\n\nSee https://github.com/hasura/graphql-engine/issues/4217\n*/\nCREATE FUNCTION hdb_catalog.gen_hasura_uuid() RETURNS uuid AS\n-- We assume gen_random_uuid() is available in the search_path.\n-- This may not be true but we can't do much till https://github.com/hasura/graphql-engine/issues/3657\n'select gen_random_uuid()' LANGUAGE SQL;\n\nCREATE TABLE hdb_catalog.hdb_version (\n    hasura_uuid UUID PRIMARY KEY DEFAULT hdb_catalog.gen_hasura_uuid(),\n    version TEXT NOT NULL,\n    upgraded_on TIMESTAMPTZ NOT NULL,\n    cli_state JSONB NOT NULL DEFAULT '{}'::jsonb,\n    console_state JSONB NOT NULL DEFAULT '{}'::jsonb\n);\n\nCREATE UNIQUE INDEX hdb_version_one_row\nON hdb_catalog.hdb_version((version IS NOT NULL));\n\n-- Create table which stores metadata JSON blob\nCREATE TABLE hdb_catalog.hdb_metadata\n(\n  id INTEGER PRIMARY KEY,\n  metadata JSON NOT NULL,\n  resource_version INTEGER NOT NULL DEFAULT 1 UNIQUE\n);\n\nCREATE TABLE hdb_catalog.hdb_action_log\n(\n  id UUID PRIMARY KEY DEFAULT hdb_catalog.gen_hasura_uuid(),\n  -- we deliberately do not reference the action name\n  -- because sometimes we may want to retain history\n  -- after dropping the action\n  action_name TEXT,\n  input_payload JSONB NOT NULL,\n  request_headers JSONB NOT NULL,\n  session_variables JSONB NOT NULL,\n  response_payload JSONB NULL,\n  errors JSONB NULL,\n  created_at timestamptz NOT NULL default now(),\n  response_received_at timestamptz NULL,\n  status text NOT NULL,\n  CHECK (status IN ('created', 'processing', 'completed', 'error'))\n);\n\nCREATE TABLE hdb_catalog.hdb_cron_events\n(\n  id TEXT DEFAULT hdb_catalog.gen_hasura_uuid() PRIMARY KEY,\n  trigger_name TEXT NOT NULL,\n  scheduled_time TIMESTAMPTZ NOT NULL,\n  status TEXT NOT NULL DEFAULT 'scheduled',\n  tries INTEGER NOT NULL DEFAULT 0,\n  created_at TIMESTAMPTZ DEFAULT NOW(),\n  next_retry_at TIMESTAMPTZ,\n\n  CONSTRAINT valid_status CHECK (status IN ('scheduled','locked','delivered','error','dead'))\n);\n\nCREATE INDEX hdb_cron_event_status ON hdb_catalog.hdb_cron_events (status);\n\nCREATE UNIQUE INDEX hdb_cron_events_unique_scheduled ON\nhdb_catalog.hdb_cron_events (trigger_name, scheduled_time)\nwhere status = 'scheduled';\n\nCREATE TABLE hdb_catalog.hdb_cron_event_invocation_logs\n(\n  id TEXT DEFAULT hdb_catalog.gen_hasura_uuid() PRIMARY KEY,\n  event_id TEXT,\n  status INTEGER,\n  request JSON,\n  response JSON,\n  created_at TIMESTAMPTZ DEFAULT NOW(),\n\n  FOREIGN KEY (event_id) REFERENCES hdb_catalog.hdb_cron_events (id)\n    ON UPDATE CASCADE ON DELETE CASCADE\n);\n\nCREATE TABLE hdb_catalog.hdb_scheduled_events\n(\n  id TEXT DEFAULT hdb_catalog.gen_hasura_uuid() PRIMARY KEY,\n  webhook_conf JSON NOT NULL,\n  scheduled_time TIMESTAMPTZ NOT NULL,\n  retry_conf JSON,\n  payload JSON,\n  header_conf JSON,\n  status TEXT NOT NULL DEFAULT 'scheduled',\n  tries INTEGER NOT NULL DEFAULT 0,\n  created_at TIMESTAMPTZ DEFAULT NOW(),\n  next_retry_at TIMESTAMPTZ,\n  comment TEXT,\n  CONSTRAINT valid_status CHECK (status IN ('scheduled','locked','delivered','error','dead'))\n);\n\nCREATE INDEX hdb_scheduled_event_status ON hdb_catalog.hdb_scheduled_events (status);\n\nCREATE TABLE hdb_catalog.hdb_scheduled_event_invocation_logs\n(\n  id TEXT DEFAULT hdb_catalog.gen_hasura_uuid() PRIMARY KEY,\n  event_id TEXT,\n  status INTEGER,\n  request JSON,\n  response JSON,\n  created_at TIMESTAMPTZ DEFAULT NOW(),\n\n  FOREIGN KEY (event_id) REFERENCES hdb_catalog.hdb_scheduled_events (id)\n     ON DELETE CASCADE ON UPDATE CASCADE\n);\n\n-- NOTE: In OSS this table only contains a single row (indicated by ID 1).\n--       This may change to allow multiple notifications in future.\nCREATE TABLE hdb_catalog.hdb_schema_notifications\n(\n  id INTEGER PRIMARY KEY CHECK (id = 1),\n  notification JSON NOT NULL,\n  resource_version INTEGER NOT NULL DEFAULT 1,\n  instance_id UUID NOT NULL,\n  updated_at TIMESTAMPTZ DEFAULT NOW()\n);\n",
        "prepared": false,
        "error": {
          "exec_status": "FatalError",
          "hint": null,
          "message": "function \"gen_hasura_uuid\" already exists with same argument types",
          "status_code": "42723",
          "description": null
        },
        "arguments": []
      },
      "path": "$",
      "error": "database query error",
      "code": "unexpected"
    }
  }
}
rikinsk commented 2 years ago

@dougg0k can you share the earlier hasura version that was connected to the db to help us try reproducing this

dougg0k commented 2 years ago

Was v2.0.1 with scripts v1.

sbhatnagar-equinix commented 2 years ago

Hi @rikinsk , is there any resolution to this problem? I am facing the same, with kubernetes.