Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion be/src/olap/rowset/column_data_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,21 @@ OLAPStatus ColumnDataWriter::finalize() {
_segment_group->set_empty(true);
return OLAP_SUCCESS;
}

// Segment which size reaches OLAP_MAX_COLUMN_SEGMENT_FILE_SIZE
// will be flushed into disk. If the previous segment reach
// the threshold just right, and been flushed into disk.
// The following finalize() when closing ColumnDataWriter
// will generate a non-sense segment.
// In this scenario, undefined behavior will happens.
if (_num_rows == 0 && _row_index == 0) {
// If the two conditions are all satisfied,
// it dedicates that there is no necessity
// to generate segment object and file.
// Return OLAP_SUCCESS is OK.
return OLAP_SUCCESS;
}

OLAPStatus res = _flush_row_block(true);
if (OLAP_SUCCESS != res) {
OLAP_LOG_WARNING("failed to flush data while attaching row cursor.[res=%d]", res);
Expand All @@ -194,7 +209,9 @@ OLAPStatus ColumnDataWriter::finalize() {

res = _finalize_segment();
if (OLAP_SUCCESS != res) {
OLAP_LOG_WARNING("fail to finalize segment.[res=%d]", res);
LOG(WARNING) << "fail to finalize segment. res=" << res
<< ", _row_index=" << _row_index
<< ", _all_num_rows=" << _all_num_rows;
return res;
}

Expand Down
8 changes: 4 additions & 4 deletions be/src/olap/rowset/segment_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,8 @@ OLAPStatus SegmentGroup::add_short_key(const RowCursor& short_key, const uint32_
file_path.c_str(), O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR);
if (res != OLAP_SUCCESS) {
char errmsg[64];
LOG(WARNING) << "can not create file. [file_path='" << file_path
<< "' err='" << strerror_r(errno, errmsg, 64) << "']";
LOG(WARNING) << "can not create file. file_path=" << file_path
<< ", err='" << strerror_r(errno, errmsg, 64);
return res;
}
_new_segment_created = true;
Expand Down Expand Up @@ -629,8 +629,8 @@ OLAPStatus SegmentGroup::finalize_segment(uint32_t data_segment_size, int64_t nu

int file_length = _current_file_handler.tell();
if (file_length == -1) {
OLAP_LOG_WARNING("get file_length error. [err=%m]");

LOG(WARNING) << "get file_length error. err=" << Errno::no()
<< ", _new_segment_created=" << _new_segment_created;
return OLAP_ERR_IO_ERROR;
}

Expand Down