Skip to content

Commit

Permalink
Fix test of last chunk when recovery of logstore.
Browse files Browse the repository at this point in the history
  • Loading branch information
sanebay committed May 3, 2024
1 parent 42c5774 commit 6023727
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "6.4.2"
version = "6.4.3"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down
28 changes: 14 additions & 14 deletions src/lib/logstore/log_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ sisl::byte_view log_stream_reader::next_group(off_t* out_dev_offset) {
// and it can happen that log group headers couldnt match. In that case check we dont error
// if its the last chunk or not with is_offset_at_last_chunk else raise assert.
// compare it with prev crc
auto dev_offset = m_vdev_jd->dev_offset(m_cur_read_bytes);
if (m_prev_crc != 0 && m_prev_crc != header->prev_grp_crc) {
// we reached at the end
LOGINFOMOD(logstore,
"we have reached the end. crc doesn't match offset {} prev crc {} header prev crc {} log_dev={}",
m_vdev_jd->dev_offset(m_cur_read_bytes), header->prev_grp_crc, m_prev_crc, m_vdev_jd->logdev_id());
*out_dev_offset = m_vdev_jd->dev_offset(m_cur_read_bytes);
if (!m_vdev_jd->is_offset_at_last_chunk(m_cur_read_bytes)) {
"we have reached the end. crc doesn't match offset 0x{} prev crc {} header prev crc {} log_dev={}",
to_hex(dev_offset), header->prev_grp_crc, m_prev_crc, m_vdev_jd->logdev_id());
*out_dev_offset = dev_offset;
if (!m_vdev_jd->is_offset_at_last_chunk(dev_offset)) {
HS_REL_ASSERT(0, "data is corrupted {}", m_vdev_jd->logdev_id());
}
// move it by dma boundary if header is not valid
Expand All @@ -95,8 +96,8 @@ sisl::byte_view log_stream_reader::next_group(off_t* out_dev_offset) {
LOGTRACEMOD(logstore,
"Logstream read log group of size={} nrecords={} journal_dev_offset {} cur_read_bytes {} buf size "
"remaining {} log_dev={}",
header->total_size(), header->nrecords(), m_vdev_jd->dev_offset(m_cur_read_bytes), m_cur_read_bytes,
m_cur_log_buf.size(), m_vdev_jd->logdev_id());
header->total_size(), header->nrecords(), to_hex(dev_offset), m_cur_read_bytes, m_cur_log_buf.size(),
m_vdev_jd->logdev_id());

// At this point data seems to be valid. Lets see if a data is written completely by comparing the footer
const auto* footer = r_cast< log_group_footer* >((uint64_t)m_cur_log_buf.bytes() + header->footer_offset);
Expand All @@ -105,13 +106,13 @@ sisl::byte_view log_stream_reader::next_group(off_t* out_dev_offset) {
"last write is not completely written. footer magic {} footer start_log_idx {} header log indx {} "
"log_dev={}",
footer->magic, footer->start_log_idx, header->start_log_idx, m_vdev_jd->logdev_id());
*out_dev_offset = m_vdev_jd->dev_offset(m_cur_read_bytes);
if (!m_vdev_jd->is_offset_at_last_chunk(dev_offset)) {
HS_REL_ASSERT(0, "data is corrupted {}", m_vdev_jd->logdev_id());
}
*out_dev_offset = dev_offset;
// move it by dma boundary if header is not valid
m_prev_crc = 0;
m_cur_read_bytes += m_read_size_multiple;
if (!m_vdev_jd->is_offset_at_last_chunk(m_cur_read_bytes)) {
HS_REL_ASSERT(0, "data is corrupted {}", m_vdev_jd->logdev_id());
}
return ret_buf;
}

Expand All @@ -123,10 +124,9 @@ sisl::byte_view log_stream_reader::next_group(off_t* out_dev_offset) {
(header->total_size() - sizeof(log_group_header)));
if (cur_crc != header->cur_grp_crc) {
/* This is a valid entry so crc should match */
LOGERRORMOD(logstore, "crc doesn't match {} log_dev={}", m_vdev_jd->dev_offset(m_cur_read_bytes),
m_vdev_jd->logdev_id());
LOGERRORMOD(logstore, "crc doesn't match {} log_dev={}", dev_offset, m_vdev_jd->logdev_id());
HS_REL_ASSERT(0, "data is corrupted {}", m_vdev_jd->logdev_id());
*out_dev_offset = m_vdev_jd->dev_offset(m_cur_read_bytes);
*out_dev_offset = dev_offset;

// move it by dma boundary if header is not valid
m_prev_crc = 0;
Expand All @@ -138,7 +138,7 @@ sisl::byte_view log_stream_reader::next_group(off_t* out_dev_offset) {
m_prev_crc = cur_crc;

ret_buf = m_cur_log_buf;
*out_dev_offset = m_vdev_jd->dev_offset(m_cur_read_bytes);
*out_dev_offset = dev_offset;
m_cur_read_bytes += header->total_size();
m_cur_log_buf.move_forward(header->total_size());

Expand Down

0 comments on commit 6023727

Please sign in to comment.