Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: db transaction inconsistencies when deleting keys #1139

Merged
2 commits merged into from
Apr 3, 2024

Conversation

megglos
Copy link
Contributor

@megglos megglos commented Apr 2, 2024

Description

The main cause of #1001 was the bug fixed via 77e162c . Within the same transaction you couldn't insert a previously deleted key, this happened as after processing the first processes complete command a new message start event correlation was triggered, failing as the previous active process instance was still in the database as the transaction wasn't commited and deleted keys of the transaction weren't checked.

I also noticed there was a bug in the get by key method, not checking the deletedKeys set either and fixed that too with bf9e1eb .

I verified the fix as well with the test case provided in the original issue, I decided against adding it though as the unit test covers the behavior of the db transaction that was the cause of the message start event test case failing.

Related issues

closes #1001

@megglos megglos requested review from korthout and berkaycanbc April 2, 2024 05:51
Copy link

github-actions bot commented Apr 2, 2024

Test Results

 50 files   50 suites   1m 39s ⏱️
138 tests 138 ✅ 0 💤 0 ❌
438 runs  438 ✅ 0 💤 0 ❌

Results for commit bf9e1eb.

Copy link
Member

@korthout korthout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

Comment on lines -111 to +112
return transactionCache.containsKey(keyBytes) || database.containsKey(keyBytes);
return !deletedKeys.contains(keyBytes)
&& (transactionCache.containsKey(keyBytes) || database.containsKey(keyBytes));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice find! Makes sense

Comment on lines +76 to +78
if (deletedKeys.contains(key)) {
return null;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Makes sense too! Nice find!

@korthout
Copy link
Member

korthout commented Apr 2, 2024

@megglos There is already a release-8.5.0 branch, so you may want to also backport this there

@megglos
Copy link
Contributor Author

megglos commented Apr 3, 2024

bors merge

ghost pushed a commit that referenced this pull request Apr 3, 2024
1139: fix: db transaction inconsistencies when deleting keys r=megglos a=megglos

## Description

The main cause of #1001 was the bug fixed via 77e162c . Within the same transaction you couldn't insert a previously deleted key, this happened as after processing the first processes complete command a new message start event correlation was triggered, failing as the previous active process instance was still in the database as the transaction wasn't commited and deleted keys of the transaction weren't checked.

I also noticed there was a bug in the `get` by key method, not checking the deletedKeys set either and fixed that too with bf9e1eb .

I verified the fix as well with the test case provided in the original issue, I decided against adding it though as the unit test covers the behavior of the db transaction that was the cause of the message start event test case failing.

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #1001

Co-authored-by: Meggle (Sebastian Bathke) <sebastian.bathke@camunda.com>
@ghost
Copy link

ghost commented Apr 3, 2024

Build failed:

@megglos
Copy link
Contributor Author

megglos commented Apr 3, 2024

bors retry

flake

@ghost
Copy link

ghost commented Apr 3, 2024

Build succeeded:

@ghost ghost merged commit ec82e60 into main Apr 3, 2024
11 checks passed
@ghost ghost deleted the meg-1001-fix-db-inconsistencies branch April 3, 2024 04:51
@backport-action
Copy link
Collaborator

Successfully created backport PR for stable/8.1:

@backport-action
Copy link
Collaborator

Successfully created backport PR for stable/8.2:

@backport-action
Copy link
Collaborator

Successfully created backport PR for stable/8.3:

@backport-action
Copy link
Collaborator

Successfully created backport PR for stable/8.4:

@backport-action
Copy link
Collaborator

Successfully created backport PR for release-8.5.0:

ghost pushed a commit that referenced this pull request Apr 3, 2024
1142: [Backport stable/8.2] fix: db transaction inconsistencies when deleting keys r=github-actions[bot] a=backport-action

# Description
Backport of #1139 to `stable/8.2`.

relates to #1001 #1001

Co-authored-by: Meggle (Sebastian Bathke) <sebastian.bathke@camunda.com>
ghost pushed a commit that referenced this pull request Apr 3, 2024
1145: [Backport release-8.5.0] fix: db transaction inconsistencies when deleting keys r=github-actions[bot] a=backport-action

# Description
Backport of #1139 to `release-8.5.0`.

relates to #1001 #1001

Co-authored-by: Meggle (Sebastian Bathke) <sebastian.bathke@camunda.com>
ghost pushed a commit that referenced this pull request Apr 3, 2024
1143: [Backport stable/8.3] fix: db transaction inconsistencies when deleting keys r=github-actions[bot] a=backport-action

# Description
Backport of #1139 to `stable/8.3`.

relates to #1001 #1001

Co-authored-by: Meggle (Sebastian Bathke) <sebastian.bathke@camunda.com>
ghost pushed a commit that referenced this pull request Apr 3, 2024
1144: [Backport stable/8.4] fix: db transaction inconsistencies when deleting keys r=github-actions[bot] a=backport-action

# Description
Backport of #1139 to `stable/8.4`.

relates to #1001 #1001

Co-authored-by: Meggle (Sebastian Bathke) <sebastian.bathke@camunda.com>
ghost pushed a commit that referenced this pull request Apr 3, 2024
1141: [Backport stable/8.1] fix: db transaction inconsistencies when deleting keys r=github-actions[bot] a=backport-action

# Description
Backport of #1139 to `stable/8.1`.

relates to #1001 #1001

Co-authored-by: Meggle (Sebastian Bathke) <sebastian.bathke@camunda.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZeebeDbInconsistentException in column MESSAGE_PROCESSES_ACTIVE_BY_CORRELATION_KEY
3 participants