-
Notifications
You must be signed in to change notification settings - Fork 59
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
Ensure most recent metadata is served despite duplicate version 0's #268
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
several comments
dao-impl/ebean-dao/src/test/java/com/linkedin/metadata/dao/EbeanLocalDAOTest.java
Outdated
Show resolved
Hide resolved
@@ -892,6 +892,8 @@ private List<EbeanMetadataAspect> batchGetUnion(@Nonnull List<AspectKey<URN, ? e | |||
} | |||
} | |||
|
|||
sb.append(" ORDER BY createdOn DESC"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be inside the For loop. Basically you want
// SELECT * FROM metadata_aspect WHERE urn = 'urn0' AND aspect = 'aspect0' AND version = 0 ORDER BY createdOn DESC limit 1
// UNION ALL
// SELECT * FROM metadata_aspect WHERE urn = 'urn0' AND aspect = 'aspect1' AND version = 0 ORDER BY createdOn DESC limit 1
does it make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought through this as well and believed it should be outside because in the case where you're running multiple SELECT's, we want the final result to be ordered, not just each subsection.
Checklist
<fix> :
added ordering to get() make sure that the most recent record (despite duplicates in other versioning) is at the top and returned<test> :
added a unit test with corresponding SQL script to ensure that the above fix worksThe unit test requires a new script because the existing scripts would throw a Primary / Unique Key Error; a new script that adds
createdOn
was required.