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 truncate tail #33

Merged
merged 6 commits into from
Oct 20, 2023
Merged

Fix truncate tail #33

merged 6 commits into from
Oct 20, 2023

Conversation

banks
Copy link
Member

@banks banks commented Oct 16, 2023

Fixes #31.

The WAL layer assumes that the tail index will be sealed during a tail truncate and marks it as such in the meta store but doesn't actually have a mechanism currently to force the segment writer to append an index block.

This PR fixes that by adding such a mechanism.

Integration Tests

Since this is another issue that escaped due to lack of integration testing between the component layers, I've added a basic initial integration suite that uses WAL with real Segment/Meta/FS in some basic scenarios.

Although basic, two of the scenarios failed without the fix to call ForceSeal in this PR in the same way as #31. There is also at least one scenario that would have failed my initial integration with Consul before I had the snapshot behaviour correct (another integration testing miss).

Perhaps in the future we can extend this to cover other scenarios or to use fault injection or fuzzing etc. But for now this is a solid improvement over no integration tests!

@banks
Copy link
Member Author

banks commented Oct 16, 2023

There are some tests failing due to the additional validation I added - it looks like we have some work to do to consistently support seal metadata correctly in testStorage as it kinda ignored that detail as a segment issue until now. Will work on that too.

@banks banks marked this pull request as ready for review October 16, 2023 21:14
Copy link

@dhiaayachi dhiaayachi left a comment

Choose a reason for hiding this comment

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

🚀
Reading and trying to understand all the synchronization mechanisms around the segment operations was so enlightening! 😄

I think one integration test that we need to make at some point is retro compatibility with the on disk format. This could be achieved by saving a few test scenarios with each released version and trying to open/read them in tests in main.

@banks
Copy link
Member Author

banks commented Oct 18, 2023

I think one integration test that we need to make at some point is retro compatibility with the on disk format. This could be achieved by saving a few test scenarios with each released version and trying to open/read them in tests in main.

This is a great call. We've not made any changes to disk format since I first released this yet but when we do we should certainly have an upgrade test. I think you are suggesting that it would be worth having that anyway just in case we accidentally change something. Not a bad call. I guess it wouldn't be too hard to write out a test dir into testdata with a flag and then have a test that tries to open and read that.

sealed, indexStart, err := ts.Sealed()
require.NoError(t, err)
require.True(t, sealed)
require.NotEqual(t, 0, int(indexStart))
Copy link
Member Author

Choose a reason for hiding this comment

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

Realised I should also assert that the seg.IndexStart matches the indexStart. It's a bit of a tautology in the sense that segments read from disk would actually populate indexStart from metadata in the first place but in these tests it would actually verify something useful: that the segment we just sealed reported it's index offset consistently and that it was actually updated in the meta data. I'll add that before I merge.

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.

Sealed segment without IndexStart
2 participants