[scn] rename log_ts to scn

This commit is contained in:
obdev
2022-11-28 02:29:00 +00:00
committed by ob-robot
parent 89c7502360
commit 59db61e110
316 changed files with 219033 additions and 6033 deletions

View File

@ -118,7 +118,7 @@ void gen_default_palf_base_info_(PalfBaseInfo &palf_base_info)
LSN default_prev_lsn(PALF_INITIAL_LSN_VAL);
LogInfo prev_log_info;
prev_log_info.log_id_ = 0;
prev_log_info.log_scn_.set_min();
prev_log_info.scn_.set_min();
prev_log_info.lsn_ = default_prev_lsn;
prev_log_info.log_proposal_id_ = INVALID_PROPOSAL_ID;
prev_log_info.accum_checksum_ = -1;
@ -180,7 +180,7 @@ TEST_F(TestLogSlidingWindow, test_private_func_batch_01)
EXPECT_EQ(OB_SUCCESS, log_sw_.get_last_submit_log_info(lsn, log_id, log_pid));
EXPECT_EQ(OB_SUCCESS, log_sw_.get_max_flushed_log_info(lsn, end_lsn, log_pid));
EXPECT_EQ(OB_SUCCESS, log_sw_.get_last_slide_end_lsn(end_lsn));
SCN log_scn = log_sw_.get_last_slide_log_scn();
SCN scn = log_sw_.get_last_slide_scn();
}
TEST_F(TestLogSlidingWindow, test_to_follower_pending)
@ -197,9 +197,9 @@ TEST_F(TestLogSlidingWindow, test_to_follower_pending)
SCN ref_scn;
ref_scn.convert_for_lsn_allocator(99);
LSN lsn;
SCN log_scn;
SCN scn;
buf_len = 2 * 1024 * 1024;
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
EXPECT_EQ(OB_SUCCESS, log_sw_.to_follower_pending(last_lsn));
}
@ -246,11 +246,11 @@ TEST_F(TestLogSlidingWindow, test_report_log_task_trace)
char *buf = data_buf_;
int64_t buf_len = 2 * 1024 * 1024;
LSN lsn;
SCN log_scn;
SCN scn;
SCN ref_scn;
ref_scn.convert_for_lsn_allocator(99);
buf_len = 2 * 1024 * 1024;
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
EXPECT_EQ(OB_SUCCESS, log_sw_.report_log_task_trace(1));
}
@ -289,33 +289,33 @@ TEST_F(TestLogSlidingWindow, test_submit_log)
SCN ref_scn;
ref_scn.convert_for_lsn_allocator(99);
LSN lsn;
SCN log_scn;
EXPECT_EQ(OB_NOT_INIT, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
SCN scn;
EXPECT_EQ(OB_NOT_INIT, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
EXPECT_EQ(OB_SUCCESS, log_sw_.init(palf_id_, self_, &mock_state_mgr_,
&mock_mm_, &mock_mode_mgr_, &mock_log_engine_, &palf_fs_cb_, alloc_mgr_, base_info));
EXPECT_EQ(OB_INVALID_ARGUMENT, log_sw_.submit_log(NULL, buf_len, ref_scn, lsn, log_scn));
EXPECT_EQ(OB_INVALID_ARGUMENT, log_sw_.submit_log(NULL, buf_len, ref_scn, lsn, scn));
buf_len = 0;
EXPECT_EQ(OB_INVALID_ARGUMENT, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
EXPECT_EQ(OB_INVALID_ARGUMENT, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
buf_len = 64 * 1024 * 1024;
EXPECT_EQ(OB_INVALID_ARGUMENT, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
EXPECT_EQ(OB_INVALID_ARGUMENT, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
buf_len = 1000;
ref_scn.reset();
EXPECT_EQ(OB_INVALID_ARGUMENT, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
EXPECT_EQ(OB_INVALID_ARGUMENT, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
ref_scn.convert_for_lsn_allocator(99);
buf_len = 2 * 1024 * 1024;
for (int i = 0; i < 8; ++i) {
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
}
// append to last group log
buf_len = 1 * 1024 * 1024;
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
buf_len = 2 * 1024 * 1024;
for (int i = 0; i < 11; ++i) {
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
}
PALF_LOG(INFO, "current lsn", K(lsn), K(buf_len));
// 40M已填充39M,无法继续submit 2M log
EXPECT_EQ(OB_EAGAIN, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
EXPECT_EQ(OB_EAGAIN, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
}
TEST_F(TestLogSlidingWindow, test_submit_group_log)
@ -332,15 +332,15 @@ TEST_F(TestLogSlidingWindow, test_submit_group_log)
// generate log entry and group entry
LogEntryHeader log_entry_header;
LogGroupEntryHeader group_header;
SCN max_log_scn;
max_log_scn.convert_for_lsn_allocator(111111);
SCN max_scn;
max_scn.convert_for_lsn_allocator(111111);
int64_t log_id = 1;
LSN committed_end_lsn(0);
int64_t log_proposal_id = 10;
char log_data[2048];
int64_t log_data_len = 2048;
int64_t group_data_checksum = -1;
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_log_scn));
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_scn));
static const int64_t DATA_BUF_LEN = 64 * 1024 * 1024;
int64_t group_header_size = LogGroupEntryHeader::HEADER_SER_SIZE;
int64_t pos = 0;
@ -350,7 +350,7 @@ TEST_F(TestLogSlidingWindow, test_submit_group_log)
LogWriteBuf write_buf;
int64_t log_entry_size = pos + log_data_len;
EXPECT_EQ(OB_SUCCESS, write_buf.push_back(data_buf_, log_entry_size+group_header_size));
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
int64_t accum_checksum = 100;
(void) group_header.update_accumulated_checksum(accum_checksum);
@ -389,22 +389,22 @@ TEST_F(TestLogSlidingWindow, test_receive_log)
int64_t buf_len = 2 * 1024 * 1024;
SCN ref_scn;
ref_scn.convert_for_lsn_allocator(999);
SCN log_scn;
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
SCN scn;
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
// update lsn for next group entry
lsn.val_ = lsn.val_ + LogEntryHeader::HEADER_SER_SIZE + buf_len;
// generate new group entry
LogEntryHeader log_entry_header;
LogGroupEntryHeader group_header;
SCN max_log_scn;
max_log_scn.convert_for_lsn_allocator(111111);
SCN max_scn;
max_scn.convert_for_lsn_allocator(111111);
int64_t log_id = 2;
LSN committed_end_lsn(0);
int64_t log_proposal_id = 20;
char log_data[2048];
log_data_len = 2048;
int64_t group_data_checksum = -1;
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_log_scn));
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_scn));
static const int64_t DATA_BUF_LEN = 64 * 1024 * 1024;
int64_t group_header_size = LogGroupEntryHeader::HEADER_SER_SIZE;
int64_t pos = 0;
@ -413,8 +413,8 @@ TEST_F(TestLogSlidingWindow, test_receive_log)
memcpy(data_buf_ + group_header_size + pos, log_data, log_data_len);
log_entry_size = pos + log_data_len;
// gen 2nd log entry
max_log_scn.convert_for_lsn_allocator(222222);
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_log_scn));
max_scn.convert_for_lsn_allocator(222222);
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_scn));
pos = 0;
log_entry_header.serialize(data_buf_ + group_header_size + log_entry_size, DATA_BUF_LEN, pos);
EXPECT_TRUE(pos > 0);
@ -423,7 +423,7 @@ TEST_F(TestLogSlidingWindow, test_receive_log)
// gen group log
LogWriteBuf write_buf;
EXPECT_EQ(OB_SUCCESS, write_buf.push_back(data_buf_, log_entry_size + group_header_size));
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
int64_t accum_checksum = 100;
(void) group_header.update_accumulated_checksum(accum_checksum);
@ -464,7 +464,7 @@ TEST_F(TestLogSlidingWindow, test_receive_log)
lsn.val_ = lsn.val_ + group_entry_size;
// test log_id exceeds range case
log_id = 999999;
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
// calculate header parity flag
(void) group_header.update_header_checksum();
@ -477,7 +477,7 @@ TEST_F(TestLogSlidingWindow, test_receive_log)
// test cache log case
log_id = 102;
lsn.val_ += 4096 * 1024;
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
// calculate header parity flag
(void) group_header.update_header_checksum();
@ -492,7 +492,7 @@ TEST_F(TestLogSlidingWindow, test_receive_log)
lsn.val_ -= 4096 * 1024;
prev_lsn = old_lsn;
prev_log_proposal_id = log_proposal_id;
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
// inc log_proposal_id to trigger clean cached log_task
log_proposal_id += 1;
@ -520,11 +520,11 @@ TEST_F(TestLogSlidingWindow, test_receive_log)
log_sw_.max_flushed_end_lsn_.val_ += 100;
// 增大log_id,构造prev log空洞
log_id += 100;
uint64_t new_val = max_log_scn.get_val_for_lsn_allocator() - 10;
max_log_scn.convert_for_lsn_allocator(new_val);
uint64_t new_val = max_scn.get_val_for_lsn_allocator() - 10;
max_scn.convert_for_lsn_allocator(new_val);
LogWriteBuf write_buf1;
EXPECT_EQ(OB_SUCCESS, write_buf1.push_back(data_buf_, log_entry_size+group_header_size));
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf1, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf1, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
// calculate header parity flag
(void) group_header.update_header_checksum();
@ -568,12 +568,12 @@ TEST_F(TestLogSlidingWindow, test_after_flush_log)
SCN ref_scn;
ref_scn.convert_for_lsn_allocator(999);
LSN lsn;
SCN log_scn;
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
SCN scn;
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
EXPECT_EQ(OB_INVALID_ARGUMENT, log_sw_.after_flush_log(flush_log_ctx));
flush_log_ctx.log_id_ = PALF_SLIDING_WINDOW_SIZE + 100;
flush_log_ctx.log_scn_ = log_scn;
flush_log_ctx.scn_ = scn;
LSN group_log_lsn;
group_log_lsn.val_ = lsn.val_ - LogGroupEntryHeader::HEADER_SER_SIZE;
flush_log_ctx.lsn_ = group_log_lsn;
@ -618,22 +618,22 @@ TEST_F(TestLogSlidingWindow, test_truncate_log)
SCN ref_scn;
ref_scn.convert_for_lsn_allocator(999);
LSN lsn;
SCN log_scn;
SCN scn;
// submit first log
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
EXPECT_EQ(OB_SUCCESS, log_sw_.try_freeze_last_log());
// generate new group entry
LogEntryHeader log_entry_header;
LogGroupEntryHeader group_header;
SCN max_log_scn;
max_log_scn.convert_for_lsn_allocator(111111);
SCN max_scn;
max_scn.convert_for_lsn_allocator(111111);
int64_t log_id = 2;
LSN committed_end_lsn(0);
int64_t log_proposal_id = 20;
char log_data[2048];
int64_t log_data_len = 2048;
int64_t group_data_checksum = -1;
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_log_scn));
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_scn));
static const int64_t DATA_BUF_LEN = 64 * 1024 * 1024;
int64_t group_header_size = LogGroupEntryHeader::HEADER_SER_SIZE;
int64_t pos = 0;
@ -642,8 +642,8 @@ TEST_F(TestLogSlidingWindow, test_truncate_log)
memcpy(data_buf_ + group_header_size + pos, log_data, log_data_len);
int64_t log_entry_size = pos + log_data_len;
// gen 2nd log entry
max_log_scn.convert_for_lsn_allocator(222222);
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_log_scn));
max_scn.convert_for_lsn_allocator(222222);
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_scn));
pos = 0;
log_entry_header.serialize(data_buf_ + group_header_size + log_entry_size, DATA_BUF_LEN, pos);
EXPECT_TRUE(pos > 0);
@ -652,7 +652,7 @@ TEST_F(TestLogSlidingWindow, test_truncate_log)
// gen group log
LogWriteBuf write_buf;
EXPECT_EQ(OB_SUCCESS, write_buf.push_back(data_buf_, log_entry_size+group_header_size));
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
int64_t accum_checksum = 100;
(void) group_header.update_accumulated_checksum(accum_checksum);
@ -739,8 +739,8 @@ TEST_F(TestLogSlidingWindow, test_ack_log)
SCN ref_scn;
ref_scn.convert_for_lsn_allocator(999);
LSN lsn;
SCN log_scn;
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
SCN scn;
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
LSN end_lsn = lsn + LogEntryHeader::HEADER_SER_SIZE + buf_len;
ObAddr server;
server.set_ip_addr("127.0.0.1", 12346);
@ -756,7 +756,7 @@ TEST_F(TestLogSlidingWindow, test_ack_log)
FlushLogCbCtx flush_log_ctx;
flush_log_ctx.log_id_ = 1;
flush_log_ctx.log_scn_ = log_scn;
flush_log_ctx.scn_ = scn;
LSN group_log_lsn;
group_log_lsn.val_ = lsn.val_ - LogGroupEntryHeader::HEADER_SER_SIZE;
flush_log_ctx.lsn_ = group_log_lsn;
@ -784,20 +784,20 @@ TEST_F(TestLogSlidingWindow, test_truncate_for_rebuild)
SCN ref_scn;
ref_scn.convert_for_lsn_allocator(999);
LSN lsn;
SCN log_scn;
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, log_scn));
SCN scn;
EXPECT_EQ(OB_SUCCESS, log_sw_.submit_log(buf, buf_len, ref_scn, lsn, scn));
// generate new group entry
LogEntryHeader log_entry_header;
LogGroupEntryHeader group_header;
SCN max_log_scn;
max_log_scn.convert_for_lsn_allocator(111111);
SCN max_scn;
max_scn.convert_for_lsn_allocator(111111);
int64_t log_id = 2;
LSN committed_end_lsn(0);
int64_t log_proposal_id = 20;
char log_data[2048];
int64_t log_data_len = 2048;
int64_t group_data_checksum = -1;
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_log_scn));
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_scn));
static const int64_t DATA_BUF_LEN = 64 * 1024 * 1024;
int64_t group_header_size = LogGroupEntryHeader::HEADER_SER_SIZE;
int64_t pos = 0;
@ -806,8 +806,8 @@ TEST_F(TestLogSlidingWindow, test_truncate_for_rebuild)
memcpy(data_buf_ + group_header_size + pos, log_data, log_data_len);
int64_t log_entry_size = pos + log_data_len;
// gen 2nd log entry
max_log_scn.convert_for_lsn_allocator(222222);
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_log_scn));
max_scn.convert_for_lsn_allocator(222222);
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_scn));
pos = 0;
log_entry_header.serialize(data_buf_ + group_header_size + log_entry_size, DATA_BUF_LEN, pos);
EXPECT_TRUE(pos > 0);
@ -816,7 +816,7 @@ TEST_F(TestLogSlidingWindow, test_truncate_for_rebuild)
// gen group log
LogWriteBuf write_buf;
EXPECT_EQ(OB_SUCCESS, write_buf.push_back(data_buf_, log_entry_size+group_header_size));
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
int64_t accum_checksum = 100;
(void) group_header.update_accumulated_checksum(accum_checksum);
@ -842,11 +842,11 @@ TEST_F(TestLogSlidingWindow, test_truncate_for_rebuild)
EXPECT_EQ(OB_SUCCESS, log_sw_.receive_log(src_server, push_log_type, prev_lsn, prev_log_proposal_id, lsn, data_buf_, group_entry_size, false, truncate_log_info));
// gen next group log
log_id = 10;
uint64_t new_val = max_log_scn.get_val_for_lsn_allocator() + 100;
max_log_scn.convert_for_lsn_allocator(new_val);
uint64_t new_val = max_scn.get_val_for_lsn_allocator() + 100;
max_scn.convert_for_lsn_allocator(new_val);
LogWriteBuf write_buf1;
EXPECT_EQ(OB_SUCCESS, write_buf1.push_back(data_buf_, log_entry_size+group_header_size));
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf1, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf1, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
accum_checksum += 100;
(void) group_header.update_accumulated_checksum(accum_checksum);
@ -868,8 +868,8 @@ TEST_F(TestLogSlidingWindow, test_truncate_for_rebuild)
EXPECT_EQ(OB_SUCCESS, log_sw_.truncate_for_rebuild(new_base_info));
new_base_info.prev_log_info_.log_id_ = 6;
new_val = max_log_scn.get_val_for_lsn_allocator() - 50;
new_base_info.prev_log_info_.log_scn_.convert_for_lsn_allocator(new_val);
new_val = max_scn.get_val_for_lsn_allocator() - 50;
new_base_info.prev_log_info_.scn_.convert_for_lsn_allocator(new_val);
new_base_info.prev_log_info_.log_proposal_id_ = curr_proposal_id;
new_base_info.prev_log_info_.lsn_ = lsn - 200;
new_base_info.curr_lsn_ = lsn - 100;
@ -893,15 +893,15 @@ TEST_F(TestLogSlidingWindow, test_append_disk_log)
LogEntry log_entry;
LogEntryHeader log_entry_header;
LogGroupEntryHeader group_header;
SCN max_log_scn;
max_log_scn.convert_for_lsn_allocator(111111);
SCN max_scn;
max_scn.convert_for_lsn_allocator(111111);
int64_t log_id = 1;
LSN committed_end_lsn(0);
int64_t log_proposal_id = 20;
char log_data[2048];
int64_t log_data_len = 2048;
int64_t group_data_checksum = -1;
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_log_scn));
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_scn));
static const int64_t DATA_BUF_LEN = 64 * 1024 * 1024;
int64_t group_header_size = LogGroupEntryHeader::HEADER_SER_SIZE;
int64_t pos = 0;
@ -923,8 +923,8 @@ TEST_F(TestLogSlidingWindow, test_append_disk_log)
int64_t log_entry_size = pos + log_data_len;
// gen 2nd log entry
max_log_scn.convert_for_lsn_allocator(222222);
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_log_scn));
max_scn.convert_for_lsn_allocator(222222);
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_scn));
pos = 0;
log_entry_header.serialize(data_buf_ + group_header_size + log_entry_size, DATA_BUF_LEN, pos);
EXPECT_TRUE(pos > 0);
@ -932,7 +932,7 @@ TEST_F(TestLogSlidingWindow, test_append_disk_log)
log_entry_size += (pos + log_data_len);
// gen group log
LogWriteBuf write_buf;
EXPECT_EQ(OB_INVALID_ARGUMENT, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_INVALID_ARGUMENT, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
const int64_t total_group_log_size = group_header_size + log_entry_size;
const int64_t first_part_len = total_group_log_size / 2;
@ -941,7 +941,7 @@ TEST_F(TestLogSlidingWindow, test_append_disk_log)
// continous buf
EXPECT_EQ(OB_SUCCESS, write_buf.push_back(data_buf_, first_part_len));
EXPECT_EQ(OB_SUCCESS, write_buf.push_back(data_buf_ + first_part_len, second_part_len));
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
// non-continous buf
group_header.reset();
@ -951,7 +951,7 @@ TEST_F(TestLogSlidingWindow, test_append_disk_log)
memcpy(second_buf, data_buf_ + first_part_len, second_part_len);
EXPECT_EQ(OB_SUCCESS, write_buf.push_back(data_buf_, first_part_len));
EXPECT_EQ(OB_SUCCESS, write_buf.push_back(second_buf, second_part_len));
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
int64_t accum_checksum = 100;
(void) group_header.update_accumulated_checksum(accum_checksum);
@ -973,13 +973,13 @@ TEST_F(TestLogSlidingWindow, test_append_disk_log)
EXPECT_EQ(OB_SUCCESS, log_sw_.append_disk_log(lsn, group_entry));
// gen new group entry
log_id++;
uint64_t new_val = max_log_scn.get_val_for_lsn_allocator() + 100;
max_log_scn.convert_for_lsn_allocator(new_val);
uint64_t new_val = max_scn.get_val_for_lsn_allocator() + 100;
max_scn.convert_for_lsn_allocator(new_val);
lsn.val_ += group_entry_size;
// gen group log
LogWriteBuf write_buf1;
EXPECT_EQ(OB_SUCCESS, write_buf1.push_back(data_buf_, log_entry_size+group_header_size));
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
accum_checksum += 100;
(void) group_header.update_accumulated_checksum(accum_checksum);
@ -1000,11 +1000,11 @@ TEST_F(TestLogSlidingWindow, test_group_entry_truncate)
LSN lsn(0);
LogGroupEntry group_entry;
LogGroupEntryHeader group_header;
SCN truncate_log_scn;
truncate_log_scn.convert_for_lsn_allocator(111113);
SCN truncate_scn;
truncate_scn.convert_for_lsn_allocator(111113);
int64_t pre_accum_checksum = 123456;
EXPECT_EQ(OB_INVALID_ARGUMENT, group_header.truncate(NULL, 1024, truncate_log_scn, pre_accum_checksum));
EXPECT_EQ(OB_INVALID_ARGUMENT, group_header.truncate(data_buf_, 0, truncate_log_scn, pre_accum_checksum));
EXPECT_EQ(OB_INVALID_ARGUMENT, group_header.truncate(NULL, 1024, truncate_scn, pre_accum_checksum));
EXPECT_EQ(OB_INVALID_ARGUMENT, group_header.truncate(data_buf_, 0, truncate_scn, pre_accum_checksum));
PalfBaseInfo base_info;
gen_default_palf_base_info_(base_info);
EXPECT_EQ(OB_SUCCESS, log_sw_.init(palf_id_, self_, &mock_state_mgr_,
@ -1014,15 +1014,15 @@ TEST_F(TestLogSlidingWindow, test_group_entry_truncate)
// generate new group entry
LogEntry log_entry;
LogEntryHeader log_entry_header;
SCN max_log_scn;
max_log_scn.convert_for_lsn_allocator(111111);
SCN max_scn;
max_scn.convert_for_lsn_allocator(111111);
int64_t log_id = 1;
LSN committed_end_lsn(0);
int64_t log_proposal_id = 20;
char log_data[2048];
int64_t log_data_len = 2048;
int64_t group_data_checksum = -1;
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_log_scn));
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_scn));
static const int64_t DATA_BUF_LEN = 64 * 1024 * 1024;
int64_t group_header_size = LogGroupEntryHeader::HEADER_SER_SIZE;
int64_t pos = 0;
@ -1032,8 +1032,8 @@ TEST_F(TestLogSlidingWindow, test_group_entry_truncate)
int64_t dser_pos = 0;
int64_t log_entry_size = pos + log_data_len;
// gen 2nd log entry
max_log_scn.convert_for_lsn_allocator(222222);
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_log_scn));
max_scn.convert_for_lsn_allocator(222222);
EXPECT_EQ(OB_SUCCESS, log_entry_header.generate_header(log_data, log_data_len, max_scn));
pos = 0;
log_entry_header.serialize(data_buf_ + group_header_size + log_entry_size, DATA_BUF_LEN, pos);
EXPECT_TRUE(pos > 0);
@ -1041,7 +1041,7 @@ TEST_F(TestLogSlidingWindow, test_group_entry_truncate)
log_entry_size += (pos + log_data_len);
// gen group log
LogWriteBuf write_buf;
EXPECT_EQ(OB_INVALID_ARGUMENT, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_INVALID_ARGUMENT, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
const int64_t total_group_log_size = group_header_size + log_entry_size;
const int64_t first_part_len = total_group_log_size / 2;
@ -1050,7 +1050,7 @@ TEST_F(TestLogSlidingWindow, test_group_entry_truncate)
// continous buf
EXPECT_EQ(OB_SUCCESS, write_buf.push_back(data_buf_, first_part_len));
EXPECT_EQ(OB_SUCCESS, write_buf.push_back(data_buf_ + first_part_len, second_part_len));
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_log_scn, log_id,
EXPECT_EQ(OB_SUCCESS, group_header.generate(false, false, write_buf, log_entry_size, max_scn, log_id,
committed_end_lsn, log_proposal_id, group_data_checksum));
int64_t accum_checksum = 100;
(void) group_header.update_accumulated_checksum(accum_checksum);
@ -1065,7 +1065,7 @@ TEST_F(TestLogSlidingWindow, test_group_entry_truncate)
EXPECT_TRUE(group_header.check_integrity(data_buf_ + group_header_size, group_entry_size - group_header_size));
EXPECT_EQ(OB_SUCCESS, group_entry.generate(group_header, data_buf_ + group_header_size));
EXPECT_TRUE(group_entry.check_integrity());
EXPECT_EQ(OB_SUCCESS, group_header.truncate(data_buf_ + group_header_size, log_entry_size, truncate_log_scn, pre_accum_checksum));
EXPECT_EQ(OB_SUCCESS, group_header.truncate(data_buf_ + group_header_size, log_entry_size, truncate_scn, pre_accum_checksum));
}
} // END of unittest