[Vectorized](udaf) fix java-udaf couldn't get jar core dump (#14393)

fix java-udaf couldn't get jar core dump
This commit is contained in:
zhangstar333
2022-11-22 20:49:02 +08:00
committed by GitHub
parent 45aeb1d40d
commit b04ec41c1d
7 changed files with 59 additions and 9 deletions

View File

@ -22,6 +22,7 @@
#include <vector>
#include "common/config.h"
#include "common/status.h"
#include "env/env.h"
#include "gutil/strings/split.h"
#include "http/http_client.h"
@ -432,4 +433,41 @@ Status UserFunctionCache::get_jarpath(int64_t fid, const std::string& url,
return Status::OK();
}
Status UserFunctionCache::check_jar(int64_t fid, const std::string& url,
const std::string& checksum) {
UserFunctionCacheEntry* entry = nullptr;
Status st = Status::OK();
{
std::lock_guard<std::mutex> l(_cache_lock);
auto it = _entry_map.find(fid);
if (it != _entry_map.end()) {
entry = it->second;
} else {
entry = new UserFunctionCacheEntry(
fid, checksum, _make_lib_file(fid, checksum, LibType::JAR), LibType::JAR);
entry->ref();
_entry_map.emplace(fid, entry);
}
entry->ref();
}
if (entry->is_loaded.load()) {
return st;
}
std::unique_lock<std::mutex> l(entry->load_lock);
if (!entry->is_downloaded) {
st = _download_lib(url, entry);
}
if (!st.ok()) {
// if we load a cache entry failed, I think we should delete this entry cache
// even if this cache was valid before.
_destroy_cache_entry(entry);
return Status::InternalError(
"Java UDAF has error, maybe you should check the path about java impl jar, because "
"{}",
st.get_error_msg());
}
return Status::OK();
}
} // namespace doris