This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new b9f51f3d7e4 [fix](Outfile) fix bug that it will core dump if the 
_schema fails to build in the open phase #25920
b9f51f3d7e4 is described below

commit b9f51f3d7e44f9cfcb1930d960087acb783d140f
Author: Tiewei Fang <[email protected]>
AuthorDate: Thu Oct 26 09:12:45 2023 +0800

    [fix](Outfile) fix bug that it will core dump if the _schema fails to build 
in the open phase #25920
---
 be/src/vec/runtime/vfile_result_writer.cpp |  2 +-
 be/src/vec/runtime/vorc_writer.cpp         | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/runtime/vfile_result_writer.cpp 
b/be/src/vec/runtime/vfile_result_writer.cpp
index 4a215d7898a..fd599b32cc5 100644
--- a/be/src/vec/runtime/vfile_result_writer.cpp
+++ b/be/src/vec/runtime/vfile_result_writer.cpp
@@ -468,12 +468,12 @@ Status 
VFileResultWriter::_create_new_file_if_exceed_size() {
 
 Status VFileResultWriter::_close_file_writer(bool done) {
     if (_vfile_writer) {
-        RETURN_IF_ERROR(_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());
+        RETURN_IF_ERROR(_vfile_writer->close());
         _vfile_writer.reset(nullptr);
     } else if (_file_writer_impl) {
         RETURN_IF_ERROR(_file_writer_impl->close());
diff --git a/be/src/vec/runtime/vorc_writer.cpp 
b/be/src/vec/runtime/vorc_writer.cpp
index df9615d6689..b9107251970 100644
--- a/be/src/vec/runtime/vorc_writer.cpp
+++ b/be/src/vec/runtime/vorc_writer.cpp
@@ -113,7 +113,13 @@ 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;
 }
 
 Status VOrcWriterWrapper::close() {
@@ -124,6 +130,9 @@ Status VOrcWriterWrapper::close() {
             return Status::IOError(e.what());
         }
     }
+    if (_output_stream) {
+        _output_stream->close();
+    }
     return Status::OK();
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to