openactive / OpenActive.Server.NET

.NET server library, including an OpenActive Reference Implementation
MIT License
0 stars 7 forks source link

Add parallel request protection for Order B #146

Closed matdavies closed 3 years ago

matdavies commented 3 years ago

Related to #100

Adds AsyncDuplicateLock, which was copied from Steven Cleary's answer to this SO question. We've used this for years to prevent the same situation in callbacks from POS webhooks or Payment Gateway callbacks, so confident in its functionality. Though, I appreciate, there are no tests here...

nickevansuk commented 3 years ago

Looks good @matdavies ! Sorry realise I missed one more - should the lock also apply to all other endpoints that operate on that UUID, e.g. ProcessCheckpoint (to protect leasing overlaps?), and cancellation, etc? Basically to avoid any unexpected behaviour where a UUID get operated on more than once, through whichever endpoint?

Specifically that would be in each of the "write" endpoints defined in the IBookingEngine interface:

https://github.com/openactive/OpenActive.Server.NET/blob/5b04adcc772f3cfd7a25231038e33880d4683ebd/OpenActive.Server.NET/Entrypoint/IBookingEngine.cs#L25-L38

Note that for ProcessCheckpoint1 and ProcessCheckpoint2 the lock can be simply added to ProcessCheckpoint

matdavies commented 3 years ago

Hi @nickevansuk , have added locks to all write endpoints except TriggerTestAction, because in that case I was not sure what the key should be. If you let me know a sensible key there, I will add.