gavinchou commented on code in PR #40943:
URL: https://github.com/apache/doris/pull/40943#discussion_r1765162822
##########
be/src/olap/rowset/segment_v2/segment.cpp:
##########
@@ -294,6 +295,41 @@ Status Segment::new_iterator(SchemaSPtr schema, const
StorageReadOptions& read_o
return iter->get()->init(read_options);
}
+Status Segment::_write_error_file(size_t file_size, size_t bytes_read,
io::IOContext& io_ctx) {
+ if (!doris::config::is_cloud_mode()) {
+ return Status::OK();
+ }
+
+ std::string error_file;
+ error_file.resize(file_size);
+ RETURN_IF_ERROR(
+ _file_reader->read_at(0, Slice(error_file.data(), file_size),
&bytes_read, &io_ctx));
+ int64_t cur_time = UnixMillis();
+ std::stringstream ss;
+ ss << std::this_thread::get_id();
+
+ std::string dir_path =
io::FileCacheFactory::instance()->get_base_paths()[0] + "/error_file/";
+ Status create_st =
io::global_local_filesystem()->create_directory(dir_path, true);
+ if (!create_st.ok() && !create_st.is<ErrorCode::ALREADY_EXIST>()) {
+ LOG(WARNING) << "failed to create error file dir: " <<
create_st.to_string();
+ return create_st;
+ }
+ size_t dir_size = 0;
+ RETURN_IF_ERROR(io::global_local_filesystem()->directory_size(dir_path,
&dir_size));
+ if (dir_size > config::file_cache_error_log_limit_bytes) {
+ LOG(WARNING) << "error file dir size is too large: " << dir_size;
+ return Status::OK();
+ }
+
+ std::string file_path = dir_path + std::to_string(cur_time) + "_" +
ss.str();
Review Comment:
use this pattern to get rid of duplicated dumps (check existence before read
and write)
```
std::string file_path = dir_path + this->_rowset_id.to_string() + "_" +
segment_id + "_" + offset + "_" + size;
```
--
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]