flyte icon indicating copy to clipboard operation
flyte copied to clipboard

[BUG] Duplicate Database Creation

Open Yicheng-Lu-llll opened this issue 1 year ago • 2 comments

Describe the bug

When first running:

flytectl demo start --dev
# Under flyte repo
make compile
POD_NAMESPACE=flyte ./flyte start --config flyte-single-binary-local.yaml

The following errors may occurs.

{"json":{"src":"start.go:63"},"level":"info","msg":"Running Database Migrations...","ts":"2023-07-07T05:13:37Z"}
{"json":{"src":"initialize.go:41"},"level":"warning","msg":"Database [flyte] does not exist, trying to create it now","ts":"2023-07-07T05:13:37Z"}
{"json":{"src":"database.go:123"},"level":"warning","msg":"Database [flyte] does not exist","ts":"2023-07-07T05:13:37Z"}
{"json":{"src":"database.go:136"},"level":"info","msg":"Creating database flyte","ts":"2023-07-07T05:13:37Z"}
{"json":{"src":"handle.go:59"},"level":"info","msg":"Creating Database flyte since it does not exist","ts":"2023-07-07T05:13:37Z"}
{"json":{"src":"initialize.go:54"},"level":"error","msg":"Failed to create DB flyte err ERROR: duplicate key value violates unique constraint \"pg_database_datname_index\" (SQLSTATE 23505)","ts":"2023-07-07T05:13:37Z"}
panic: ERROR: duplicate key value violates unique constraint "pg_database_datname_index" (SQLSTATE 23505)

It seems that during initialization, the process attempts to create the flyte database twice. this isn't a big issue as it can be resolved by simply rerunning the command POD_NAMESPACE=flyte ./flyte start --config flyte-single-binary-local.yaml. It will not encounter the same issue on subsequent runs as the flyte database will already exist.

Expected behavior

No errors when first running POD_NAMESPACE=flyte ./flyte start --config flyte-single-binary-local.yaml.

Additional context to reproduce

No response

Screenshots

No response

Are you sure this issue hasn't been raised already?

  • [X] Yes

Have you read the Code of Conduct?

  • [X] Yes

Yicheng-Lu-llll avatar Jul 07 '23 05:07 Yicheng-Lu-llll