Skip to content

SDSTOR-24056: hold lock when updating superblk of raft_repl_dev#898

Merged
JacksonYao287 merged 1 commit into
eBay:stable/v7.xfrom
JacksonYao287:SDSTOR-24056
Jul 20, 2026
Merged

SDSTOR-24056: hold lock when updating superblk of raft_repl_dev#898
JacksonYao287 merged 1 commit into
eBay:stable/v7.xfrom
JacksonYao287:SDSTOR-24056

Conversation

@JacksonYao287

@JacksonYao287 JacksonYao287 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor
  • Add mutex protection around superblock write in leave() to prevent data races
  • Fix typos across comments and log strings

@codecov-commenter

codecov-commenter commented Jul 17, 2026

Copy link
Copy Markdown

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

Codecov Report

❌ Patch coverage is 27.27273% with 8 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (stable/v7.x@7eafb3a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/lib/replication/repl_dev/raft_repl_dev.cpp 22.22% 3 Missing and 4 partials ⚠️
src/lib/replication/repl_dev/raft_repl_dev.h 50.00% 0 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@              Coverage Diff               @@
##             stable/v7.x     #898   +/-   ##
==============================================
  Coverage               ?   48.23%           
==============================================
  Files                  ?      110           
  Lines                  ?    12965           
  Branches               ?     6231           
==============================================
  Hits                   ?     6254           
  Misses                 ?     2578           
  Partials               ?     4133           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/lib/replication/repl_dev/raft_repl_dev.h Outdated

@xiaoxichen xiaoxichen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I dont get the context of this fix in both jira and commit message...

@JacksonYao287

JacksonYao287 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

I dont get the context of this fix in both jira and commit message...

in this PR :
1 I first update a lot of typos, no need to pay too much attention since they are only log and comment text changes.

2 the key logic change in this PR is in RaftReplDev::leave(), where a lock is added before updating the superblk of raft_repl_dev, this is the part the reviewer should pay more attention:

    {
        std::unique_lock lg{m_sb_mtx};
        m_rd_sb->destroy_pending = 0x1;
        m_rd_sb.write();
    }

the reason we need to add this lock is that many threads will try to update m_rd_sb concurrently, for example, RaftReplDev::cp_flush will update it in cp flush thread.

if we update it without a lock, when coming to MetaBlkService::update_sub_sb, it will first calculated the crc of the input buffer, and then write the input data buffer into disk. before the data buffer is written into disk, the crc will be calculated again

so, if the input data buffer is changed by another thread after the first crc calculation , then crc mismatch will occur.

the lock here is used to protect to data buffer not to be changed until update_sub_sb is completed. also, we can see the lock is hold before m_rd_sb.write() in other places in homestore code, but missed in RaftReplDev::leave(), so just add it here.

@JacksonYao287
JacksonYao287 merged commit 28b6921 into eBay:stable/v7.x Jul 20, 2026
21 checks passed
@JacksonYao287
JacksonYao287 deleted the SDSTOR-24056 branch July 20, 2026 02:32
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