Skip to content

Commit

Permalink
[fix](Outfile) fix bug that it will core dump if the _schema fails to…
Browse files Browse the repository at this point in the history
… build in the open phase
  • Loading branch information
derenli committed Aug 22, 2024
1 parent 6c9d792 commit 018dc01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion be/src/vec/runtime/vfile_result_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,12 @@ Status VFileResultWriter::_create_new_file_if_exceed_size() {

Status VFileResultWriter::_close_file_writer(bool done, bool only_close) {
if (_vfile_writer) {
_vfile_writer->close();
// we can not use _current_written_bytes to COUNTER_UPDATE(_written_data_bytes, _current_written_bytes)
// because it will call `write()` function of orc/parquet function in `_vfile_writer->close()`
// and the real written_len will increase
// and _current_written_bytes will less than _vfile_writer->written_len()
COUNTER_UPDATE(_written_data_bytes, _vfile_writer->written_len());
_vfile_writer->close();
_vfile_writer.reset(nullptr);
} else if (_file_writer_impl) {
_file_writer_impl->close();
Expand Down
11 changes: 10 additions & 1 deletion be/src/vec/runtime/vorc_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,22 @@ std::unique_ptr<orc::ColumnVectorBatch> VOrcWriterWrapper::_create_row_batch(siz
}

int64_t VOrcWriterWrapper::written_len() {
return _output_stream->getLength();
// written_len() will be called in VFileResultWriter::_close_file_writer
// but _output_stream may be nullptr
// because the failure built by _schema in open()
if (_output_stream) {
return _output_stream->getLength();
}
return 0;
}

void VOrcWriterWrapper::close() {
if (_writer != nullptr) {
_writer->close();
}
if (_output_stream) {
_output_stream->close();
}
}

#define RETURN_WRONG_TYPE \
Expand Down

0 comments on commit 018dc01

Please sign in to comment.