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

feat: improve snapshot generation for NOSQL databses #5775

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

filipelautert
Copy link
Collaborator

@filipelautert filipelautert commented Apr 5, 2024

Brings back what had to be rolledback from PR #5619 to be tested again and fix what is required.

This one may be useful too: https://github.com/liquibase/liquibase-pro/pull/1650

@filipelautert
Copy link
Collaborator Author

@fbiville here we go again!

@filipelautert filipelautert self-assigned this Apr 5, 2024
@filipelautert filipelautert requested a deployment to internal April 9, 2024 19:35 — with GitHub Actions Abandoned
@filipelautert filipelautert requested a deployment to internal April 10, 2024 16:32 — with GitHub Actions Abandoned
Comment on lines +62 to +86
boolean firstRoundDone = false;
SnapshotGenerator lastGenerator = null;
T lastObject = example;
while (snapshotGenerators.hasNext()) {
SnapshotGenerator generator = snapshotGenerators.next();
if (replacedGenerators.contains(generator.getClass())) {
continue;
}
T object = generator.snapshot(lastObject, snapshot, this);
if ((object != null) && (object.getSnapshotId() == null)) {
object.setSnapshotId(snapshotIdService.generateId());
}
// only first generator in the chain is allowed to create new instances - subsequent ones are not
if (firstRoundDone && object != lastObject) {
throw new DatabaseException(String.format("Snapshot generator %s has returned a different reference from the previous generator %s.\n" +
"\tSnapshot object was: %s, it is now: %s.\n" +
"\tConsider declaring %1$s as being replaced by one the generator in the chain via liquibase.snapshot.SnapshotGenerator#replaces.",
generator.getClass().getName(),
lastGenerator.getClass().getName(),
identity(lastObject),
identity(object)));
}
lastObject = object;
lastGenerator = generator;
firstRoundDone = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

This code should be moved to a method that has extensive javadoc on it. It's not obvious what this code is doing currently.

@rberezen rberezen requested a deployment to internal April 11, 2024 16:51 — with GitHub Actions Abandoned
@rberezen rberezen requested a deployment to internal April 11, 2024 18:15 — with GitHub Actions Abandoned
@rberezen rberezen requested a deployment to internal April 11, 2024 18:29 — with GitHub Actions Abandoned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Development
Development

Successfully merging this pull request may close these issues.

None yet

3 participants