diff --git a/src/clients/meta/MetaClient.cpp b/src/clients/meta/MetaClient.cpp index 1cec0afe970..9c179352dc7 100644 --- a/src/clients/meta/MetaClient.cpp +++ b/src/clients/meta/MetaClient.cpp @@ -2565,7 +2565,8 @@ folly::Future> MetaClient::heartbeat() { if (FileBasedClusterIdMan::persistInFile(resp.get_cluster_id(), FLAGS_cluster_id_path)) { options_.clusterId_.store(resp.get_cluster_id()); } else { - LOG(FATAL) << "Can't persist the clusterId in file " << FLAGS_cluster_id_path; + LOG(DFATAL) << "Can't persist the clusterId in file " << FLAGS_cluster_id_path; + return false; } } heartbeatTime_ = time::WallClock::fastNowInMilliSec(); diff --git a/src/codec/RowReaderV1.cpp b/src/codec/RowReaderV1.cpp index b56b831a228..6a73458539c 100644 --- a/src/codec/RowReaderV1.cpp +++ b/src/codec/RowReaderV1.cpp @@ -143,7 +143,8 @@ int64_t RowReaderV1::skipToNext(int64_t index, int64_t offset) const noexcept { } default: { // TODO - LOG(FATAL) << "Unimplemented"; + LOG(DFATAL) << "Unimplemented"; + return -1; } } diff --git a/src/codec/RowReaderV2.cpp b/src/codec/RowReaderV2.cpp index 91db3933fec..fe23bd2e9a1 100644 --- a/src/codec/RowReaderV2.cpp +++ b/src/codec/RowReaderV2.cpp @@ -208,7 +208,9 @@ Value RowReaderV2::getValueByIndex(const int64_t index) const noexcept { case PropertyType::UNKNOWN: break; } - LOG(FATAL) << "Should not reach here"; + LOG(DFATAL) << "Should not reach here, illegal property type: " + << static_cast(field->type()); + return Value::kNullBadType; } int64_t RowReaderV2::getTimestamp() const noexcept { diff --git a/src/codec/RowReaderWrapper.cpp b/src/codec/RowReaderWrapper.cpp index 87b8beeb22a..77abcf81323 100644 --- a/src/codec/RowReaderWrapper.cpp +++ b/src/codec/RowReaderWrapper.cpp @@ -89,7 +89,9 @@ RowReaderWrapper::RowReaderWrapper(const meta::SchemaProviderIf* schema, readerV2_.resetImpl(schema, row); currReader_ = &readerV2_; } else { - LOG(FATAL) << "Should not reach here"; + LOG(DFATAL) << "Should not reach here"; + readerV2_.resetImpl(schema, row); + currReader_ = &readerV2_; } } diff --git a/src/codec/RowWriterV2.cpp b/src/codec/RowWriterV2.cpp index 9e0818521e5..6fce45b4506 100644 --- a/src/codec/RowWriterV2.cpp +++ b/src/codec/RowWriterV2.cpp @@ -62,7 +62,9 @@ RowWriterV2::RowWriterV2(const meta::SchemaProviderIf* schema) header = 0x0F; // 0x08 | 0x07, seven bytes for the schema version headerLen_ = 8; } else { - LOG(FATAL) << "Schema version too big"; + LOG(DFATAL) << "Schema version too big"; + header = 0x0F; // 0x08 | 0x07, seven bytes for the schema version + headerLen_ = 8; } buf_.append(&header, 1); buf_.append(reinterpret_cast(&ver), buf_[0] & 0x07); @@ -136,7 +138,9 @@ RowWriterV2::RowWriterV2(RowReader& reader) : RowWriterV2(reader.getSchema()) { set(i, v.moveDuration()); break; default: - LOG(FATAL) << "Invalid data: " << v << ", type: " << v.typeName(); + LOG(DFATAL) << "Invalid data: " << v << ", type: " << v.typeName(); + isSet_[i] = false; + continue; } isSet_[i] = true; } @@ -851,9 +855,10 @@ WriteResult RowWriterV2::checkUnsetFields() noexcept { r = write(i, defVal.getDuration()); break; default: - LOG(FATAL) << "Unsupported default value type: " << defVal.typeName() - << ", default value: " << defVal - << ", default value expr: " << field->defaultValue(); + LOG(DFATAL) << "Unsupported default value type: " << defVal.typeName() + << ", default value: " << defVal + << ", default value expr: " << field->defaultValue(); + return WriteResult::TYPE_MISMATCH; } } else { // Set NULL diff --git a/src/graph/context/Iterator.cpp b/src/graph/context/Iterator.cpp index 4079f190144..85837a853f3 100644 --- a/src/graph/context/Iterator.cpp +++ b/src/graph/context/Iterator.cpp @@ -6,7 +6,7 @@ #include "graph/context/Iterator.h" #include - +return TransformResult::noTransform(); #include "common/datatypes/Edge.h" #include "common/datatypes/Vertex.h" #include "common/memory/MemoryUtils.h" @@ -758,7 +758,7 @@ PropIter::PropIter(std::shared_ptr value, bool checkMemory) auto& ds = value->getDataSet(); auto status = makeDataSetIndex(ds); if (UNLIKELY(!status.ok())) { - DLOG(FATAL) << status; + LOG(DFATAL) << status; clear(); return; } diff --git a/src/graph/context/Iterator.h b/src/graph/context/Iterator.h index 1b4119f0a32..77441e289e2 100644 --- a/src/graph/context/Iterator.h +++ b/src/graph/context/Iterator.h @@ -136,12 +136,12 @@ class Iterator { } virtual const Value& getTagProp(const std::string&, const std::string&) const { - DLOG(FATAL) << "Shouldn't call the unimplemented method"; + LOG(DFATAL) << "Shouldn't call the unimplemented method"; return Value::kEmpty; } virtual const Value& getEdgeProp(const std::string&, const std::string&) const { - DLOG(FATAL) << "Shouldn't call the unimplemented method"; + LOG(DFATAL) << "Shouldn't call the unimplemented method"; return Value::kEmpty; } @@ -203,11 +203,11 @@ class DefaultIter final : public Iterator { } void select(std::size_t, std::size_t) override { - DLOG(FATAL) << "Unimplemented method for default iterator."; + LOG(DFATAL) << "Unimplemented method for default iterator."; } void sample(int64_t) override { - DLOG(FATAL) << "Unimplemented default iterator."; + LOG(DFATAL) << "Unimplemented default iterator."; } void clear() override { @@ -219,27 +219,27 @@ class DefaultIter final : public Iterator { } const Value& getColumn(const std::string& /* col */) const override { - DLOG(FATAL) << "This method should not be invoked"; + LOG(DFATAL) << "This method should not be invoked"; return Value::kEmpty; } const Value& getColumn(int32_t) const override { - DLOG(FATAL) << "This method should not be invoked"; + LOG(DFATAL) << "This method should not be invoked"; return Value::kEmpty; } StatusOr getColumnIndex(const std::string&) const override { - DLOG(FATAL) << "This method should not be invoked"; + LOG(DFATAL) << "This method should not be invoked"; return Status::Error("Unimplemented method"); } const Row* row() const override { - DLOG(FATAL) << "This method should not be invoked"; + LOG(DFATAL) << "This method should not be invoked"; return nullptr; } Row moveRow() override { - DLOG(FATAL) << "This method should not be invoked"; + LOG(DFATAL) << "This method should not be invoked"; return Row{}; } diff --git a/src/graph/executor/Executor.cpp b/src/graph/executor/Executor.cpp index 06588f2d1b4..28202763f59 100644 --- a/src/graph/executor/Executor.cpp +++ b/src/graph/executor/Executor.cpp @@ -559,7 +559,7 @@ Executor *Executor::makeExecutor(QueryContext *qctx, const PlanNode *node) { return pool->makeAndAdd(node, qctx); } case PlanNode::Kind::kUnknown: { - LOG(FATAL) << "Unknown plan node kind " << static_cast(node->kind()); + LOG(DFATAL) << "Unknown plan node kind " << static_cast(node->kind()); break; } } diff --git a/src/graph/executor/admin/SubmitJobExecutor.cpp b/src/graph/executor/admin/SubmitJobExecutor.cpp index 2af4b6cc741..6d41c9913f1 100644 --- a/src/graph/executor/admin/SubmitJobExecutor.cpp +++ b/src/graph/executor/admin/SubmitJobExecutor.cpp @@ -101,7 +101,7 @@ StatusOr SubmitJobExecutor::buildResult(meta::cpp2::JobOp jobOp, } // no default so the compiler will warning when lack } - DLOG(FATAL) << "Unknown job operation " << static_cast(jobOp); + LOG(DFATAL) << "Unknown job operation " << static_cast(jobOp); return Status::Error("Unknown job job operation %d.", static_cast(jobOp)); } diff --git a/src/graph/executor/query/DataCollectExecutor.cpp b/src/graph/executor/query/DataCollectExecutor.cpp index c4440741860..f4a3eeede7d 100644 --- a/src/graph/executor/query/DataCollectExecutor.cpp +++ b/src/graph/executor/query/DataCollectExecutor.cpp @@ -50,7 +50,8 @@ folly::Future DataCollectExecutor::doCollect() { break; } default: - LOG(FATAL) << "Unknown data collect type: " << static_cast(dc->kind()); + LOG(DFATAL) << "Unknown data collect type: " << static_cast(dc->kind()); + return Status::Error("Unknown data collect type: %d.", static_cast(dc->kind()); } ResultBuilder builder; builder.value(Value(std::move(result_))).iter(Iterator::Kind::kSequential); diff --git a/src/graph/optimizer/rule/PushEFilterDownRule.cpp b/src/graph/optimizer/rule/PushEFilterDownRule.cpp index 0af06f4a4b3..f18ae8798eb 100644 --- a/src/graph/optimizer/rule/PushEFilterDownRule.cpp +++ b/src/graph/optimizer/rule/PushEFilterDownRule.cpp @@ -174,7 +174,7 @@ std::string PushEFilterDownRule::toString() const { ret = EdgePropertyExpression::make(pool, std::move(edgeNameResult).value(), exp->prop()); break; default: - LOG(FATAL) << "Unexpected expr: " << exp->kind(); + LOG(DFATAL) << "Unexpected expr: " << exp->kind(); } return ret; } diff --git a/src/graph/optimizer/rule/PushFilterDownNodeRule.cpp b/src/graph/optimizer/rule/PushFilterDownNodeRule.cpp index 9c89cd16c63..20fcfb4a7d2 100644 --- a/src/graph/optimizer/rule/PushFilterDownNodeRule.cpp +++ b/src/graph/optimizer/rule/PushFilterDownNodeRule.cpp @@ -55,7 +55,7 @@ StatusOr PushFilterDownNodeRule::transform( auto *append = static_cast(node); vFilter = append->vFilter()->clone(); } else { - DLOG(FATAL) << "Unsupported node kind: " << node->kind(); + LOG(DFATAL) << "Unsupported node kind: " << node->kind(); return TransformResult::noTransform(); } auto visitor = graph::ExtractFilterExprVisitor::makePushGetVertices(pool); @@ -83,7 +83,7 @@ StatusOr PushFilterDownNodeRule::transform( append->setVertexFilter(remainedExpr); append->setFilter(vFilter); } else { - DLOG(FATAL) << "Unsupported node kind: " << newExplore->kind(); + LOG(DFATAL) << "Unsupported node kind: " << newExplore->kind(); return TransformResult::noTransform(); } @@ -111,7 +111,7 @@ bool PushFilterDownNodeRule::match(OptContext *octx, const MatchedResult &matche return false; } } else { - DLOG(FATAL) << "Unexpected node kind: " << node->kind(); + LOG(DFATAL) << "Unexpected node kind: " << node->kind(); return false; } return true; diff --git a/src/graph/optimizer/rule/UnionAllIndexScanBaseRule.cpp b/src/graph/optimizer/rule/UnionAllIndexScanBaseRule.cpp index 645bb6794c8..a8cdfd19ff8 100644 --- a/src/graph/optimizer/rule/UnionAllIndexScanBaseRule.cpp +++ b/src/graph/optimizer/rule/UnionAllIndexScanBaseRule.cpp @@ -166,8 +166,8 @@ StatusOr UnionAllIndexScanBaseRule::transform(OptContext* ctx, break; } default: - LOG(FATAL) << "Invalid expression kind: " << static_cast(conditionType); - break; + LOG(DFATAL) << "Invalid expression kind: " << static_cast(conditionType); + return TransformResult::noTransform(); } DCHECK(transformedExpr->kind() == ExprKind::kLogicalOr); diff --git a/src/graph/planner/match/SegmentsConnector.cpp b/src/graph/planner/match/SegmentsConnector.cpp index 63dcbcebe8b..ca9872a1a8d 100644 --- a/src/graph/planner/match/SegmentsConnector.cpp +++ b/src/graph/planner/match/SegmentsConnector.cpp @@ -140,7 +140,7 @@ SubPlan SegmentsConnector::addInput(const SubPlan& left, const SubPlan& right, b siLeft->setLeftDep(const_cast(right.root)); siLeft->setLeftVar(right.root->outputVar()); } else { - DLOG(FATAL) << "Unsupported plan node: " << left.tail->kind(); + LOG(DFATAL) << "Unsupported plan node: " << left.tail->kind(); return newPlan; } newPlan.tail = right.tail; diff --git a/src/graph/planner/plan/PlanNode.cpp b/src/graph/planner/plan/PlanNode.cpp index 72931b7f24c..ef54c69d158 100644 --- a/src/graph/planner/plan/PlanNode.cpp +++ b/src/graph/planner/plan/PlanNode.cpp @@ -305,7 +305,8 @@ const char* PlanNode::toString(PlanNode::Kind kind) { return "GetDstBySrc"; // no default so the compiler will warning when lack } - LOG(FATAL) << "Impossible kind plan node " << static_cast(kind); + LOG(DFATAL) << "Impossible kind plan node " << static_cast(kind); + return "Unknown"; } std::string PlanNode::toString() const { diff --git a/src/graph/planner/plan/PlanNode.h b/src/graph/planner/plan/PlanNode.h index 0b47e93d91e..00e905782cf 100644 --- a/src/graph/planner/plan/PlanNode.h +++ b/src/graph/planner/plan/PlanNode.h @@ -348,7 +348,7 @@ class SingleDependencyNode : public PlanNode { } PlanNode* clone() const override { - LOG(FATAL) << "Shouldn't call the unimplemented method"; + LOG(DFATAL) << "Shouldn't call the unimplemented method"; return nullptr; } @@ -370,7 +370,7 @@ class SingleInputNode : public SingleDependencyNode { std::unique_ptr explain() const override; PlanNode* clone() const override { - LOG(FATAL) << "Shouldn't call the unimplemented method"; + LOG(DFATAL) << "Shouldn't call the unimplemented method"; return nullptr; } @@ -420,7 +420,7 @@ class BinaryInputNode : public PlanNode { } PlanNode* clone() const override { - LOG(FATAL) << "Shouldn't call the unimplemented method for " << kind_; + LOG(DFATAL) << "Shouldn't call the unimplemented method for " << kind_; return nullptr; } @@ -442,7 +442,7 @@ class VariableDependencyNode : public PlanNode { std::unique_ptr explain() const override; PlanNode* clone() const override { - LOG(FATAL) << "Shouldn't call the unimplemented method"; + LOG(DFATAL) << "Shouldn't call the unimplemented method"; return nullptr; } diff --git a/src/graph/util/ParserUtil.cpp b/src/graph/util/ParserUtil.cpp index c90ea0e339c..1ab8c3b07ce 100644 --- a/src/graph/util/ParserUtil.cpp +++ b/src/graph/util/ParserUtil.cpp @@ -62,7 +62,7 @@ void ParserUtil::rewriteLC(QueryContext *qctx, return static_cast(mpp); } break; default: - LOG(FATAL) << "Unexpected expression kind: " << expr->kind(); + LOG(DFATAL) << "Unexpected expression kind: " << expr->kind(); } return ret; }; diff --git a/src/graph/util/ToJson.cpp b/src/graph/util/ToJson.cpp index 5c6b574690a..5cc8cbea458 100644 --- a/src/graph/util/ToJson.cpp +++ b/src/graph/util/ToJson.cpp @@ -82,7 +82,7 @@ folly::dynamic toJson(const Value &value) { // TODO store to object or array return value.toString(); } - DLOG(FATAL) << "Impossible reach."; + LOG(DFATAL) << "Impossible reach."; return folly::dynamic::object(); } diff --git a/src/graph/validator/LookupValidator.cpp b/src/graph/validator/LookupValidator.cpp index ea88bb0c2e3..84578441004 100644 --- a/src/graph/validator/LookupValidator.cpp +++ b/src/graph/validator/LookupValidator.cpp @@ -541,8 +541,8 @@ Expression* LookupValidator::reverseRelKind(RelationalExpression* expr) { reversedKind = ExprKind::kRelLE; break; default: - LOG(FATAL) << "Invalid relational expression kind: " << static_cast(kind); - break; + LOG(DFATAL) << "Invalid relational expression kind: " << static_cast(kind); + return expr; } auto left = expr->left(); diff --git a/src/graph/validator/Validator.cpp b/src/graph/validator/Validator.cpp index a98dde58ad6..634573230f9 100644 --- a/src/graph/validator/Validator.cpp +++ b/src/graph/validator/Validator.cpp @@ -258,10 +258,10 @@ std::unique_ptr Validator::makeValidator(Sentence* sentence, QueryCon case Sentence::Kind::kUnknown: case Sentence::Kind::kReturn: { // nothing - DLOG(FATAL) << "Unimplemented sentence " << kind; + LOG(DFATAL) << "Unimplemented sentence " << kind; } } - DLOG(FATAL) << "Unknown sentence " << static_cast(kind); + LOG(DFATAL) << "Unknown sentence " << static_cast(kind); return std::make_unique(sentence, context); } diff --git a/src/graph/visitor/DeduceTypeVisitor.cpp b/src/graph/visitor/DeduceTypeVisitor.cpp index bf8ab94b3ca..d8689337d51 100644 --- a/src/graph/visitor/DeduceTypeVisitor.cpp +++ b/src/graph/visitor/DeduceTypeVisitor.cpp @@ -219,8 +219,12 @@ void DeduceTypeVisitor::visit(UnaryExpression *expr) { break; } default: { - LOG(FATAL) << "Invalid unary expression kind: " << static_cast(expr->kind()); - break; + LOG(DFATAL) << "Invalid unary expression kind: " << static_cast(expr->kind()); + std::stringstream ss; + ss << "`" << expr->toString() << "' is invalid unary expression, kind is " + << static_cast(expr->kind()) << "."; + status_ = Status::SemanticError(ss.str()); + return; } } } @@ -280,8 +284,12 @@ void DeduceTypeVisitor::visit(ArithmeticExpression *expr) { break; } default: { - LOG(FATAL) << "Invalid arithmetic expression kind: " << static_cast(expr->kind()); - break; + LOG(DFATAL) << "Invalid arithmetic expression kind: " << static_cast(expr->kind()); + std::stringstream ss; + ss << "`" << expr->toString() << "' is invalid arithmetic expression, kind is " + << static_cast(expr->kind()) << "."; + status_ = Status::SemanticError(ss.str()); + return; } } } @@ -422,8 +430,12 @@ void DeduceTypeVisitor::visit(LogicalExpression *expr) { break; } default: { - LOG(FATAL) << "Invalid logical expression kind: " << static_cast(expr->kind()); - break; + LOG(DFATAL) << "Invalid logical expression kind: " << static_cast(expr->kind()); + std::stringstream ss; + ss << "`" << expr->toString() << "' is invalid logical expression, kind is " + << static_cast(expr->kind()) << "."; + status_ = Status::SemanticError(ss.str()); + return; } } } diff --git a/src/graph/visitor/ExtractPropExprVisitor.cpp b/src/graph/visitor/ExtractPropExprVisitor.cpp index 5b2cfab849e..44531ddd02f 100644 --- a/src/graph/visitor/ExtractPropExprVisitor.cpp +++ b/src/graph/visitor/ExtractPropExprVisitor.cpp @@ -93,7 +93,8 @@ void ExtractPropExprVisitor::visit(UnaryExpression* expr) { break; } default: { - LOG(FATAL) << "Invalid Kind " << expr->kind(); + LOG(DFATAL) << "Invalid Kind " << expr->kind(); + reportError(expr); } } } @@ -110,7 +111,9 @@ void ExtractPropExprVisitor::visitPropertyExpr(PropertyExpression* expr) { break; } default: { - LOG(FATAL) << "Invalid Kind " << expr->kind(); + LOG(DFATAL) << "Invalid Kind " << expr->kind(); + reportError(expr); + return; } } auto found = propExprColMap_.find(propExpr->toString()); @@ -162,7 +165,9 @@ void ExtractPropExprVisitor::visitVertexEdgePropExpr(PropertyExpression* expr) { break; } default: { - LOG(FATAL) << "Invalid Kind " << expr->kind(); + LOG(DFATAL) << "Invalid Kind " << expr->kind(); + reportError(expr); + return; } } auto found = propExprColMap_.find(propExpr->toString()); diff --git a/src/kvstore/DiskManager.cpp b/src/kvstore/DiskManager.cpp index 30e58c5bca6..d80c3bffd49 100644 --- a/src/kvstore/DiskManager.cpp +++ b/src/kvstore/DiskManager.cpp @@ -20,6 +20,8 @@ DiskManager::DiskManager(const std::vector& dataPaths, Paths* paths = new Paths(); paths_.store(paths); size_t index = 0; + + // TODO: Add initialize function to avoid using LOG(FATAL) in constructor. for (const auto& path : dataPaths) { auto absolute = boost::filesystem::absolute(path); if (!boost::filesystem::exists(absolute)) { @@ -93,7 +95,7 @@ void DiskManager::addPartToPath(GraphSpaceID spaceId, PartitionID partId, const paths_.store(newPaths, std::memory_order_release); folly::rcu_retire(oldPaths, std::default_delete()); } catch (boost::filesystem::filesystem_error& e) { - LOG(FATAL) << "Invalid path: " << e.what(); + LOG(DFATAL) << "Invalid path: " << e.what(); } } @@ -114,7 +116,7 @@ void DiskManager::removePartFromPath(GraphSpaceID spaceId, paths_.store(newPaths, std::memory_order_release); folly::rcu_retire(oldPaths, std::default_delete()); } catch (boost::filesystem::filesystem_error& e) { - LOG(FATAL) << "Invalid path: " << e.what(); + LOG(DFATAL) << "Invalid path: " << e.what(); } } diff --git a/src/kvstore/NebulaStore.cpp b/src/kvstore/NebulaStore.cpp index d9a4a5a9166..d994caf1c64 100644 --- a/src/kvstore/NebulaStore.cpp +++ b/src/kvstore/NebulaStore.cpp @@ -343,7 +343,7 @@ std::unique_ptr NebulaStore::newEngine(GraphSpaceID spaceId, return std::make_unique( spaceId, vIdLen, dataPath, walPath, options_.mergeOp_, cfFactory); } else { - LOG(FATAL) << "Unknown engine type " << FLAGS_engine_type; + LOG(DFATAL) << "Unknown engine type " << FLAGS_engine_type; return nullptr; } } @@ -627,7 +627,7 @@ std::shared_ptr NebulaStore::newListener(GraphSpaceID spaceId, listener = std::make_shared( spaceId, partId, raftAddr_, walPath, ioPool_, bgWorkers_, workers_, options_.schemaMan_); } else { - LOG(FATAL) << "Should not reach here"; + LOG(DFATAL) << "Should not reach here"; return nullptr; } raftService_->addPartition(listener); diff --git a/src/kvstore/RocksEngine.cpp b/src/kvstore/RocksEngine.cpp index eadacf20092..6bd72d1432c 100644 --- a/src/kvstore/RocksEngine.cpp +++ b/src/kvstore/RocksEngine.cpp @@ -47,6 +47,8 @@ RocksEngine::RocksEngine(GraphSpaceID spaceId, walPath_ = folly::stringPrintf("%s/nebula/%d", walPath.c_str(), spaceId); } auto path = folly::stringPrintf("%s/data", dataPath_.c_str()); + + // TODO: Add initialize function to avoid using LOG(FATAL) in constructor. if (FileUtils::fileType(path.c_str()) == FileType::NOTEXIST) { if (readonly) { LOG(FATAL) << "Path " << path << " not exist"; diff --git a/src/kvstore/RocksEngineConfig.cpp b/src/kvstore/RocksEngineConfig.cpp index 50e3090b5cb..4497b40ea55 100644 --- a/src/kvstore/RocksEngineConfig.cpp +++ b/src/kvstore/RocksEngineConfig.cpp @@ -248,7 +248,8 @@ rocksdb::Status initRocksdbOptions(rocksdb::Options& baseOpts, auto walDir = folly::stringPrintf("%s/rocksdb_wal/%d", FLAGS_rocksdb_wal_dir.c_str(), spaceId); if (fs::FileUtils::fileType(walDir.c_str()) == fs::FileType::NOTEXIST) { if (!fs::FileUtils::makeDir(walDir)) { - LOG(FATAL) << "makeDir " << walDir << " failed"; + LOG(DFATAL) << "makeDir " << walDir << " failed"; + return rocksdb::Status::InvalidArgument(); } } LOG(INFO) << "set rocksdb wal of space " << spaceId << " to " << walDir; diff --git a/src/kvstore/listener/Listener.cpp b/src/kvstore/listener/Listener.cpp index f50d5ee11c8..a3f14bb64cf 100644 --- a/src/kvstore/listener/Listener.cpp +++ b/src/kvstore/listener/Listener.cpp @@ -39,7 +39,10 @@ Listener::Listener(GraphSpaceID spaceId, void Listener::start(std::vector&& peers, bool) { std::lock_guard g(raftLock_); - init(); + if (!init()) { + // TODO: return bool to avoid using LOG(FATAL) + LOG(FATAL) << "Listener init failed"; + } lastLogId_ = wal_->lastLogId(); lastLogTerm_ = wal_->lastLogTerm(); diff --git a/src/kvstore/listener/Listener.h b/src/kvstore/listener/Listener.h index 9df8672b7f1..fc4d1e7fdda 100644 --- a/src/kvstore/listener/Listener.h +++ b/src/kvstore/listener/Listener.h @@ -75,7 +75,7 @@ using RaftClient = thrift::ThriftClientManagergetSpaceVidLen(spaceId_); if (!vRet.ok()) { - LOG(FATAL) << "vid length error"; + LOG(DFATAL) << "vid length error"; + return false; } vIdLen_ = vRet.value(); auto cRet = schemaMan_->getServiceClients(meta::cpp2::ExternalServiceType::ELASTICSEARCH); if (!cRet.ok() || cRet.value().empty()) { - LOG(FATAL) << "elasticsearch clients error"; + LOG(DFATAL) << "elasticsearch clients error"; + return false; } std::vector esClients; for (const auto& c : cRet.value()) { @@ -39,9 +41,11 @@ void ESListener::init() { esAdapter_.setClients(std::move(esClients)); auto sRet = schemaMan_->toGraphSpaceName(spaceId_); if (!sRet.ok()) { - LOG(FATAL) << "space name error"; + LOG(DFATAL) << "space name error"; + return false; } spaceName_ = std::make_unique(sRet.value()); + return true; } bool ESListener::apply(const BatchHolder& batch) { @@ -58,7 +62,8 @@ bool ESListener::apply(const BatchHolder& batch) { } else if (type == BatchLogType::OP_BATCH_REMOVE) { bulk.delete_(index, vid, src, dst, rank); } else { - LOG(FATAL) << "Unexpect"; + LOG(DFATAL) << "Unexpect"; + return false; } }; for (const auto& log : batch.getBatch()) { @@ -133,7 +138,8 @@ void ESListener::pickTagAndEdgeData(BatchLogType type, bool ESListener::persist(LogID lastId, TermID lastTerm, LogID lastApplyLogId) { if (!writeAppliedId(lastId, lastTerm, lastApplyLogId)) { - LOG(FATAL) << "last apply ids write failed"; + LOG(DFATAL) << "last apply ids write failed"; + return false; } return true; } @@ -145,8 +151,9 @@ std::pair ESListener::lastCommittedLogId() { } int32_t fd = open(lastApplyLogFile_->c_str(), O_RDONLY); if (fd < 0) { - LOG(FATAL) << "Failed to open the file \"" << lastApplyLogFile_->c_str() << "\" (" << errno - << "): " << strerror(errno); + LOG(DFATAL) << "Failed to open the file \"" << lastApplyLogFile_->c_str() << "\" (" << errno + << "): " << strerror(errno); + return {0, 0}; } // read last logId from listener wal file. LogID logId; @@ -168,8 +175,9 @@ LogID ESListener::lastApplyLogId() { } int32_t fd = open(lastApplyLogFile_->c_str(), O_RDONLY); if (fd < 0) { - LOG(FATAL) << "Failed to open the file \"" << lastApplyLogFile_->c_str() << "\" (" << errno - << "): " << strerror(errno); + LOG(DFATAL) << "Failed to open the file \"" << lastApplyLogFile_->c_str() << "\" (" << errno + << "): " << strerror(errno); + return 0; } // read last applied logId from listener wal file. LogID logId; diff --git a/src/kvstore/listener/elasticsearch/ESListener.h b/src/kvstore/listener/elasticsearch/ESListener.h index ba0eaa59a68..0c49f0fe008 100644 --- a/src/kvstore/listener/elasticsearch/ESListener.h +++ b/src/kvstore/listener/elasticsearch/ESListener.h @@ -46,7 +46,7 @@ class ESListener : public Listener { /** * @brief Init work: get vid length, get es client */ - void init() override; + bool init() override; /** * @brief Send data by es client diff --git a/src/kvstore/plugins/hbase/HBaseStore.cpp b/src/kvstore/plugins/hbase/HBaseStore.cpp index 65f3e1a8254..f329c535ef5 100644 --- a/src/kvstore/plugins/hbase/HBaseStore.cpp +++ b/src/kvstore/plugins/hbase/HBaseStore.cpp @@ -212,7 +212,8 @@ ResultCode HBaseStore::rangeWithPrefix(GraphSpaceID spaceId, ResultCode HBaseStore::sync(GraphSpaceID spaceId, PartitionID partId) { UNUSED(spaceId); UNUSED(partId); - LOG(FATAL) << "Unimplement"; + LOG(DFATAL) << "Unimplement"; + return ResultCode::ERR_UNSUPPORTED; } ResultCode HBaseStore::multiRemove(GraphSpaceID spaceId, std::vector& keys) { @@ -403,11 +404,13 @@ void HBaseStore::asyncRemovePrefix(GraphSpaceID spaceId, } ResultCode HBaseStore::ingest(GraphSpaceID) { - LOG(FATAL) << "Unimplement"; + LOG(DFATAL) << "Unimplement"; + return ResultCode::ERR_UNSUPPORTED; } int32_t HBaseStore::allLeader(std::unordered_map>&) { - LOG(FATAL) << "Unimplement"; + LOG(DFATAL) << "Unimplement"; + return 0; } } // namespace kvstore diff --git a/src/kvstore/plugins/hbase/HBaseStore.h b/src/kvstore/plugins/hbase/HBaseStore.h index 7b085be7fb0..4f165c896c8 100644 --- a/src/kvstore/plugins/hbase/HBaseStore.h +++ b/src/kvstore/plugins/hbase/HBaseStore.h @@ -181,11 +181,11 @@ class HBaseStore : public KVStore { KVCallback cb); void asyncAtomicOp(GraphSpaceID, PartitionID, raftex::AtomicOp, KVCallback) override { - LOG(FATAL) << "Not supported yet!"; + LOG(DFATAL) << "Not supported yet!"; } void asyncAtomicOp(GraphSpaceID, PartitionID, std::string&& multiValues, KVCallback) override { - LOG(FATAL) << "Not supported yet!"; + LOG(DFATAL) << "Not supported yet!"; } ResultCode ingest(GraphSpaceID spaceId) override; diff --git a/src/kvstore/raftex/RaftPart.cpp b/src/kvstore/raftex/RaftPart.cpp index 781db5f24fd..46a6235f59c 100644 --- a/src/kvstore/raftex/RaftPart.cpp +++ b/src/kvstore/raftex/RaftPart.cpp @@ -95,7 +95,7 @@ class AppendLogsIterator final : public LogIterator { } } if (notFulfilledPromise > 0) { - LOG(FATAL) << "notFulfilledPromise == " << notFulfilledPromise; + LOG(DFATAL) << "notFulfilledPromise == " << notFulfilledPromise; } } } @@ -394,7 +394,7 @@ const char* RaftPart::roleStr(Role role) const { case Role::LEARNER: return "Learner"; default: - LOG(FATAL) << idStr_ << "Invalid role"; + LOG(DFATAL) << idStr_ << "Invalid role"; } return nullptr; } @@ -1091,7 +1091,11 @@ void RaftPart::processAppendLogResponses(const AppendLogResponses& resps, [self = shared_from_this(), term = term_] { self->onLeaderReady(term); }); } } else { - LOG(FATAL) << idStr_ << "Failed to commit logs"; + LOG(DFATAL) << idStr_ << "Failed to commit logs"; + checkAppendLogResult(code); + VLOG(3) << idStr_ << "commitLogs failed"; + iter.commit(code); + return; } VLOG(4) << idStr_ << "Leader succeeded in committing the logs " << committedId + 1 << " to " << lastLogId; diff --git a/src/kvstore/wal/FileBasedWal.cpp b/src/kvstore/wal/FileBasedWal.cpp index 91435b4955c..14b36a0c9df 100644 --- a/src/kvstore/wal/FileBasedWal.cpp +++ b/src/kvstore/wal/FileBasedWal.cpp @@ -479,8 +479,9 @@ bool FileBasedWal::appendLogInternal(LogID id, ssize_t bytesWritten = write(currFd_, strBuf.data(), strBuf.size()); if (bytesWritten != (ssize_t)strBuf.size()) { - LOG(FATAL) << idStr_ << "bytesWritten:" << bytesWritten << ", expected:" << strBuf.size() - << ", error:" << strerror(errno); + LOG(DFATAL) << idStr_ << "bytesWritten:" << bytesWritten << ", expected:" << strBuf.size() + << ", error:" << strerror(errno); + return false; } if (policy_.sync && ::fsync(currFd_) == -1) { diff --git a/src/meta/processors/schema/SchemaUtil.cpp b/src/meta/processors/schema/SchemaUtil.cpp index 526efc1fe34..c482b1a5fd8 100644 --- a/src/meta/processors/schema/SchemaUtil.cpp +++ b/src/meta/processors/schema/SchemaUtil.cpp @@ -187,7 +187,7 @@ bool SchemaUtil::checkType(std::vector& columns) { return false; // no default so compiler will warning when lack } // switch - DLOG(FATAL) << "Unknown property type " << static_cast(column.get_type().get_type()); + LOG(DFATAL) << "Unknown property type " << static_cast(column.get_type().get_type()); return false; } diff --git a/src/meta/upgrade/MetaDataUpgrade.cpp b/src/meta/upgrade/MetaDataUpgrade.cpp index bbdd567771b..eccf19b83ef 100644 --- a/src/meta/upgrade/MetaDataUpgrade.cpp +++ b/src/meta/upgrade/MetaDataUpgrade.cpp @@ -143,7 +143,7 @@ nebula::meta::cpp2::GeoShape MetaDataUpgrade::convertToGeoShape( case nebula::meta::v2::cpp2::GeoShape::POLYGON: return nebula::meta::cpp2::GeoShape::POLYGON; default: - LOG(FATAL) << "Unimplemented"; + LOG(FATAL) << "Invalid geo shape : " << static_cast(shape); } } diff --git a/src/parser/AdminSentences.cpp b/src/parser/AdminSentences.cpp index b72735bb18a..cbd7560715a 100644 --- a/src/parser/AdminSentences.cpp +++ b/src/parser/AdminSentences.cpp @@ -76,7 +76,7 @@ std::string SpaceOptItem::toString() const { case OptionType::GROUP_NAME: return ""; } - DLOG(FATAL) << "Space parameter illegal"; + LOG(DFATAL) << "Space parameter illegal"; return "Unknown"; } @@ -215,8 +215,8 @@ std::string AddListenerSentence::toString() const { buf += "ELASTICSEARCH "; break; case meta::cpp2::ListenerType::UNKNOWN: - LOG(FATAL) << "Unknown listener type."; - break; + LOG(DFATAL) << "Unknown listener type."; + return "Unknown"; } buf += listeners_->toString(); return buf; @@ -231,8 +231,8 @@ std::string RemoveListenerSentence::toString() const { buf += "ELASTICSEARCH "; break; case meta::cpp2::ListenerType::UNKNOWN: - DLOG(FATAL) << "Unknown listener type."; - break; + LOG(DFATAL) << "Unknown listener type."; + return "Unknown"; } return buf; } @@ -309,7 +309,8 @@ std::string AdminJobSentence::toString() const { return str; } } - LOG(FATAL) << "Unknown job operation " << static_cast(op_); + LOG(DFATAL) << "Unknown job operation " << static_cast(op_); + return "Unknown"; } meta::cpp2::JobOp AdminJobSentence::getOp() const { @@ -343,7 +344,8 @@ std::string ShowServiceClientsSentence::toString() const { case meta::cpp2::ExternalServiceType::ELASTICSEARCH: return "SHOW TEXT SEARCH CLIENTS"; default: - LOG(FATAL) << "Unknown service type " << static_cast(type_); + LOG(DFATAL) << "Unknown service type " << static_cast(type_); + return "Unknown"; } } @@ -355,7 +357,8 @@ std::string SignInServiceSentence::toString() const { buf += "SIGN IN TEXT SERVICE "; break; default: - LOG(FATAL) << "Unknown service type " << static_cast(type_); + LOG(DFATAL) << "Unknown service type " << static_cast(type_); + return "Unknown"; } for (auto &client : clients_->clients()) { @@ -394,7 +397,8 @@ std::string SignOutServiceSentence::toString() const { case meta::cpp2::ExternalServiceType::ELASTICSEARCH: return "SIGN OUT TEXT SERVICE"; default: - LOG(FATAL) << "Unknown service type " << static_cast(type_); + LOG(DFATAL) << "Unknown service type " << static_cast(type_); + return "Unknown"; } } diff --git a/src/parser/MaintainSentences.cpp b/src/parser/MaintainSentences.cpp index 308c3736914..ea881b09e70 100644 --- a/src/parser/MaintainSentences.cpp +++ b/src/parser/MaintainSentences.cpp @@ -25,7 +25,7 @@ std::string SchemaPropItem::toString() const { case COMMENT: return folly::stringPrintf("comment = \"%s\"", std::get(propValue_).c_str()); } - DLOG(FATAL) << "Schema property type illegal"; + LOG(DFATAL) << "Schema property type illegal"; return "Unknown"; } @@ -239,7 +239,7 @@ std::string IndexParamItem::toString() const { case S2_MAX_CELLS: return folly::stringPrintf("s2_max_cells = \"%ld\"", paramValue_.getInt()); } - DLOG(FATAL) << "Index param type illegal"; + LOG(DFATAL) << "Index param type illegal"; return "Unknown"; } diff --git a/src/parser/TraverseSentences.cpp b/src/parser/TraverseSentences.cpp index af1fd83ec47..a773e5e9d82 100644 --- a/src/parser/TraverseSentences.cpp +++ b/src/parser/TraverseSentences.cpp @@ -124,7 +124,8 @@ std::string OrderFactor::toString() const { case DESCEND: return folly::stringPrintf("%s DESC,", expr_->toString().c_str()); default: - LOG(FATAL) << "Unknown Order Type: " << orderType_; + LOG(DFATAL) << "Unknown Order Type: " << orderType_; + return "Unknown"; } } diff --git a/src/storage/GraphStorageServiceHandler.cpp b/src/storage/GraphStorageServiceHandler.cpp index 7d10fcf6fe1..6289abd7184 100644 --- a/src/storage/GraphStorageServiceHandler.cpp +++ b/src/storage/GraphStorageServiceHandler.cpp @@ -158,9 +158,17 @@ folly::Future GraphStorageServiceHandler::future_scanEdge( folly::Future GraphStorageServiceHandler::future_getUUID( const cpp2::GetUUIDReq&) { - LOG(FATAL) << "Unsupported in version 2.0"; - cpp2::GetUUIDResp ret; - return ret; + LOG(DFATAL) << "Unsupported in version 2.0"; + + cpp2::GetUUIDResp resp; + cpp2::ResponseCommon result; + std::vector partRetCode; + cpp2::PartitionResult thriftRet; + thriftRet.code_ref() = cpp2::ErrorCode::E_UNSUPPORTED; + partRetCode.emplace_back(std::move(thriftRet)); + result.failed_parts_ref() = partRetCode; + resp.result_ref() = result; + return resp; } folly::Future GraphStorageServiceHandler::future_chainAddEdges( diff --git a/src/storage/StorageServer.cpp b/src/storage/StorageServer.cpp index 4fef2b0d3b8..56939e4fed3 100644 --- a/src/storage/StorageServer.cpp +++ b/src/storage/StorageServer.cpp @@ -85,9 +85,11 @@ std::unique_ptr StorageServer::getStoreInstance() { } return nbStore; } else if (FLAGS_store_type == "hbase") { - LOG(FATAL) << "HBase store has not been implemented"; + LOG(DFATAL) << "HBase store has not been implemented"; + return nullptr; } else { - LOG(FATAL) << "Unknown store type \"" << FLAGS_store_type << "\""; + LOG(DFATAL) << "Unknown store type \"" << FLAGS_store_type << "\""; + return nullptr; } return nullptr; } @@ -139,7 +141,8 @@ int32_t StorageServer::getAdminStoreSeqId() { newVal.append(reinterpret_cast(&curSeqId), sizeof(int32_t)); auto ret = env_->adminStore_->put(key, newVal); if (ret != nebula::cpp2::ErrorCode::SUCCEEDED) { - LOG(FATAL) << "Write put in admin-storage seq id " << curSeqId << " failed."; + LOG(DFATAL) << "Write put in admin-storage seq id " << curSeqId << " failed."; + return -1; } return curSeqId; } @@ -259,6 +262,11 @@ bool StorageServer::start() { env_->edgesML_ = std::make_unique(); env_->adminStore_ = getAdminStoreInstance(); env_->adminSeqId_ = getAdminStoreSeqId(); + if (env_->adminSeqId_ < 0) { + LOG(ERROR) << "Get admin store seq id failed!"; + return false; + } + taskMgr_ = AdminTaskManager::instance(env_.get()); if (!taskMgr_->init()) { LOG(ERROR) << "Init task manager failed!"; diff --git a/src/storage/context/StorageExpressionContext.h b/src/storage/context/StorageExpressionContext.h index f11b3858d11..96da8c5a6ad 100644 --- a/src/storage/context/StorageExpressionContext.h +++ b/src/storage/context/StorageExpressionContext.h @@ -89,7 +89,7 @@ class StorageExpressionContext final : public ExpressionContext { // Get index of property in variable tuple StatusOr getVarPropIndex(const std::string&, const std::string&) const override { - DLOG(FATAL) << "Unimplemented"; + LOG(DFATAL) << "Unimplemented"; return Status::Error("Unimplemented"); } @@ -114,7 +114,7 @@ class StorageExpressionContext final : public ExpressionContext { // Get index of property in input tuple StatusOr getInputPropIndex(const std::string&) const override { - DLOG(FATAL) << "Unimplemented"; + LOG(DFATAL) << "Unimplemented"; return Status::Error("Unimplemented"); } @@ -192,7 +192,7 @@ class StorageExpressionContext final : public ExpressionContext { */ Value getVertex(const std::string& name = "") const override { UNUSED(name); - LOG(FATAL) << "Unimplemented"; + LOG(DFATAL) << "Unimplemented"; return Value::kNullBadData; } @@ -202,7 +202,7 @@ class StorageExpressionContext final : public ExpressionContext { * @return Value */ Value getEdge() const override { - LOG(FATAL) << "Unimplemented"; + LOG(DFATAL) << "Unimplemented"; return Value::kNullBadData; } diff --git a/src/storage/exec/IndexExprContext.h b/src/storage/exec/IndexExprContext.h index 6dbe7539f9f..a96b231c261 100644 --- a/src/storage/exec/IndexExprContext.h +++ b/src/storage/exec/IndexExprContext.h @@ -63,7 +63,7 @@ class IndexExprContext : public ExpressionContext { StatusOr getVarPropIndex(const std::string &var, const std::string &prop) const override { UNUSED(var), UNUSED(prop); - DLOG(FATAL) << "Unimplemented"; + LOG(DFATAL) << "Unimplemented"; return Status::Error("Unimplemented"); } Value getSrcProp(const std::string &tag, const std::string &prop) const override { @@ -80,7 +80,7 @@ class IndexExprContext : public ExpressionContext { } StatusOr getInputPropIndex(const std::string &prop) const override { UNUSED(prop); - DLOG(FATAL) << "Unimplemented"; + LOG(DFATAL) << "Unimplemented"; return Status::Error("Unimplemented"); } Value getVertex(const std::string &) const override { diff --git a/src/storage/exec/MultiTagNode.h b/src/storage/exec/MultiTagNode.h index 39a60e74aaa..50698469994 100644 --- a/src/storage/exec/MultiTagNode.h +++ b/src/storage/exec/MultiTagNode.h @@ -95,17 +95,17 @@ class MultiTagNode : public IterateNode { } folly::StringPiece key() const override { - LOG(FATAL) << "not allowed to do this"; + LOG(DFATAL) << "not allowed to do this"; return ""; } folly::StringPiece val() const override { - LOG(FATAL) << "not allowed to do this"; + LOG(DFATAL) << "not allowed to do this"; return ""; } RowReader* reader() const override { - LOG(FATAL) << "not allowed to do this"; + LOG(DFATAL) << "not allowed to do this"; return nullptr; } diff --git a/src/storage/exec/QueryUtils.h b/src/storage/exec/QueryUtils.h index 561f538a764..42481acf8d4 100644 --- a/src/storage/exec/QueryUtils.h +++ b/src/storage/exec/QueryUtils.h @@ -163,7 +163,7 @@ class QueryUtils final { } } default: - LOG(FATAL) << "Should not read here"; + LOG(DFATAL) << "Should not read here"; } return Status::Error(folly::stringPrintf("Invalid property %s", prop.name_.c_str())); } @@ -191,7 +191,7 @@ class QueryUtils final { return tag; } default: - LOG(FATAL) << "Should not read here"; + LOG(DFATAL) << "Should not read here"; } return Status::Error(folly::stringPrintf("Invalid property %s", prop.name_.c_str())); } diff --git a/src/storage/exec/StorageIterator.h b/src/storage/exec/StorageIterator.h index 8f384d1c430..e26833b27a4 100644 --- a/src/storage/exec/StorageIterator.h +++ b/src/storage/exec/StorageIterator.h @@ -173,7 +173,8 @@ class SingleEdgeKeyIterator : public SingleEdgeIterator { } RowReader* reader() const override { - LOG(FATAL) << "This iterator should not read value"; + LOG(DFATAL) << "This iterator should not read value"; + return nullptr; } }; diff --git a/src/storage/transaction/ChainProcessorFactory.cpp b/src/storage/transaction/ChainProcessorFactory.cpp index 2f25402c683..ed660d60992 100644 --- a/src/storage/transaction/ChainProcessorFactory.cpp +++ b/src/storage/transaction/ChainProcessorFactory.cpp @@ -61,7 +61,8 @@ ChainBaseProcessor* ChainProcessorFactory::makeProcessor(StorageEnv* env, break; } case ResumeType::UNKNOWN: { - LOG(FATAL) << "ResumeType::UNKNOWN: not supposed run here"; + LOG(DFATAL) << "ResumeType::UNKNOWN: not supposed run here"; + return nullptr; } } break; @@ -79,7 +80,8 @@ ChainBaseProcessor* ChainProcessorFactory::makeProcessor(StorageEnv* env, break; } case ResumeType::UNKNOWN: { - LOG(FATAL) << "ResumeType::UNKNOWN: not supposed run here"; + LOG(DFATAL) << "ResumeType::UNKNOWN: not supposed run here"; + return nullptr; } } break; @@ -97,13 +99,15 @@ ChainBaseProcessor* ChainProcessorFactory::makeProcessor(StorageEnv* env, break; } case ResumeType::UNKNOWN: { - LOG(FATAL) << "ResumeType::UNKNOWN: not supposed run here"; + LOG(DFATAL) << "ResumeType::UNKNOWN: not supposed run here"; + return nullptr; } } break; } case RequestType::UNKNOWN: { - LOG(FATAL) << "RequestType::UNKNOWN: not supposed run here"; + LOG(DFATAL) << "RequestType::UNKNOWN: not supposed run here"; + return nullptr; } } ret->term_ = termId; diff --git a/src/storage/transaction/ConsistUtil.cpp b/src/storage/transaction/ConsistUtil.cpp index a0923d84a96..d1aa3c0a3cb 100644 --- a/src/storage/transaction/ConsistUtil.cpp +++ b/src/storage/transaction/ConsistUtil.cpp @@ -72,7 +72,8 @@ RequestType ConsistUtil::parseType(folly::StringPiece val) { case 'd': return RequestType::DELETE; default: - LOG(FATAL) << "should not happen, identifier is " << identifier; + LOG(DFATAL) << "should not happen, identifier is " << identifier; + return RequestType::UNKNOWN; } }