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

#3129 Fix to verify DBJson dirtiness using same field ordering on both sides (due to PostgreSQL reordering fields for JsonB types) #3405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AntoineDuComptoirDesPharmacies

Same as PR #3402 but starting / targeting master branch.

This pull request aim to fix a problem (#3129) where @DbJsonB fields are always considered dirty on load if the order of their properties do not match fields ordering from data stored in Postgres.

This is due to the fact that Postgres is re-ordering the fields if column type is a JsonB in order to optimize storage / index / etc...

To solve this problem, we parse/format the value coming from readSet method in order to be sure that comparison will be done using Java Jackson encoded JSON on both side.

Fix to verify DBJson dirtiness using same field ordering on both sides (due to PostgreSQL reordering fields for JsonB types)
@AntoineDuComptoirDesPharmacies
Copy link
Author

Hi @rbygrave,

If you feel there is something missing to complete the PR or need additional information, do not hesitate to ask, we are available. 👍

Yours faithfully,
LCDP

@rbygrave
Copy link
Member

Yeah sorry, been busy. At the back of my mind I'm wondering if there is another design option. That is, the design started from more the view that the json coming back out of the db would match the json going in, and I think that isn't holding up well. For example, the checksum for the content could be stored as a derived column and in that way we only care about the one direction in terms of json content and it's checksum. So I haven't quite had time to look at that design option yet, but that is the background thinking going on.

@AntoineDuComptoirDesPharmacies
Copy link
Author

No problem, it is to be sure that we could not have help more on our side.

Great idea about storing object checksum as a derived data of the POJO. So that instead of comparing checksum(rawDbValue) with checksum(newPojoAsJson) we would compare storedChecksumFromDb with checksum(newPojoAsJson) .

It would consume more disk space but the benefit is that it will speed up checksum comparison.

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