on 07-08-2023 12:53 PM
Hi,
After upgrading our multitenant solution to CAP 7, I'm facing an issue when performing multiple UPDATE transactions on HANA Cloud. Important remark, the first update transaction seems to work, as soon as I try to do a second update the server crashes and states: "Transaction already closed in the logs". Multiple SELECT statements don't have issues.
Good to know, this was working perfectly fine on latest CDS 6 release AND works perfectly fine when running the application with CDS 7 in BAS with SQLITE.
We're running all latest package versions and updated all the dependencies to the latest versions.
Code excerpt (1st update works, seconds update crashes the server):
Logs:
Am I doing something wrong here? Something that changed in CDS 7 that I might have missed? Or is this a bug?
Best regards,
Geert-Jan
Hi Geert-Jan, all,
We improved transaction handling in cds7. What you are experiencing is protection against dangling transactions caused by, for example, missing awaits.
In particular, foo.forEach(async () => { ... }) doesn't do what you might think it does. It triggers execution in a promise, but does not await it. So the "main thread" move along and closes the transaction, while the promises are still underway. Use a for loop instead.
Best,
Sebastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sebastian,
Thank you for clarifying, reworked the whole logic to perform all database updates without using promises. Strange thing is that this issue doesn't occur on sqlite, so from a development perspective it's hard to determine what the root cause is. (I'm expecting the same issue to occur when running this locally in BAS)
I do think this definitely is in improvement, but I don't seem to find the warning about the new protection mechanism in the release notes. Maybe it would be good to mention it in the release notes as well?
Best regards,
Geert-Jan
Hi Geert-Jan,
I doesn't happen on sqlite because there is no pool but a single connection with a queue. So on HANA, connections can be returned to the pool even though they will still be used (e.g., by not awaited promises). This needed to be improved.
I'll forward the feedback regarding the release notes.
Best,
Sebastian
User | Count |
---|---|
75 | |
10 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.