Skip to content

Commit 2d7b63c

Browse files
kangpinghuanglichaoyong
authored and
lichaoyong
committed
Add validate for rowset writer (#1104)
1 parent 5c65762 commit 2d7b63c

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

be/src/olap/rowset/alpha_rowset_writer.cpp

+22-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ OLAPStatus AlphaRowsetWriter::flush() {
151151

152152
RowsetSharedPtr AlphaRowsetWriter::build() {
153153
if (_writer_state != WRITER_FLUSHED) {
154-
LOG(WARNING) << "invalid writer state before build:" << _writer_state;
154+
LOG(WARNING) << "invalid writer state before build, state:" << _writer_state;
155155
return nullptr;
156156
}
157157
for (auto& segment_group : _segment_groups) {
@@ -200,6 +200,13 @@ RowsetSharedPtr AlphaRowsetWriter::build() {
200200
_current_rowset_meta->set_num_rows(_num_rows_written);
201201
_current_rowset_meta->set_creation_time(time(nullptr));
202202

203+
// validate rowset arguments before create rowset
204+
bool ret = _validate_rowset();
205+
if (!ret) {
206+
LOG(WARNING) << "valiate rowset arguments failed";
207+
return nullptr;
208+
}
209+
203210
RowsetSharedPtr rowset(new(std::nothrow) AlphaRowset(_rowset_writer_context.tablet_schema,
204211
_rowset_writer_context.rowset_path_prefix,
205212
_rowset_writer_context.data_dir, _current_rowset_meta));
@@ -289,4 +296,18 @@ OLAPStatus AlphaRowsetWriter::_init() {
289296
return OLAP_SUCCESS;
290297
}
291298

299+
bool AlphaRowsetWriter::_validate_rowset() {
300+
if (_is_pending_rowset) {
301+
int64_t partition_id = _current_rowset_meta->partition_id();
302+
if (partition_id <= 0) {
303+
LOG(WARNING) << "invalid partition id:" << partition_id << " for pending rowset."
304+
<< ", rowset_id:" << _current_rowset_meta->rowset_id()
305+
<< ", tablet_id:" << _current_rowset_meta->tablet_id()
306+
<< ", schema_hash:" << _current_rowset_meta->tablet_schema_hash();
307+
return false;
308+
}
309+
}
310+
return true;
311+
}
312+
292313
} // namespace doris

be/src/olap/rowset/alpha_rowset_writer.h

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class AlphaRowsetWriter : public RowsetWriter {
7070

7171
private:
7272
OLAPStatus _init();
73+
74+
// validate rowset build arguments before create rowset to make sure correctness
75+
bool _validate_rowset();
7376

7477
private:
7578
int32_t _segment_group_id;

be/src/olap/schema_change.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ OLAPStatus RowBlockAllocator::allocate(RowBlock** row_block,
498498

499499
void RowBlockAllocator::release(RowBlock* row_block) {
500500
if (row_block == nullptr) {
501-
LOG(FATAL) << "null row block released.";
501+
LOG(INFO) << "null row block released.";
502502
return;
503503
}
504504

@@ -811,7 +811,10 @@ bool SchemaChangeDirectly::process(RowsetReaderSharedPtr rowset_reader, RowsetWr
811811
}
812812

813813
DIRECTLY_PROCESS_ERR:
814-
_row_block_allocator->release(new_row_block);
814+
if (new_row_block) {
815+
_row_block_allocator->release(new_row_block);
816+
new_row_block = nullptr;
817+
}
815818
return result;
816819
}
817820

0 commit comments

Comments
 (0)