You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2018/11/06 10:30:12 UTC

[GitHub] chenhao7253886 closed pull request #284: Fix BE can't be grayscale upgraded

chenhao7253886 closed pull request #284: Fix BE can't be grayscale upgraded
URL: https://github.com/apache/incubator-doris/pull/284
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/be/src/runtime/lib_cache.cpp b/be/src/runtime/lib_cache.cpp
index e57fcd9d..3db18851 100644
--- a/be/src/runtime/lib_cache.cpp
+++ b/be/src/runtime/lib_cache.cpp
@@ -126,10 +126,11 @@ LibCache::LibCacheEntry::~LibCacheEntry() {
 Status LibCache::get_so_function_ptr(
         const std::string& hdfs_lib_file, const std::string& symbol,
         void** fn_ptr, LibCacheEntry** ent, bool quiet) {
+    const std::string& real_symbol = get_real_symbol(symbol);
     if (hdfs_lib_file.empty()) {
         // Just loading a function ptr in the current process. No need to take any locks.
         DCHECK(_current_process_handle != NULL);
-        RETURN_IF_ERROR(dynamic_lookup(_current_process_handle, symbol.c_str(), fn_ptr));
+        RETURN_IF_ERROR(dynamic_lookup(_current_process_handle, real_symbol.c_str(), fn_ptr));
         return Status::OK;
     }
     LibCacheEntry* entry = NULL;
@@ -145,13 +146,13 @@ Status LibCache::get_so_function_ptr(
     DCHECK(entry != NULL);
     DCHECK_EQ(entry->type, TYPE_SO);
 
-    LibCacheEntry::SymbolMap::iterator it = entry->symbol_cache.find(symbol);
+    LibCacheEntry::SymbolMap::iterator it = entry->symbol_cache.find(real_symbol);
     if (it != entry->symbol_cache.end()) {
         *fn_ptr = it->second;
     } else {
         RETURN_IF_ERROR(
-            dynamic_lookup(entry->shared_object_handle, symbol.c_str(), fn_ptr));
-        entry->symbol_cache[symbol] = *fn_ptr;
+            dynamic_lookup(entry->shared_object_handle, real_symbol.c_str(), fn_ptr));
+        entry->symbol_cache[real_symbol] = *fn_ptr;
     }
 
     DCHECK(*fn_ptr != NULL);
@@ -192,18 +193,19 @@ Status LibCache::get_local_lib_path(
 Status LibCache::check_symbol_exists(
         const std::string& hdfs_lib_file, LibType type,
         const std::string& symbol, bool quiet) {
+    const std::string& real_symbol = get_real_symbol(symbol);
     if (type == TYPE_SO) {
         void* dummy_ptr = NULL;
-        return get_so_function_ptr(hdfs_lib_file, symbol, &dummy_ptr, NULL, quiet);
+        return get_so_function_ptr(hdfs_lib_file, real_symbol, &dummy_ptr, NULL, quiet);
     } else if (type == TYPE_IR) {
         boost::unique_lock<boost::mutex> lock;
         LibCacheEntry* entry = NULL;
         RETURN_IF_ERROR(get_chache_entry(hdfs_lib_file, type, &lock, &entry));
         DCHECK(entry != NULL);
         DCHECK_EQ(entry->type, TYPE_IR);
-        if (entry->symbols.find(symbol) == entry->symbols.end()) {
+        if (entry->symbols.find(real_symbol) == entry->symbols.end()) {
             std::stringstream ss;
-            ss << "Symbol '" << symbol << "' does not exist in module: " << hdfs_lib_file
+            ss << "Symbol '" << real_symbol << "' does not exist in module: " << hdfs_lib_file
                 << " (local path: " << entry->local_path << ")";
             // return quiet ? Status::Expected(ss.str()) : Status(ss.str());
             return Status(ss.str());
diff --git a/be/src/runtime/lib_cache.h b/be/src/runtime/lib_cache.h
index 81d87f41..ff4f7c59 100644
--- a/be/src/runtime/lib_cache.h
+++ b/be/src/runtime/lib_cache.h
@@ -161,6 +161,33 @@ class LibCache {
         const std::string& hdfs_lib_file, LibType type,
         boost::unique_lock<boost::mutex>* entry_lock, LibCacheEntry** entry);
 
+    // map "palo" to "doris" in symbol, only for grayscale upgrading
+    std::string get_real_symbol(const std::string& symbol) {
+        const std::string& str1 = replace_all(symbol, "8palo_udf", "9doris_udf");
+        const std::string& str2 = replace_all(str1, "4palo", "5doris"); 
+        return str2;
+    }
+
+    std::string replace_all(const std::string& str, const std::string& find, const std::string& replace) {
+        std::stringstream ss;
+        std::size_t pos = str.find(find);
+        std::size_t last_pos = pos;
+        while (pos != std::string::npos) {
+            if (pos > 0) {
+                ss << str.substr(0, pos);
+            }
+            ss << replace;
+            last_pos = pos;
+            pos = str.find(find, pos + find.length());
+        }
+        if (last_pos != std::string::npos) {
+            ss << str.substr(last_pos + find.length(), (str.length() - last_pos - 1));
+        } else {
+            return str;
+        }
+        return ss.str();
+    }
+ 
     /// Utility function for generating a filename unique to this process and
     /// 'hdfs_path'. This is to prevent multiple impalad processes or different library files
     /// with the same name from clobbering each other. 'hdfs_path' should be the full path


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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