Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
1) When I call order.Save() is there a implicit sql transaction which wraps all the sql delete/insert/update statements that I assume are executed under the hood? Or is it my responsibility to do transaction management?
2) Related, what happens if two requests try to save the same order at the same time (or even a save and read concurrent requests)? Is that handled by TeaCommerece/Umbraco/PetaPOCO, or is it my responsibility? I'm trying to understand the reason for a an duplicate key sql exception being thrown in my code on a webhook call from the payment provider (Stripe).
1) As of 3.3.1 yes. An order save is now performed within a transaction (this was added for the exact reason you are experiencing)
2) This is an area that needs to be looked into further. The transaction added in 3.3.1 does resolve that key error, however it doesn't resolve the issue entirely. The main issue being, the two requests still run, which can allow logic to be run twice that you'd expect to only run once. ie, should the order be finalized as part of the first request, it is possible for the second request to cause a save which runs finalization logic again (because the internal model hasn't been updated yet and so it doesn't know it's being finalized already). This can result in the order being finalized twice and thus firing events for things like sending out emails twice.
I'm not quite sure how to resolve that one yet, but the transaction added in 3.3.1 is a step in the right direction.
If you have an ideas of something you were planning to implement, do let me know as it could help the route I go.
Hope this helps
Ok, thanks Matt!
We are a bit behind on the version right now (3.2.4), and have a custom Stripe implementation. I'll probably take the time to upgrade and synchronize with 3.3.1 in the next couple weeks. There's a chance I might be able to give you some feedback then :-)
Hehe, thanks Tor.
I'm always open to feedback 👍
All the best
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted