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(dual schema): use aspect table as SOT for optimistic locking in DUAL_SCHEMA mode #483

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

jsdonn
Copy link
Contributor

@jsdonn jsdonn commented Dec 7, 2024

Summary

Previously, optimistic locking had the following behavior:

in NEW_SCHEMA and DUAL_SCHEMA modes:
getLatest from entity table
add with optimistic locking to aspect table using old timestamp from entity table

in OLD_SCHEMA mode:
getLatest from aspect table
add with optimistic locking to aspect table using old timestamp from aspect table

Now, use the aspect table when in DUAL_SCHEMA mode which makes sense since DUAL_SCHEMA mode will read from both tables but eventually return the result from the old schema table anyways.

Testing Done

update unit tests

Checklist

@jsdonn jsdonn marked this pull request as ready for review December 7, 2024 00:35
Copy link
Contributor

@rakhiagr rakhiagr left a comment

Choose a reason for hiding this comment

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

LGTM

numOfUpdatedRows = runInTransactionWithRetry(() -> {
// Additionally, in DUAL_SCHEMA mode: apply a regular update (no optimistic locking) to the entity table
if (_schemaConfig == SchemaConfig.DUAL_SCHEMA) {
_localAccess.addWithOptimisticLocking(urn, (ASPECT) value, aspectClass, newAuditStamp, null,
Copy link
Contributor

Choose a reason for hiding this comment

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

is this conflict with the comment (no optimistic locking)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment is correct, we pass null oldTimestamp to the addWithOptimisticLocking function on the entity tables, which will just do a regular update because of null oldTimestamp

Copy link
Contributor

@yangyangv2 yangyangv2 left a comment

Choose a reason for hiding this comment

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

Overall looks good, just a clarification question once confirmed, feel free to ship.

@jsdonn jsdonn merged commit ae21b69 into linkedin:master Dec 9, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants