-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected 3 retries when using prisma.$transaction
after a KnownError in 2.17 and bad error parsing
#6156
Comments
prisma.$transaction
after a KnownError in 2.17 and bad error parsing
While debugging #5976, I was able to reliably reproduce the 3 retries. const test2 = async () => {
await prisma.user.findFirst().then(c => console.log(`Finished 1: ${new Date()}`)).catch(err => console.log(`Err 1: ${new Date()}`));
await sleep(10000)
await prisma.user.findFirst().then(c => console.log(`Finished 2: ${new Date()}`)).catch(err => console.log(`Err 2: ${new Date()}`));
await sleep(1000)
await prisma.user.findFirst().then(c => console.log(`Finished 2: ${new Date()}`)).catch(err => console.log(`Err 2: ${new Date()}`));
} And I am killing the DB connection between the first and second call. This generates the following logs where we can see the retries:
|
Yes because I am not sure it is the job of the client to automatically retry on unknown errors. The user should at least have the possibility to turn it off since it can have unintended consequences. |
Marking this as improvement and candidating it. Behavior should be defined here. It is reproducible. |
FWIW, I'm also surprised that we retry here. I would have expected that to be an application-level concern or at most an opt-in option. |
@Sytten I've tried to reproduce this a few ways with Prisma 3.9.1 and I can't get it to automatically retry. Would you be able to test again with the latest version of Prisma and see if this is still an issue? |
I believe they did a lot of internal changes to how prisma handles errors.so this might very well be the case. |
@Sytten I'm on the prisma team.
The last release had a lot of fixes to stabilize the transaction work. Middleware might still experience a timeout with very long-running operations. This will be fixed in the next release.
With failures we aim to always return the error and to never unknowingly retry. If you have time would you be able to see if you still get the 3 retry attempts. I can't find anywhere on the query-engine side where we retry 3 times. And I cannot reproduce it. |
Good to know, you can also ping me on the company slack of prisma (technically still have a contract with prisma as I did QA testing last year). Cool, this will help a lot I think. One thing that I wasn't exactly pleased with the new implementation is that for people using the "old" way with multiple queries in an array, it would be slower due to fact that it would now do multiple calls to the engine instead of one. Anyway I digress since this is not part of the current issue. That is no true, look into the connection pooling/quaint and you will find inconsistencies. I have been pushing prisma to rewrite the connection pooling for a long time because it is frankly one of the weak point of the engine right now and constant battle in production:
As for this particular 3 times retry, it was happening from the client side on unexpected errors (like an engine crash) not from the engine side. If it was removed, then yes this particular issue can be closed. I am happy to walk you through the multitude of issues/comments/experiments I did a while ago to find those problems. |
I've tried to reproduce this and cannot get it this error. We have pushed a lot of fixes that should hopefully resolve this. I'm going to close this. Feel free to re-open if you still get this issue with the latest version of Prisma. |
Bug description
Given the schema:
If you execute:
And the thing happens to violate the unique clause of
PromoterStaff
, it will throw:Looking at the logs, it seems to retry 3 times before failing:
Expected behavior
Environment & setup
It is a somewhat old prisma version, I will try again on a newer version if I get the time.
The text was updated successfully, but these errors were encountered: