-
When we upgraded from v24 to v30 we noticed that queries that run in a lambda that is terminated due to a timeout are rolled back, even though the queries are not part of a transaction. In the simplest case, we have a lambda that looks roughly like this:
In v24, the materialized view is always refreshed, even if it takes long enough that the lambda is terminated. In v30, the view no longer updates in cases where the lambda is terminated. The same behaviour also applies in cases where the termination occurs after the query finishes, if another query or request delays the lambda long enough. It looks as if all queries are running in a transaction by default that is committed when the pool is closed, with no way to manually commit it before that. I'm no longer sure how to safely implement the following scenario without resorting to a message queue:
If (3) fails, then (1) is rolled back, but the user already got notified that (1) succeeded. Any help or insights are much appreciated 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I don't believe that is the case. If you submit a PR showing otherwise, this would be a bug.
If the backend is terminated, then it is expected that the materialized view would fail. It is not rolling back – the action just does not complete.
I don't believe that is the case. If you submit a PR showing otherwise, this would be a bug. |
Beta Was this translation helpful? Give feedback.
-
Hey @gajus, sorry that it's taken so long but I've gotten green light to set up a sponsorship from Proposales. Naturally, that's not conditional on the resolution of this issue, we're going to keep sponsoring you as long as we're using Slonik internally 🙂
I will look into that!
I can't say for certain what Vercel does when a lambda exceeds its maximum duration, but my guess is that they send a SIGKILL. I wouldn't know how the database connections are terminated when the process is killed. We can say with certainty that refreshing the materialized view, when started via a query using the |
Beta Was this translation helpful? Give feedback.
I don't believe that is the case. If you submit a PR showing otherwise, this would be a bug.
If the backend is terminated, then it is expected that the materialized view would fail. It is not rolling back – the action just does not complete.