Skip to content
Permalink
Browse files

Fixed crash problem due to meta not ready (#769)

* Fixed crash problem due to meta not ready

* add comments
  • Loading branch information...
dutor committed Aug 14, 2019
1 parent 1406e57 commit 83dc436f0876a935d14c01287463c248f7bf0c95
@@ -117,7 +117,13 @@ int main(int argc, char *argv[]) {

gServer = std::make_unique<apache::thrift::ThriftServer>();
gServer->getIOThreadPool()->setNumThreads(FLAGS_num_netio_threads);
auto interface = std::make_shared<GraphService>(gServer->getIOThreadPool());

auto interface = std::make_shared<GraphService>();
status = interface->init(gServer->getIOThreadPool());
if (!status.ok()) {
LOG(ERROR) << status;
return EXIT_FAILURE;
}

gServer->setInterface(std::move(interface));
gServer->setAddress(localIP, FLAGS_port);
@@ -32,7 +32,8 @@ Status ExecutionEngine::init(std::shared_ptr<folly::IOThreadPoolExecutor> ioExec
// load data try 3 time
bool loadDataOk = metaClient_->waitForMetadReady(3);
if (!loadDataOk) {
return Status::Error("ExecutionEngine::init loadData by thread error!");
// Resort to retrying in the background
LOG(WARNING) << "Failed to synchronously wait for meta service ready";
}

schemaManager_ = meta::SchemaManager::create();
@@ -14,17 +14,22 @@
namespace nebula {
namespace graph {

GraphService::GraphService(std::shared_ptr<folly::IOThreadPoolExecutor> ioExecutor) {
sessionManager_ = std::make_unique<SessionManager>();
executionEngine_ = std::make_unique<ExecutionEngine>();
executionEngine_->init(std::move(ioExecutor));
authenticator_ = std::make_unique<SimpleAuthenticator>();
GraphService::GraphService() {
}


GraphService::~GraphService() = default;


Status GraphService::init(std::shared_ptr<folly::IOThreadPoolExecutor> ioExecutor) {
sessionManager_ = std::make_unique<SessionManager>();
executionEngine_ = std::make_unique<ExecutionEngine>();
authenticator_ = std::make_unique<SimpleAuthenticator>();

return executionEngine_->init(std::move(ioExecutor));
}


folly::Future<cpp2::AuthResponse> GraphService::future_authenticate(
const std::string& username,
const std::string& password) {
@@ -22,8 +22,11 @@ namespace graph {

class GraphService final : public cpp2::GraphServiceSvIf {
public:
explicit GraphService(std::shared_ptr<folly::IOThreadPoolExecutor> ioExecutor);
GraphService();
~GraphService();

Status MUST_USE_RESULT init(std::shared_ptr<folly::IOThreadPoolExecutor> ioExecutor);

folly::Future<cpp2::AuthResponse> future_authenticate(
const std::string& username,
const std::string& password) override;
@@ -18,7 +18,9 @@ class TestUtils {
static std::unique_ptr<test::ServerContext> mockGraphServer(uint32_t port) {
auto sc = std::make_unique<test::ServerContext>();
auto threadPool = std::make_shared<folly::IOThreadPoolExecutor>(1);
auto interface = std::make_shared<GraphService>(threadPool);
auto interface = std::make_shared<GraphService>();
auto status = interface->init(threadPool);
CHECK(status.ok()) << status;
sc->mockCommon("graph", port, interface);
LOG(INFO) << "Starting the graph Daemon on port " << sc->port_;
return sc;

0 comments on commit 83dc436

Please sign in to comment.
You can’t perform that action at this time.