fixed allocate memory failed but the error is OB_INVALID_ARGUMENT
This commit is contained in:
@ -547,6 +547,9 @@ int LogEngine::read_group_entry_header(const LSN &lsn, LogGroupEntryHeader &log_
|
||||
ret = OB_NOT_INIT;
|
||||
} else if (false == lsn.is_valid()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
} else if (!read_buf.is_valid()) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
PALF_LOG(WARN, "allocate memory failed", KPC(this), K(lsn));
|
||||
} else if (OB_FAIL(log_storage_.pread_without_block_header(lsn, in_read_size, read_buf, out_read_size))) {
|
||||
PALF_LOG(WARN, "LogStorage pread failed", K(ret));
|
||||
} else if (OB_FAIL(log_group_entry_header.deserialize(read_buf.buf_, in_read_size, pos))) {
|
||||
@ -1150,6 +1153,9 @@ int LogEngine::construct_log_meta_(const LSN &lsn, block_id_t &expected_next_blo
|
||||
LogMetaEntry meta_entry;
|
||||
if (false == lsn.is_valid()) {
|
||||
PALF_LOG(INFO, "there is no meta entry, maybe create palf failed", K(ret), K_(palf_id), K_(is_inited));
|
||||
} else if (!read_buf.is_valid()) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
PALF_LOG(WARN, "allocate memory failed", KPC(this), K(lsn));
|
||||
} else if (OB_FAIL(log_meta_storage_.pread(lsn, buf_len, read_buf, out_read_size))) {
|
||||
PALF_LOG(WARN, "ObLogMetaStorage pread failed", K(ret), K_(palf_id), K_(is_inited));
|
||||
// NB: when lsn is invalid, means there is no data on disk.
|
||||
|
||||
@ -113,7 +113,6 @@ int LogReader::inner_pread_(const int read_io_fd,
|
||||
offset_t backoff = start_offset - aligned_start_offset;
|
||||
int64_t aligned_in_read_size = upper_align(in_read_size + backoff, LOG_DIO_ALIGN_SIZE);
|
||||
int64_t limited_and_aligned_in_read_size = 0;
|
||||
ReadBufGuard read_buf_guard("LogReader", aligned_in_read_size);
|
||||
if (MAX_LOG_BUFFER_SIZE + LOG_DIO_ALIGN_SIZE < aligned_in_read_size) {
|
||||
ret = OB_BUF_NOT_ENOUGH;
|
||||
PALF_LOG(ERROR, "aligned_in_read_size is greater than MAX BUFFER LEN",
|
||||
|
||||
@ -30,6 +30,11 @@ ReadBuf::ReadBuf(char *buf, const int64_t buf_len) : buf_(buf), buf_len_(buf_len
|
||||
{
|
||||
}
|
||||
|
||||
ReadBuf::ReadBuf(const ReadBuf &rhs)
|
||||
{
|
||||
*this = rhs;
|
||||
}
|
||||
|
||||
ReadBuf::~ReadBuf()
|
||||
{
|
||||
reset();
|
||||
@ -51,6 +56,12 @@ bool ReadBuf::operator!=(const ReadBuf &rhs) const
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
ReadBuf &ReadBuf::operator=(const ReadBuf &rhs)
|
||||
{
|
||||
buf_ = rhs.buf_;
|
||||
buf_len_ = rhs.buf_len_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool ReadBuf::is_valid() const
|
||||
{
|
||||
|
||||
@ -22,8 +22,11 @@ struct ReadBuf
|
||||
{
|
||||
ReadBuf();
|
||||
ReadBuf(char *buf, const int64_t buf_len);
|
||||
ReadBuf(const ReadBuf &rhs);
|
||||
bool operator==(const ReadBuf &rhs) const;
|
||||
bool operator!=(const ReadBuf &rhs) const;
|
||||
|
||||
ReadBuf &operator=(const ReadBuf &rhs);
|
||||
~ReadBuf();
|
||||
void reset();
|
||||
bool is_valid() const;
|
||||
|
||||
@ -733,7 +733,10 @@ int LogStorage::read_block_header_(const block_id_t block_id,
|
||||
LSN log_tail = get_readable_log_tail_guarded_by_lock_();
|
||||
block_id_t max_block_id = lsn_2_block(log_tail, logical_block_size_);
|
||||
bool last_block_has_data = (0 == lsn_2_offset(log_tail, logical_block_size_) ? false : true);
|
||||
if (block_id > max_block_id || (block_id == max_block_id && false == last_block_has_data)) {
|
||||
if (!read_buf.is_valid()) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
PALF_LOG(WARN, "allocate memory failed");
|
||||
} else if (block_id > max_block_id || (block_id == max_block_id && false == last_block_has_data)) {
|
||||
ret = OB_ERR_OUT_OF_UPPER_BOUND;
|
||||
PALF_LOG(WARN, "block_id is large than max_block_id", K(ret), K(block_id),
|
||||
K(log_tail), K(max_block_id), K(log_block_header));
|
||||
|
||||
@ -3943,10 +3943,13 @@ int PalfHandleImpl::read_and_append_log_group_entry_before_ts_(
|
||||
};
|
||||
|
||||
last_log_buf = NULL;
|
||||
if (OB_FAIL(iterator.init(start_lsn, get_file_end_lsn, log_engine_.get_log_storage()))) {
|
||||
ReadBufGuard read_buf_guard("Palf", MAX_LOG_BUFFER_SIZE);
|
||||
if (!read_buf_guard.read_buf_.is_valid()) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
PALF_LOG(WARN, "allocate memory failed", KPC(this));
|
||||
} else if (OB_FAIL(iterator.init(start_lsn, get_file_end_lsn, log_engine_.get_log_storage()))) {
|
||||
PALF_LOG(WARN, "iterator init failed", K(ret), KPC(this), K(start_lsn), K(flashback_scn));
|
||||
} else {
|
||||
ReadBufGuard read_buf_guard("Palf", MAX_LOG_BUFFER_SIZE);
|
||||
const int64_t read_buf_len = read_buf_guard.read_buf_.buf_len_;
|
||||
char *&read_buf = read_buf_guard.read_buf_.buf_;
|
||||
const char *buffer = NULL;
|
||||
|
||||
Reference in New Issue
Block a user