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 rollback when rollback to tail_lsn. #532

Merged
merged 2 commits into from
Aug 30, 2024

Conversation

xiaoxichen
Copy link
Collaborator

previously we dont properly handle this case,
which will error out in

m_records.rollback(to_lsn);
as the to_lsn + 1 is invalid in this case.

previously we dont properly handle this case,
which will error out in https://github.com/eBay/HomeStore/blob/2080ad42e31a9ddf0a41d3a112db4d1c020c45ee/src/lib/logstore/log_store.cpp#L315
as the to_lsn + 1 is invalid in this case.

Signed-off-by: Xiaoxi Chen <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Aug 29, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 67.53%. Comparing base (1a0cef8) to head (91a4566).
Report is 55 commits behind head on master.

Files with missing lines Patch % Lines
src/lib/logstore/log_store.cpp 66.66% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #532       +/-   ##
===========================================
+ Coverage   56.51%   67.53%   +11.01%     
===========================================
  Files         108      109        +1     
  Lines       10300    10429      +129     
  Branches     1402     1401        -1     
===========================================
+ Hits         5821     7043     +1222     
+ Misses       3894     2710     -1184     
- Partials      585      676       +91     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@JacksonYao287 JacksonYao287 left a comment

Choose a reason for hiding this comment

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

the basic logic is right. I left my comment , PATL.
also , please add some detail comments to the function decription to make the function more clear.

to_lsn is the tail_lsn after rollback

@@ -166,11 +166,6 @@ class SampleLogStoreClient {
}

void rollback_validate(uint32_t num_lsns_to_rollback) {

Copy link
Contributor

Choose a reason for hiding this comment

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

why this is removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe @sanebay hit this issue when he was doing the log store long running... he worked around in the UT but with the fix in implementation we dont need this work around in UT.

Comment on lines 286 to 295
//Fast path
if (to_lsn == m_tail_lsn.load()) {
return true;
}

if (to_lsn > m_tail_lsn.load()) {
HS_LOG_ASSERT(false, "Attempted to rollback to {} which is larger than tail_lsn {}", to_lsn, m_tail_lsn.load());
return false;
}

Copy link
Contributor

@JacksonYao287 JacksonYao287 Aug 29, 2024

Choose a reason for hiding this comment

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

actually , what rollback does is to reset the tail_lsn to a valid lsn in the range [start_lsn , tail_lsn]. so if the rollback_to_lsn is not in the range, we can log an error and return false.
so my suggestion is adding the following code is enough, and the check in line 297 can also be removed.

if(to_lsn < m_start_lsn || to_lsn > m_tail_lsn) {
        LOGERROR;
        return false;
}

Signed-off-by: Xiaoxi Chen <[email protected]>
Copy link
Contributor

@JacksonYao287 JacksonYao287 left a comment

Choose a reason for hiding this comment

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

LGTM

@xiaoxichen xiaoxichen merged commit 7cd1eab into eBay:master Aug 30, 2024
21 checks passed
}

if (to_lsn > m_tail_lsn.load() || to_lsn < m_start_lsn.load()) {
HS_LOG_ASSERT(false, "Attempted to rollback to {} which is not in the range of [{}, {}]", to_lsn, m_start_lsn.load(), m_tail_lsn.load());
return false;
}

Copy link
Contributor

@yamingk yamingk Aug 30, 2024

Choose a reason for hiding this comment

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

nit: Can we also have an assert here for HS_DEBUG_ASSERT(m_records.status(to_lsn + 1).is_out_of_range == false)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there are two angle,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the sisl one can be take as a bug, IMO.

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.

4 participants