Hi @Shanka_Somasiri,
I haven’t reviewed the code. But in general when multiple transactions try to update the same documents they might acquire a lock on the updated documents, if they can’t whitin thr configured limits (default 5ms) they will abort.
Additionally other transactions might fail on write conflicts if another in progress transactions modified documents they are about to update.
More details see here:
https://docs.mongodb.com/manual/core/transactions-production-consideration/#acquiring-locks
Thanks
Pavel