Skip to content

Commit

Permalink
Cherry pick v3.0.0 (0117-0124) (#3820)
Browse files Browse the repository at this point in the history
* drop host only when it registe heartbeat (#3739)

* Fix race of create tag and edge (#3735)

* fix rece

* polish

* fix review

* Add version for `show hosts` (#3702)

* version

* tck

* pytest

* pytest

Co-authored-by: cpw <[email protected]>

* Update client version to v3.0.0 (#3741)

* Update python package name to v3

* Update client version white list

* Update go mod to v3

* Change the python package name used in tests

* Update client version white list

* Fix create fulltext index failed (#3747)

* fix bug: the same tagId/edgetype under different spaces, failed to create fulltext indexes

* fix bug: the same tagId/edgetype under different spaces, failed to create fulltext indexes

* fix writternBy delete by optimizer (#3746)

* fix bugs

* add tck features

* style

Co-authored-by: cpw <[email protected]>

* fix with & optimizer rule error (#3736)

* fix error

* fix collapseProjectRule

Co-authored-by: cpw <[email protected]>

* fix upgrade bug (#3772)

Co-authored-by: Sophie <[email protected]>

* fix 3727 (#3737)

Co-authored-by: Doodle <[email protected]>

* Balance fix (#3668)

* fix core balance in zone removing the only host in zone

* fix balance plan that make redundant part

* fix deadlock when runInternal and finish callback called in the same thread

* fix transleader return TERM_OUT_OF_DATE

* continue running balance task from last status

* fix deadlock when removing part

Co-authored-by: Sophie <[email protected]>

* Add snapshot for prefix iterate. (#3717)

* Add snapshot for prefix iterate.

* Add header comment

* Add happy test

* Fix lint

* Modify engine snap argument position

* Fix other subclass

* Fix code

Co-authored-by: yaphet <[email protected]>
Co-authored-by: Sophie <[email protected]>
Co-authored-by: Doodle <[email protected]>

* suppress undesired ASAN error (#3705)

* suppress undesired error

* fix unstable test case

* fix upgrade (#3787)

Co-authored-by: Doodle <[email protected]>

* Create CODEOWNERS (#3770)

Confirm with sophie.xie

* disable data balance (#3756)

Co-authored-by: Sophie <[email protected]>

* Fix iterator with snapshot(parameter position) (#3785)

Co-authored-by: Harris.Chu <[email protected]>
Co-authored-by: Sophie <[email protected]>

Co-authored-by: yaphet <[email protected]>
Co-authored-by: jakevin <[email protected]>
Co-authored-by: cpw <[email protected]>
Co-authored-by: Yichen Wang <[email protected]>
Co-authored-by: panda-sheep <[email protected]>
Co-authored-by: endy.li <[email protected]>
Co-authored-by: jimingquan <[email protected]>
Co-authored-by: hs.zhang <[email protected]>
Co-authored-by: Doodle <[email protected]>
Co-authored-by: liwenhui-soul <[email protected]>
Co-authored-by: Alex Xing <[email protected]>
Co-authored-by: Harris.Chu <[email protected]>
  • Loading branch information
13 people authored Jan 26, 2022
1 parent e7863df commit caf0815
Show file tree
Hide file tree
Showing 95 changed files with 1,048 additions and 268 deletions.
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Require an approved review in PRs including files with a designated code owner.
/conf/ @vesoft-inc/tech-committee-reviewers
/src/kvstore/raftex/ @critical27 @sherman-the-tank
/cmake/ @sherman-the-tank @yixinglu
*.thrift @vesoft-inc/tech-committee-reviewers
*.yy @CPWstatic
2 changes: 1 addition & 1 deletion cmake/ThriftGenerate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ add_custom_command(
--gen "js:node:"
--gen "csharp"
--gen "java:hashcode"
--gen "go:thrift_import=github.com/facebook/fbthrift/thrift/lib/go/thrift,package_prefix=github.com/vesoft-inc/nebula-go/v2/,use_context"
--gen "go:thrift_import=github.com/facebook/fbthrift/thrift/lib/go/thrift,package_prefix=github.com/vesoft-inc/nebula-go/v3/,use_context"
-o "." "${file_path}/${file_name}.thrift"
COMMAND
mkdir -p "./gen-rust/${file_name}"
Expand Down
2 changes: 1 addition & 1 deletion src/codec/RowReaderV2.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RowReaderV2 : public RowReader {
FRIEND_TEST(ScanEdgePropBench, ProcessEdgeProps);

public:
virtual ~RowReaderV2() = default;
~RowReaderV2() override = default;

Value getValueByName(const std::string& prop) const noexcept override;
Value getValueByIndex(const int64_t index) const noexcept override;
Expand Down
4 changes: 3 additions & 1 deletion src/common/base/SanitizerOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const char* __asan_default_options() {
"fast_unwind_on_malloc=0 \n"
"detect_stack_use_after_return=1 \n"
"alloc_dealloc_mismatch=1 \n"
"new_delete_type_mismatch=1 \n"
// todo(doodle): Reopen when https://github.com/vesoft-inc/nebula/issues/3690
// addressed throughly
"new_delete_type_mismatch=0 \n"
"strict_init_order=1 \n"
"intercept_tls_get_addr=1 \n"
"symbolize_inline_frames=1 \n"
Expand Down
4 changes: 4 additions & 0 deletions src/common/expression/PropertyExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ class LabelTagPropertyExpression final : public PropertyExpression {
return label_;
}

void setLabel(Expression* label) {
label_ = label;
}

private:
LabelTagPropertyExpression(ObjectPool* pool,
Expression* label = nullptr,
Expand Down
6 changes: 4 additions & 2 deletions src/graph/executor/admin/ShowHostsExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ folly::Future<Status> ShowHostsExecutor::showHosts() {
"Status",
"Leader count",
"Leader distribution",
"Partition distribution"});
"Partition distribution",
"Version"});

std::map<std::string, int64_t> leaderPartsCount;
std::map<std::string, int64_t> allPartsCount;
Expand Down Expand Up @@ -82,6 +83,7 @@ folly::Future<Status> ShowHostsExecutor::showHosts() {
r.emplace_back(leaderCount);
r.emplace_back(leaders.str());
r.emplace_back(parts.str());
r.emplace_back(host.version_ref().has_value() ? Value(*host.version_ref()) : Value());
v.emplace_back(std::move(r));
} // row loop
{
Expand Down Expand Up @@ -148,7 +150,7 @@ folly::Future<Status> ShowHostsExecutor::showHosts() {
LOG(ERROR) << resp.status();
return resp.status();
}
auto value = std::move(resp).value();
auto value = std::forward<decltype(resp)>(resp).value();
if (type == meta::cpp2::ListHostType::ALLOC) {
return finish(makeTraditionalResult(value));
}
Expand Down
1 change: 1 addition & 0 deletions src/graph/optimizer/OptGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void OptGroup::addGroupNode(OptGroupNode *groupNode) {
DCHECK(groupNode != nullptr);
DCHECK(groupNode->group() == this);
groupNodes_.emplace_back(groupNode);
groupNode->node()->updateSymbols();
}

OptGroupNode *OptGroup::makeGroupNode(PlanNode *node) {
Expand Down
2 changes: 1 addition & 1 deletion src/graph/planner/match/MatchPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace graph {
class MatchPlanner final : public Planner {
public:
static std::unique_ptr<MatchPlanner> make() {
return std::unique_ptr<MatchPlanner>(new MatchPlanner());
return std::make_unique<MatchPlanner>();
}

static bool match(AstContext* astCtx);
Expand Down
9 changes: 9 additions & 0 deletions src/graph/planner/plan/PlanNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,15 @@ void PlanNode::releaseSymbols() {
}
}

void PlanNode::updateSymbols() {
auto symTbl = qctx_->symTable();
for (auto out : outputVars_) {
if (out != nullptr) {
symTbl->updateWrittenBy(out->name, out->name, this);
}
}
}

std::ostream& operator<<(std::ostream& os, PlanNode::Kind kind) {
os << PlanNode::toString(kind);
return os;
Expand Down
2 changes: 2 additions & 0 deletions src/graph/planner/plan/PlanNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ class PlanNode {

void releaseSymbols();

void updateSymbols();

static const char* toString(Kind kind);
std::string toString() const;

Expand Down
2 changes: 1 addition & 1 deletion src/graph/service/GraphFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ DEFINE_bool(enable_optimizer, false, "Whether to enable optimizer");
DEFINE_uint32(ft_request_retry_times, 3, "Retry times if fulltext request failed");
DEFINE_bool(enable_client_white_list, true, "Turn on/off the client white list.");
DEFINE_string(client_white_list,
nebula::getOriginVersion() + ":2.5.0:2.5.1:2.6.0",
nebula::getOriginVersion() + ":3.0.0",
"A white list for different client versions, separate with colon.");

#endif
Expand Down
2 changes: 1 addition & 1 deletion src/graph/service/test/StandAloneTestGraphFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
DEFINE_uint32(ft_request_retry_times, 3, "Retry times if fulltext request failed");
DEFINE_bool(enable_client_white_list, true, "Turn on/off the client white list.");
DEFINE_string(client_white_list,
nebula::getOriginVersion() + ":2.5.0:2.5.1:2.6.0",
nebula::getOriginVersion() + ":3.0.0",
"A white list for different client versions, separate with colon.");
24 changes: 15 additions & 9 deletions src/graph/util/ExpressionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,24 @@ bool ExpressionUtils::isEvaluableExpr(const Expression *expr, const QueryContext
}

// rewrite Attribute to LabelTagProp
Expression *ExpressionUtils::rewriteAttr2LabelTagProp(const Expression *expr) {
Expression *ExpressionUtils::rewriteAttr2LabelTagProp(
const Expression *expr, const std::unordered_map<std::string, AliasType> &aliasTypeMap) {
ObjectPool *pool = expr->getObjPool();

auto matcher = [](const Expression *e) -> bool {
if (e->kind() == Expression::Kind::kAttribute) {
auto attrExpr = static_cast<const AttributeExpression *>(e);
if (attrExpr->left()->kind() == Expression::Kind::kLabelAttribute &&
attrExpr->right()->kind() == Expression::Kind::kConstant) {
return true;
}
auto matcher = [&aliasTypeMap](const Expression *e) -> bool {
if (e->kind() != Expression::Kind::kAttribute) {
return false;
}
return false;
auto attrExpr = static_cast<const AttributeExpression *>(e);
if (attrExpr->left()->kind() != Expression::Kind::kLabelAttribute) {
return false;
}
auto label = static_cast<const LabelAttributeExpression *>(attrExpr->left())->left()->name();
auto iter = aliasTypeMap.find(label);
if (iter == aliasTypeMap.end() || iter->second != AliasType::kNode) {
return false;
}
return true;
};

auto rewriter = [pool](const Expression *e) -> Expression * {
Expand Down
5 changes: 3 additions & 2 deletions src/graph/util/ExpressionUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
#include "common/expression/PropertyExpression.h"
#include "common/expression/TypeCastingExpression.h"
#include "common/expression/UnaryExpression.h"
#include "graph/context/ast/CypherAstContext.h"
#include "graph/visitor/EvaluableExprVisitor.h"
#include "graph/visitor/FindVisitor.h"
#include "graph/visitor/RewriteVisitor.h"

namespace nebula {
class ObjectPool;
namespace graph {

class ExpressionUtils {
public:
explicit ExpressionUtils(...) = delete;
Expand Down Expand Up @@ -55,7 +55,8 @@ class ExpressionUtils {

static bool isEvaluableExpr(const Expression* expr, const QueryContext* qctx = nullptr);

static Expression* rewriteAttr2LabelTagProp(const Expression* expr);
static Expression* rewriteAttr2LabelTagProp(
const Expression* expr, const std::unordered_map<std::string, AliasType>& aliasTypeMap);

static Expression* rewriteLabelAttr2TagProp(const Expression* expr);

Expand Down
4 changes: 4 additions & 0 deletions src/graph/validator/AdminJobValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ namespace nebula {
namespace graph {

Status AdminJobValidator::validateImpl() {
if (sentence_->getCmd() == meta::cpp2::AdminCmd::DATA_BALANCE ||
sentence_->getCmd() == meta::cpp2::AdminCmd::ZONE_BALANCE) {
return Status::SemanticError("Data balance not support");
}
if (sentence_->getOp() == meta::cpp2::AdminJobOp::ADD) {
auto cmd = sentence_->getCmd();
if (requireSpace()) {
Expand Down
11 changes: 7 additions & 4 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ Status MatchValidator::validateFilter(const Expression *filter,
auto transformRes = ExpressionUtils::filterTransform(filter);
NG_RETURN_IF_ERROR(transformRes);
// rewrite Attribute to LabelTagProperty
whereClauseCtx.filter = ExpressionUtils::rewriteAttr2LabelTagProp(transformRes.value());
whereClauseCtx.filter = ExpressionUtils::rewriteAttr2LabelTagProp(
transformRes.value(), whereClauseCtx.aliasesAvailable);

auto typeStatus = deduceExprType(whereClauseCtx.filter);
NG_RETURN_IF_ERROR(typeStatus);
Expand Down Expand Up @@ -383,7 +384,8 @@ Status MatchValidator::validateReturn(MatchReturn *ret,
ExpressionUtils::hasAny(column->expr(), {Expression::Kind::kAggregate})) {
retClauseCtx.yield->hasAgg_ = true;
}
column->setExpr(ExpressionUtils::rewriteAttr2LabelTagProp(column->expr()));
column->setExpr(ExpressionUtils::rewriteAttr2LabelTagProp(
column->expr(), retClauseCtx.yield->aliasesAvailable));
exprs.push_back(column->expr());
columns->addColumn(column->clone().release());
}
Expand Down Expand Up @@ -459,7 +461,8 @@ Status MatchValidator::validateWith(const WithClause *with,
}
if (with->returnItems()->columns()) {
for (auto *column : with->returnItems()->columns()->columns()) {
column->setExpr(ExpressionUtils::rewriteAttr2LabelTagProp(column->expr()));
column->setExpr(ExpressionUtils::rewriteAttr2LabelTagProp(
column->expr(), withClauseCtx.yield->aliasesAvailable));
columns->addColumn(column->clone().release());
}
}
Expand Down Expand Up @@ -819,7 +822,7 @@ Status MatchValidator::checkAlias(
auto name = static_cast<const VariablePropertyExpression *>(labelExpr)->prop();
auto res = getAliasType(aliasesAvailable, name);
NG_RETURN_IF_ERROR(res);
if (res.value() != AliasType::kNode) {
if (res.value() == AliasType::kEdge || res.value() == AliasType::kPath) {
return Status::SemanticError("The type of `%s' should be tag", name.c_str());
}
return Status::OK();
Expand Down
12 changes: 12 additions & 0 deletions src/graph/visitor/RewriteVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,18 @@ void RewriteVisitor::visit(PathBuildExpression *expr) {
}
}

void RewriteVisitor::visit(LabelTagPropertyExpression *expr) {
if (!care(expr->kind())) {
return;
}
auto label = expr->label();
if (matcher_(label)) {
expr->setLabel(rewriter_(label));
} else {
label->accept(this);
}
}

void RewriteVisitor::visit(AttributeExpression *expr) {
if (!care(expr->kind())) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/graph/visitor/RewriteVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ class RewriteVisitor final : public ExprVisitorImpl {
void visit(RelationalExpression*) override;
void visit(SubscriptExpression*) override;
void visit(PathBuildExpression*) override;
void visit(LabelTagPropertyExpression*) override;
void visit(SubscriptRangeExpression*) override;
void visit(ConstantExpression*) override {}
void visit(LabelExpression*) override {}
void visit(UUIDExpression*) override {}
void visit(LabelAttributeExpression*) override {}
void visit(LabelTagPropertyExpression*) override {}
void visit(VariableExpression*) override {}
void visit(VersionedVariableExpression*) override {}
void visit(TagPropertyExpression*) override {}
Expand Down
4 changes: 2 additions & 2 deletions src/interface/common.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace java com.vesoft.nebula
namespace go nebula
namespace js nebula
namespace csharp nebula
namespace py nebula2.common
namespace py nebula3.common

cpp_include "common/thrift/ThriftTypes.h"
cpp_include "common/datatypes/DateOps-inl.h"
Expand All @@ -34,7 +34,7 @@ cpp_include "common/datatypes/DurationOps-inl.h"
*
*/

const binary (cpp.type = "char const *") version = "2.6.0"
const binary (cpp.type = "char const *") version = "3.0.0"

typedef i64 (cpp.type = "nebula::ClusterID") ClusterID
typedef i32 (cpp.type = "nebula::GraphSpaceID") GraphSpaceID
Expand Down
2 changes: 1 addition & 1 deletion src/interface/graph.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace java com.vesoft.nebula.graph
namespace go nebula.graph
namespace js nebula.graph
namespace csharp nebula.graph
namespace py nebula2.graph
namespace py nebula3.graph

include "common.thrift"

Expand Down
2 changes: 1 addition & 1 deletion src/interface/meta.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace java com.vesoft.nebula.meta
namespace go nebula.meta
namespace js nebula.meta
namespace csharp nebula.meta
namespace py nebula2.meta
namespace py nebula3.meta

include "common.thrift"

Expand Down
2 changes: 1 addition & 1 deletion src/interface/storage.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace java com.vesoft.nebula.storage
namespace go nebula.storage
namespace csharp nebula.storage
namespace js nebula.storage
namespace py nebula2.storage
namespace py nebula3.storage

include "common.thrift"
include "meta.thrift"
Expand Down
24 changes: 22 additions & 2 deletions src/kvstore/KVEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ class KVEngine {
bool sync,
bool wait) = 0;

/**
* @brief Get the Snapshot from kv engine.
*
* @return const void* snapshot pointer.
*/
virtual const void* GetSnapshot() = 0;
/**
* @brief Release snapshot from kv engine.
*
* @param snapshot
*/
virtual void ReleaseSnapshot(const void* snapshot) = 0;
// Read a single key
virtual nebula::cpp2::ErrorCode get(const std::string& key, std::string* value) = 0;

Expand All @@ -62,9 +74,17 @@ class KVEngine {
const std::string& end,
std::unique_ptr<KVIterator>* iter) = 0;

// Get all results with 'prefix' str as prefix.
/**
* @brief Get all results with 'prefix' str as prefix.
*
* @param prefix Prefix string.
* @param snapshot Snapshot from kv engine. nullptr means no snapshot.
* @param iter Iterator for this prefix range.
* @return nebula::cpp2::ErrorCode
*/
virtual nebula::cpp2::ErrorCode prefix(const std::string& prefix,
std::unique_ptr<KVIterator>* iter) = 0;
std::unique_ptr<KVIterator>* iter,
const void* snapshot = nullptr) = 0;

// Get all results with 'prefix' str as prefix starting form 'start'
virtual nebula::cpp2::ErrorCode rangeWithPrefix(const std::string& start,
Expand Down
Loading

0 comments on commit caf0815

Please sign in to comment.