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 bug in merge #3270

Merged
merged 1 commit into from
Apr 28, 2022
Merged

Fix bug in merge #3270

merged 1 commit into from
Apr 28, 2022

Conversation

johnnyaug
Copy link
Contributor

@johnnyaug johnnyaug commented Apr 27, 2022

When merging from a branch that made no changes, Graveler would create a new commit with an empty metarange ID, causing all the objects to be deleted on the merge destination.
Instead, we should return a "no changes" error.

Test changes

Changed the behavior of the unit tests to take into account the metarange IDs, which until now were ignored.

This required changes to the test cases themselves: before this change, metaranges always got fixed IDs. After this change, IDs are generated according to the metarange's content. In some cases this causes the ID of the base metarange to be equal to the ID of the source or dest metaranges.

In order for them to get different IDs, I added some content to the end of some of the bases. Since all addition are only to the merge bases, this doesn't affect the merge results.

@johnnyaug johnnyaug added the include-changelog PR description should be included in next release changelog label Apr 27, 2022
@johnnyaug johnnyaug requested review from itaidavid and nopcoder April 27, 2022 23:43
@johnnyaug johnnyaug added the pr/merge-if-approved Reviewer: please feel free to merge if no major comments label Apr 27, 2022
Copy link
Contributor

@nopcoder nopcoder left a comment

Choose a reason for hiding this comment

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

When there are no changes to the source, we want the destination to be the result.
Think that the no change should be returned when both point to base.

@@ -66,18 +67,35 @@ type testRunResult struct {
expectedErr error
}

type testMetaRange struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

can be []testRange this way we don't need special construction for all the test code.

type testMetaRange []testRange

@arielshaqed
Copy link
Contributor

When there are no changes to the source, we want the destination to be the result. Think that the no change should be returned when both point to base.

I think that this is correct. So: we should start by agreeing on the desired test results, and only then proceed to the actual fix.

Note that we can determine the correct result by ignoring the "base === {source, dest}" optimization. I mean, suppose I took a case where base and source (or dest) have precisely the same diffs, but one range boundary in base is different. Then the metarange IDs are different and the full algorithm runs. But the result should be the same.

For instance, we could consider adding a test-only flag that turns off these optimizations. Now we can run the tests with and without the flag -- the tests should pass regardless!

Or you could add a field to testMetaRange that gets appended to its ID. Now you can copy the tests in disagreement and change that field on base. We should still get the same result!

Copy link
Contributor

@arielshaqed arielshaqed left a comment

Choose a reason for hiding this comment

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

Thanks! Still want the test with and without changing the base metarange ID, to ensure we have consistent behaviour. But this is not blocking for a bug like this.

pkg/graveler/committed/merge_test.go Show resolved Hide resolved
@guy-har
Copy link
Contributor

guy-har commented Apr 28, 2022

Adding Here This comment just to explain what exactly happened, because it may be a bit confusing

When trying to introduce a merge with no changes an error should* be returned
There was a bug that returned an empty string and no error, which then set the metarangeID of the merge commit to be an empty string

flowchart TD
  A[mid:1] -- Main --> B[mid:2] --> C[mid:""];
  A  -- Branch 1 No Change --> D[mid:1];
  D -- No Change --> C;
Loading
  • An error shouldn't really be returned, It was historically returned when commit and merge were implemented together, This behavior should probably change, but this shouldn't be resolved in this PR

Copy link
Contributor

@nopcoder nopcoder left a comment

Choose a reason for hiding this comment

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

Approve as keeping the previous behaviour. Opening an issue to address the behaviour that will allow us to merge when no changes from base.

@nopcoder nopcoder merged commit 346391d into master Apr 28, 2022
@johnnyaug johnnyaug deleted the bugfix/merge_source_dest_same branch April 28, 2022 20:07
@ozkatz ozkatz added bug/critical bug Something isn't working labels Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/critical bug Something isn't working include-changelog PR description should be included in next release changelog pr/merge-if-approved Reviewer: please feel free to merge if no major comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants