dataroaring commented on code in PR #51760:
URL: https://github.com/apache/doris/pull/51760#discussion_r2366591198


##########
be/src/runtime/load_stream_writer.cpp:
##########
@@ -100,6 +102,26 @@ Status LoadStreamWriter::init() {
 Status LoadStreamWriter::append_data(uint32_t segid, uint64_t offset, 
butil::IOBuf buf,
                                      FileType file_type) {
     SCOPED_ATTACH_TASK(_resource_ctx);
+
+    // When memtable-on-sink is enabled
+    // Check disk capacity before writing data
+    if (!_is_init) {
+        return Status::Corruption("append_data failed, LoadStreamWriter is not 
inited");
+    }
+
+    auto tablet_res = ExecEnv::get_tablet(_req.tablet_id);
+    if (tablet_res.has_value()) {
+        auto tablet = std::dynamic_pointer_cast<Tablet>(tablet_res.value());
+        if (tablet && tablet->data_dir()) {
+            int64_t incoming_data_size = static_cast<int64_t>(buf.size());
+            if (tablet->data_dir()->reach_capacity_limit(incoming_data_size)) {
+                return Status::Error<ErrorCode::DISK_REACH_CAPACITY_LIMIT>(
+                        "disk {} exceed capacity limit when writing stream 
data, tablet_id={}",
+                        tablet->data_dir()->path_hash(), _req.tablet_id);
+            }
+        }
+    }
+

Review Comment:
   We can record data dir when initing to avoid lookup tablet each time.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to