xcherryio / xcherry

server and main repo of xCherry project
Apache License 2.0
26 stars 1 forks source link

fix deadlock by locking proc exec row first #55

Closed duoertai closed 11 months ago

duoertai commented 11 months ago

Why make this pull request?

Fix deadlock issue by locking xdb_sys_process_executions row first in all cases that involves updating existing state

What has changed

sql_process_store.go

  1. start process -> apply terminate if running policy
  2. complete wait until
  3. complete execution
  4. stop process

[Link to xdb-apis/xdb-golang-sdk PRs if it's on top of any API changes]

How to test this pull request?

existing integ test and unit test

Checklist before merge

[ ] If applicable, merge the xdb-apis/xdb-golang-sdk PRs to main branch [ ] If applicable, merge the xdb-apis/xdb-apis PRs to main branch [ ] Update go.mod to use the commitID of the main branches for xdb-apis/xdb-golang-sdk

codecov[bot] commented 11 months ago

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (53f688a) 68.71% compared to head (b136121) 69.75%. Report is 1 commits behind head on main.

:exclamation: Current head b136121 differs from pull request most recent head 1e3c2ab. Consider uploading reports for the commit 1e3c2ab to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #55 +/- ## ========================================== + Coverage 68.71% 69.75% +1.04% ========================================== Files 46 46 Lines 4031 4044 +13 ========================================== + Hits 2770 2821 +51 + Misses 1072 1038 -34 + Partials 189 185 -4 ``` | [Files](https://app.codecov.io/gh/xdblab/xdb/pull/55?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xdblab) | Coverage Δ | | |---|---|---| | [extensions/postgres/non\_transactional.go](https://app.codecov.io/gh/xdblab/xdb/pull/55?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xdblab#diff-ZXh0ZW5zaW9ucy9wb3N0Z3Jlcy9ub25fdHJhbnNhY3Rpb25hbC5nbw==) | `86.04% <100.00%> (ø)` | | | [extensions/postgres/transactional.go](https://app.codecov.io/gh/xdblab/xdb/pull/55?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xdblab#diff-ZXh0ZW5zaW9ucy9wb3N0Z3Jlcy90cmFuc2FjdGlvbmFsLmdv) | `84.00% <ø> (+13.41%)` | :arrow_up: | | [engine/worker\_task\_queue.go](https://app.codecov.io/gh/xdblab/xdb/pull/55?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xdblab#diff-ZW5naW5lL3dvcmtlcl90YXNrX3F1ZXVlLmdv) | `68.84% <90.47%> (+4.43%)` | :arrow_up: | | [persistence/sql/sql\_process\_store.go](https://app.codecov.io/gh/xdblab/xdb/pull/55?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xdblab#diff-cGVyc2lzdGVuY2Uvc3FsL3NxbF9wcm9jZXNzX3N0b3JlLmdv) | `63.46% <57.14%> (+2.45%)` | :arrow_up: | ... and [4 files with indirect coverage changes](https://app.codecov.io/gh/xdblab/xdb/pull/55/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xdblab)

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