content icon indicating copy to clipboard operation
content copied to clipboard

stopping the request during the first page view is breaking initialization

Open elevatebart opened this issue 11 months ago • 6 comments

Environment

Version

v3+

Reproduction

https://kestra.io

Description

When DB init takes more that 100s, the Cloudflare timeout takes on and returns. I hope the query finishes but it's hard to make sure of.

Would it be better to do this init as a "fire and forget"? We could send a flag with each dataset saying "initializing" so we can tell users what is happening and still communicate a progress. Even better we could have a ProgressBar component telling where we are.

Additional context

No response

Logs


elevatebart avatar Feb 19 '25 13:02 elevatebart

If we remove these 3 lines, the init will continue but h3 will return to the users browser early with no values. Hence, no timeout. Because there would be no value, users would wonder what is happening, why they see an error/no values.

To mitigate that, we could have another API returning the status of the database compared to the dump.

We could even have a WebSocket based progress-bar component.

elevatebart avatar Feb 19 '25 20:02 elevatebart

Hi Team,

I have narrowed the issue down to a simple and reliable way to reproduce the issue on cloudflare:

There is only one request that initializes a collection in the database. If that request is cancelled, the system is blocked... forever.

And to cancel a request, one only needs to close the tab or hit "stop" in chrome.

To reproduce, use a significant collection. It will give you more time to hist stop later. During the first request to te collection, click stop. Now check the Database:

  • ready is 0,
  • values are not being inserted anymore,
  • in the logs, the requests is shown as cancelled
Image

Suggestion

The "fire and forget" seems to be the only solution here. We could have a separate service running the init without interruption.

No need at first for the whole progress bar shabang, but the init needs to get through always

Alternative

The ready flag could become a number of inserts already done so the next non-cancelled request could take over where the previous one left off.

Issue with alternative: How do we prevent exact concurrent pickup of same request (specially if it's an update concat)?

elevatebart avatar Feb 22 '25 14:02 elevatebart

IDEA: In the meantime I would like to create an endpoint that will run this init asynchronously.

/api/content/:collection/init or /api/content/:collection/deploy

This would manually launch deployment of databases when things get borked and return immediately. It could save some users bacon and be used to do the above suggestion later.

elevatebart avatar Feb 22 '25 14:02 elevatebart

I found a helping tool here I think

https://nitro.build/guide/tasks

I feel that the initialization/update of the database should be a "Nitro task".

  • It has to be done once and only once (cannot be run by multiple people)
  • It should not be stopped before the end
  • It could take longer than a typical efficient http request <- This ticket

I will investigate

elevatebart avatar Feb 25 '25 12:02 elevatebart

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Apr 26 '25 12:04 github-actions[bot]

It is still absolutely a recurring problem in 3.4.0

elevatebart avatar Apr 26 '25 18:04 elevatebart

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jun 25 '25 19:06 github-actions[bot]

I will open a new issue if I find a way to fix it. It does not seem to be a priority of yours.

Thank you anyway

elevatebart avatar Jun 26 '25 07:06 elevatebart