jembi / openhim-core-js

The Open Health Information Mediator core component. OpenHIM Support: Post your query on OpenHIE Discourse using the #openhim tag https://discourse.ohie.org/
http://openhim.org
Mozilla Public License 2.0
69 stars 69 forks source link

TB-173 Handle transactions stuck in processing state #1208

Closed arran-standish closed 1 year ago

arran-standish commented 1 year ago

If OpenHIM crashes with a request in-flight (so before the down stream service responds) this transaction will stay in 'Processing' forever and does not provide a true reflection of the transaction state.

So on startup it will find all transactions in that state and update them to failed. It uses mongoose's cursor functionality which returns a stream and so shouldn't interfere with the main application as it will only process once the stream receives data. It also properly respects node's event loop and so won't block it (i.e.: incoming requests still get processed normally).

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 91.66% and project coverage change: +0.02% :tada:

Comparison is base (4ab86ea) 86.81% compared to head (68ae11d) 86.83%.

:exclamation: Current head 68ae11d differs from pull request most recent head cade24e. Consider uploading reports for the commit cade24e to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1208 +/- ## ========================================== + Coverage 86.81% 86.83% +0.02% ========================================== Files 87 87 Lines 5906 5916 +10 ========================================== + Hits 5127 5137 +10 Misses 779 779 ``` | [Files Changed](https://app.codecov.io/gh/jembi/openhim-core-js/pull/1208?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=jembi) | Coverage Δ | | |---|---|---| | [src/model/transactions.js](https://app.codecov.io/gh/jembi/openhim-core-js/pull/1208?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=jembi#diff-c3JjL21vZGVsL3RyYW5zYWN0aW9ucy5qcw==) | `96.15% <88.88%> (-3.85%)` | :arrow_down: | | [src/middleware/messageStore.js](https://app.codecov.io/gh/jembi/openhim-core-js/pull/1208?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=jembi#diff-c3JjL21pZGRsZXdhcmUvbWVzc2FnZVN0b3JlLmpz) | `93.65% <100.00%> (+0.73%)` | :arrow_up: | | [src/server.js](https://app.codecov.io/gh/jembi/openhim-core-js/pull/1208?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=jembi#diff-c3JjL3NlcnZlci5qcw==) | `73.27% <100.00%> (+0.09%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.