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

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 9852ca58ff [bugfix](writer) add _is_closed state to DeltaWriter and 
avoid write/close core after close
9852ca58ff is described below

commit 9852ca58ffeab5c97eac664d020fd96cf0224c85
Author: morningman <[email protected]>
AuthorDate: Thu Feb 9 09:42:39 2023 +0800

    [bugfix](writer) add _is_closed state to DeltaWriter and avoid write/close 
core after close
    
    cherry-pick #16453.
    But different with master, when delta write close twice, it will return OK.
---
 be/src/olap/delta_writer.cpp | 13 +++++++++++++
 be/src/olap/delta_writer.h   |  1 +
 2 files changed, 14 insertions(+)

diff --git a/be/src/olap/delta_writer.cpp b/be/src/olap/delta_writer.cpp
index ca47cde07e..5148d51568 100644
--- a/be/src/olap/delta_writer.cpp
+++ b/be/src/olap/delta_writer.cpp
@@ -218,6 +218,12 @@ Status DeltaWriter::write(const vectorized::Block* block, 
const std::vector<int>
         return _cancel_status;
     }
 
+    if (_is_closed) {
+        LOG(WARNING) << "write block after closed tablet_id=" << _req.tablet_id
+                     << " load_id=" << _req.load_id << " txn_id=" << 
_req.txn_id;
+        return Status::InternalError("already closed");
+    }
+
     _total_received_rows += row_idxs.size();
     _mem_table->insert(block, row_idxs);
 
@@ -331,8 +337,15 @@ Status DeltaWriter::close() {
         return _cancel_status;
     }
 
+    if (_is_closed) {
+        LOG(WARNING) << "close after closed tablet_id=" << _req.tablet_id
+                     << " load_id=" << _req.load_id << " txn_id=" << 
_req.txn_id;
+        return Status::OK();
+    }
+
     auto s = _flush_memtable_async();
     _mem_table.reset();
+    _is_closed = true;
     if (OLAP_UNLIKELY(!s.ok())) {
         return s;
     } else {
diff --git a/be/src/olap/delta_writer.h b/be/src/olap/delta_writer.h
index 522bc98ede..40c0bf55a1 100644
--- a/be/src/olap/delta_writer.h
+++ b/be/src/olap/delta_writer.h
@@ -131,6 +131,7 @@ private:
 
     bool _is_init = false;
     bool _is_cancelled = false;
+    bool _is_closed = false;
     Status _cancel_status;
     WriteRequest _req;
     TabletSharedPtr _tablet;


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

Reply via email to