gavinchou commented on code in PR #33680:
URL: https://github.com/apache/doris/pull/33680#discussion_r1567299080


##########
be/src/io/fs/hdfs_file_writer.cpp:
##########
@@ -53,23 +58,29 @@ Status HdfsFileWriter::close() {
         return Status::OK();
     }
     _closed = true;
-    int result = hdfsFlush(_hdfs_handler->hdfs_fs, _hdfs_file);
-    if (result == -1) {
-        std::stringstream ss;
-        ss << "failed to flush hdfs file. "
-           << "fs_name:" << _fs_name << " path:" << _path << ", err: " << 
hdfs_error();
-        LOG(WARNING) << ss.str();
-        return Status::InternalError(ss.str());
+
+    if (_sync_file_data) {
+        int ret = hdfsHSync(_hdfs_handler->hdfs_fs, _hdfs_file);
+        if (ret != 0) {
+            return Status::InternalError("failed to sync hdfs file. fs_name={} 
path={} : {}",
+                                         _fs_name, _path.native(), 
hdfs_error());

Review Comment:
   also print  ret



##########
be/src/io/fs/hdfs_file_writer.cpp:
##########
@@ -53,23 +58,29 @@ Status HdfsFileWriter::close() {
         return Status::OK();
     }
     _closed = true;
-    int result = hdfsFlush(_hdfs_handler->hdfs_fs, _hdfs_file);
-    if (result == -1) {
-        std::stringstream ss;
-        ss << "failed to flush hdfs file. "
-           << "fs_name:" << _fs_name << " path:" << _path << ", err: " << 
hdfs_error();
-        LOG(WARNING) << ss.str();
-        return Status::InternalError(ss.str());
+
+    if (_sync_file_data) {
+        int ret = hdfsHSync(_hdfs_handler->hdfs_fs, _hdfs_file);
+        if (ret != 0) {
+            return Status::InternalError("failed to sync hdfs file. fs_name={} 
path={} : {}",
+                                         _fs_name, _path.native(), 
hdfs_error());
+        }
+    } else {
+        int ret = hdfsFlush(_hdfs_handler->hdfs_fs, _hdfs_file);
+        if (ret != 0) {
+            return Status::InternalError("failed to flush hdfs file. 
fs_name={} path={} : {}",

Review Comment:
   ditto
   



##########
be/src/io/fs/hdfs_file_writer.cpp:
##########
@@ -53,23 +58,29 @@ Status HdfsFileWriter::close() {
         return Status::OK();
     }
     _closed = true;
-    int result = hdfsFlush(_hdfs_handler->hdfs_fs, _hdfs_file);
-    if (result == -1) {
-        std::stringstream ss;
-        ss << "failed to flush hdfs file. "
-           << "fs_name:" << _fs_name << " path:" << _path << ", err: " << 
hdfs_error();
-        LOG(WARNING) << ss.str();
-        return Status::InternalError(ss.str());
+
+    if (_sync_file_data) {
+        int ret = hdfsHSync(_hdfs_handler->hdfs_fs, _hdfs_file);
+        if (ret != 0) {
+            return Status::InternalError("failed to sync hdfs file. fs_name={} 
path={} : {}",
+                                         _fs_name, _path.native(), 
hdfs_error());
+        }
+    } else {
+        int ret = hdfsFlush(_hdfs_handler->hdfs_fs, _hdfs_file);
+        if (ret != 0) {
+            return Status::InternalError("failed to flush hdfs file. 
fs_name={} path={} : {}",
+                                         _fs_name, _path.native(), 
hdfs_error());
+        }
     }
 
-    result = hdfsCloseFile(_hdfs_handler->hdfs_fs, _hdfs_file);
+    int ret = hdfsCloseFile(_hdfs_handler->hdfs_fs, _hdfs_file);
     _hdfs_file = nullptr;
-    if (result != 0) {
-        std::string err_msg = hdfs_error();
+    if (ret != 0) {
         return Status::InternalError(
                 "Write hdfs file failed. (BE: {}) namenode:{}, path:{}, err: 
{}",
-                BackendOptions::get_localhost(), _fs_name, _path.string(), 
err_msg);
+                BackendOptions::get_localhost(), _fs_name, _path.native(), 
hdfs_error());

Review Comment:
   ditto
   



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to