open-horizon / exchange-api

Horizon Exchange REST API Server
Apache License 2.0
11 stars 30 forks source link

Review which routes need to be changed to a single DB transaction #437

Open sf2ne opened 4 years ago

sf2ne commented 4 years ago

The paginated routes (/changes, policy /search, pattern /search) already are a single transaction.

Regarding transactions, slick, and postgresql:

val f: Future[Unit] = db.run(a)



Potentially related to: https://github.com/open-horizon/exchange-api/issues/402
naphelps commented 3 years ago

These 5 routes effect policy/pattern search route(s):

nodePutPolicyRoute nodeDeletePolicyRoute nodePutAgreementRoute nodeDeleteAgreementsRoute nodeDeleteAgreementRoute

These routes make multiple independent DB changes which include updating the lastUpdated attribute. Each change is its own transaction and when the route fails the DB changes up to that point remain. The downstream impact of this on the search routes is random skipping/hanging in returned nodes. It can at times prevent the search routes from returning any nodes.

Additional routes with similar issues likely exist within the exchange.

naphelps commented 3 years ago

Transactions from multiple routes and well as multiple calls to the same route are presently allowed to be interleaved. This can have unknown consequences on downstream routes that use data in the DB to function.