Skip to content

use createItem instead of upsertItem for create api

Alok Joshi requested to merge use_create_item into master

Use createItem instead of upsertItem when creating a legal tag. This prevents concurrent creation of the same legaltag which was being an issue with a particular integration test (should_onlyLetAMaximumOf1LegaltagBeCreated_when_tryingToCreateMultipleVersionsOfTheSameContractAtTheSameTime). The root cause of failure of this integration test was concurrency: after the recent scaling change, multiple service instances try to create the same legaltag at the same time and more than 1 instances succeed. The reason is two folds: Legal uses upsertItem instead of createItem function to create the legal tag, which allows create and updates on the data in cosmos; the second reason being we are using instance based locking which won't work in a distributed (multi instance) scenario.

We also don't need the explicit lock inside create() method now because we use createItem, which inherently doesn't allow creation of the same object if it exists in the cosmos db.

Removed a duplicate dependency declaration from pom.

Edited by Alok Joshi

Merge request reports

Loading