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(new schema): fix duplicate key exception for aspect table #490

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

jsdonn
Copy link
Contributor

@jsdonn jsdonn commented Dec 18, 2024

Summary

In new schema mode, the aspect table is not getting update with optimistic locking on the createdon column. As a result, the duplicate version 0 rows in job-gms are causing duplicate key exceptions even in new schema mode.

To fix, read the latest row from the aspect table, get the timestamp, and also perform an update using the old timestamp to match a single row in the aspect table.

Testing Done

./gradlew build

Checklist

@jsdonn jsdonn marked this pull request as ready for review December 18, 2024 00:19
// table. Therefore, we will apply compare-and-set with oldTimestamp on entity table (addWithOptimisticLocking).
// We will also apply an optimistic locking update over (urn, aspect, version) primary key combination to avoid duplicate
// key exceptions when the primary key includes createdon.
EbeanMetadataAspect result = findLatestMetadataAspect(_server, urn, aspectClass);
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the urn and aspect does not exist? What does this return?

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.

Thanks for fixing this issue 🚢

@jsdonn jsdonn merged commit afb4ee7 into linkedin:master Dec 18, 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.

2 participants