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
31.03k stars 2.76k forks source link

Hasura holds open connection to metadata DB #10466

Closed banool closed 1 month ago

banool commented 1 month ago

Version Information

Server Version: 2.40.2-ce

Environment

OSS

What is the current behaviour?

We observe that each Hasura instance holds open a connection to the metadata DB for its entire life.

What is the expected behaviour?

It should only hold open a connection when it needs to, e.g. on startup, it should open a connection, read the metadata, and then close the connection. Same thing for exporting / importing / reloading metadata.

How to reproduce the issue?

N/A

Screenshots or Screencast

Please provide any traces or logs that could help here.

Any possible solutions/workarounds you're aware of?

Keywords

ecthiender commented 1 month ago

This is due to a metadata sync mechanism among all the instances.

When there are multiple instances running, metadata can be modified by any instance. Each hasura instance keeps a connection open so it can detect if there's a new version of the metadata, and then refresh it.

banool commented 1 month ago

In my experience the Hasura instances only reload metadata from the DB when you send a reload_metadata request via the metadata API. From looking at the docs I can't find a reference to this behavior or any way to configure it (e.g. the frequency), could you point that out?

manasag commented 1 month ago

I don't see this aspect being documented officially. But there are some notes on the schema sync process in this code https://github.com/hasura/graphql-engine/blob/master/server/src-lib/Hasura/Server/SchemaUpdate.hs#L81

Converting this thread to a discussion.