Reduce number of errors in production log
Summary: Currently, when starting Memgraph with the production package (DEB/RPM), Memgraph always outputs an error for not being able to replace an existing query module (`example.so` with `example.c`). This diff introduces a precheck so that the error message is correct - so that Memgraph doesn't try to replace an `.so` file with a `.c` file before verifying that the `.c` file is a valid query module (which it obviously isn't). Also, I have moved the source of the example into a subdirectory so that it isn't even considered while loading modules. Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2724
This commit is contained in:
parent
d63eb191f9
commit
5632852890
@ -25,7 +25,7 @@ install(PROGRAMS $<TARGET_FILE:example>
|
|||||||
DESTINATION lib/memgraph/query_modules
|
DESTINATION lib/memgraph/query_modules
|
||||||
RENAME example.so)
|
RENAME example.so)
|
||||||
# Also install the source of the example, so user can read it.
|
# Also install the source of the example, so user can read it.
|
||||||
install(FILES example.c DESTINATION lib/memgraph/query_modules)
|
install(FILES example.c DESTINATION lib/memgraph/query_modules/src)
|
||||||
|
|
||||||
# Install the Python example
|
# Install the Python example
|
||||||
install(FILES example.py DESTINATION lib/memgraph/query_modules RENAME py_example.py)
|
install(FILES example.py DESTINATION lib/memgraph/query_modules RENAME py_example.py)
|
||||||
|
@ -403,6 +403,10 @@ ModuleRegistry::ModuleRegistry() {
|
|||||||
bool ModuleRegistry::LoadModuleLibrary(std::filesystem::path path) {
|
bool ModuleRegistry::LoadModuleLibrary(std::filesystem::path path) {
|
||||||
std::unique_lock<utils::RWLock> guard(lock_);
|
std::unique_lock<utils::RWLock> guard(lock_);
|
||||||
std::string module_name(path.stem());
|
std::string module_name(path.stem());
|
||||||
|
if (path.extension() != ".so" && path.extension() != ".py") {
|
||||||
|
LOG(WARNING) << "Unknown query module file " << path;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (modules_.find(module_name) != modules_.end()) {
|
if (modules_.find(module_name) != modules_.end()) {
|
||||||
LOG(ERROR) << "Unable to overwrite an already loaded module " << path;
|
LOG(ERROR) << "Unable to overwrite an already loaded module " << path;
|
||||||
return false;
|
return false;
|
||||||
@ -418,7 +422,8 @@ bool ModuleRegistry::LoadModuleLibrary(std::filesystem::path path) {
|
|||||||
if (!loaded) return false;
|
if (!loaded) return false;
|
||||||
modules_[module_name] = std::move(module);
|
modules_[module_name] = std::move(module);
|
||||||
} else {
|
} else {
|
||||||
LOG(ERROR) << "Unknown query module file " << path;
|
LOG(FATAL) << "Unknown query module extension '" << path.extension()
|
||||||
|
<< "' from file " << path;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user