Two issues have been identified when running the load test
1. Inconsistent Data:
The existing PUT DataNode implementation first deletes all the child fragments and then add new child fragments based on the input. These two operations are done in a separate transaction which can lead to inconsistent data if the second operation fails.
To avoid it, we can execute both of the operations in the same transaction. However, it does not work if the new fragment and old fragment have the same XPath because hibernate executes the insert operations before the delete. Due to the execution order, DB throws a constraint error when trying to persist the data.
So, we need to change the implementation to delete the fragment only if the input does not have the same XPath and merge if XPath is the same.
2. Concurrency issues:
Hibernate throws StaleStateException for a transaction when another has updated the same data in another transaction.
This issue is not avoidable and a proper error message should be sent to the user.