Closed sykorax closed 5 years ago
Hi, The goal of this library is to support transaction propagation between methods within the code in a simple manner.
As for your question: If 2 requests are hitting the same controller method, both will have different entityManager instances in different CLS-Hooked Namespace, so concurrency should be solved.
Thanks for the quick response.
Well I initialize the namespace before the application start as your Readme mentions and I force my controller method to sleep with set timeout for some seconds. If even more requests come in in that time window typeorm says that I already have an active transaction so I'm not able to make a new one. Do you think it is because somehow I receive the same manager instance? :/
This is weird... I am using getManager()
Did you try to test your scenario with pure typeorm? These things can also happen because of different DB connection drivers, pools...
Hmm.
I test against Sqlite. Maybe should try with sql server since production environment will be that one.
I'll have a look at this tomorrow. However since i use Nestjs all DI managed by that. So repositories and connections are managed by the Nest container. Do you have de facto experience with nest and typeorm transaction concurrency?
I would be very disappointed if it does not work but It should. Right?
Well, I don't have a lot of experience with Nest (played a bit)
It should work IMHO, but cannot vouch for that.
Ah well I will check it out with sql server tomorrow. I'll let you know what's going on :D and thanks.
Ok, so i have tested with mssql and works fine. It seems that sqlite does not support multiple transactions to be opened at the same time. However i found a thread at typeorm where some queue solution is under discussion.
Sorry for bothering you. Package is awesome! ^^,
Thanks!!!
Ok, so i have tested with mssql and works fine. It seems that sqlite does not support multiple transactions to be opened at the same time. However i found a thread at typeorm where some queue solution is under discussion.
Sorry for bothering you. Package is awesome! ^^,
could you send the link to the Typeorm issue.
Hey,
I use Nestjs with Typeorm. I'm not sure it has a point when transaction comes into it. If node is fully non blocking what's the point of having a single connection but cannot have multiple transactions?
I see that only one transaction is allowed per connection but maybe a transaction queue could solve this problem.
So when two requests hit the same controller method and both requires a transaction the second request will fail since there's another active transaction.
Is this package able to solve this problem?