You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by "acelyc111 (via GitHub)" <gi...@apache.org> on 2024/09/24 10:21:31 UTC

Re: [PR] fix(bulkload): bulkload cause many node coredump [incubator-pegasus]

acelyc111 commented on code in PR #2077:
URL: https://github.com/apache/incubator-pegasus/pull/2077#discussion_r1773068160


##########
src/replica/bulk_load/replica_bulk_loader.cpp:
##########
@@ -585,22 +599,17 @@ void replica_bulk_loader::download_sst_file(const std::string &remote_dir,
         return;
     }
     // download file succeed, update progress
+    download_file_metas.pop_back();
     update_bulk_load_download_progress(f_size, f_meta.name);
     METRIC_VAR_INCREMENT(bulk_load_download_file_successful_count);
     METRIC_VAR_INCREMENT_BY(bulk_load_download_file_bytes, f_size);
 
     // download next file
-    if (file_index + 1 < _metadata.files.size()) {
-        const file_meta &next_f_meta = _metadata.files[file_index + 1];
-        _download_files_task[next_f_meta.name] =
-            tasking::enqueue(LPC_BACKGROUND_BULK_LOAD,
-                             tracker(),
-                             std::bind(&replica_bulk_loader::download_sst_file,
-                                       this,
-                                       remote_dir,
-                                       local_dir,
-                                       file_index + 1,
-                                       fs));
+    if (!download_file_metas.empty()) {
+        _download_files_task[download_file_metas.back().name] = tasking::enqueue(
+            LPC_BACKGROUND_BULK_LOAD, tracker(), [=, file_metas = download_file_metas]() mutable {

Review Comment:
   Why introduce `file_metas`?



##########
src/replica/bulk_load/replica_bulk_loader.cpp:
##########
@@ -519,22 +521,34 @@ void replica_bulk_loader::download_files(const std::string &provider_name,
     }
 
     // download sst files asynchronously
-    if (!_metadata.files.empty()) {
-        const file_meta &f_meta = _metadata.files[0];
-        _download_files_task[f_meta.name] = tasking::enqueue(
-            LPC_BACKGROUND_BULK_LOAD,
-            tracker(),
-            std::bind(&replica_bulk_loader::download_sst_file, this, remote_dir, local_dir, 0, fs));
+    std::vector<::dsn::replication::file_meta> download_file_metas;
+    {
+        zauto_read_lock l(_lock);
+        std::copy(_metadata.files.begin(),
+                  _metadata.files.end(),
+                  std::back_inserter(download_file_metas));

Review Comment:
   Why do it like this, doesn't it equal to `download_file_metas = _metadata.files` ?



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org