Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick 3.5.0 (0401-0419) #5479

Merged
merged 20 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
find pkg-build/cpack_output -type f \( -iname \*.deb -o -iname \*.rpm -o -iname \*.tar.gz \) -exec bash -c "sha256sum {} > {}.sha256sum.txt" \;
subdir=$(date -u +%Y.%m.%d)
echo "subdir=$subdir" >> $GITHUB_OUTPUT
# - uses: actions/upload-artifact@v1
# - uses: actions/upload-artifact@v3
# with:
# name: ${{ matrix.os }}-nightly
# path: pkg-build/cpack_output
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ jobs:
run: sh -c "find . -mindepth 1 -delete"
- uses: actions/checkout@v3
- id: tag
run: echo tagnum=${{ github.event.inputs.version }}
run: echo tagnum=${{ github.event.inputs.version }} >> $GITHUB_OUTPUT

- id: oss_package
run: |
Expand Down
1 change: 0 additions & 1 deletion resources/gflags.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"clean_wal_interval_secs",
"wal_ttl",
"clean_wal_interval_secs",
"custom_filter_interval_secs",
"accept_partial_success",
"system_memory_high_watermark_ratio",
"num_rows_to_check_memory",
Expand Down
4 changes: 4 additions & 0 deletions src/common/expression/Expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ class Expression {
return false;
}

virtual bool isPropertyExpr() const {
return false;
}

virtual bool isContainerExpr() const {
return false;
}
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 @@ -32,6 +32,10 @@ class PropertyExpression : public Expression {
public:
bool operator==(const Expression& rhs) const override;

bool isPropertyExpr() const override {
return true;
}

const Value& eval(ExpressionContext& ctx) override;

const std::string& ref() const {
Expand Down
21 changes: 14 additions & 7 deletions src/common/expression/RelationalExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const Value& RelationalExpression::eval(ExpressionContext& ctx) {
case Kind::kRelREG: {
if (lhs.isBadNull() || rhs.isBadNull()) {
result_ = Value::kNullBadType;
} else if ((!lhs.isNull() && !lhs.isStr()) || (!rhs.isNull() && !rhs.isStr())) {
} else if ((!lhs.isNull() && !lhs.empty() && !lhs.isStr()) ||
(!rhs.isNull() && !rhs.empty() && !rhs.isStr())) {
result_ = Value::kNullBadType;
} else if (lhs.isStr() && rhs.isStr()) {
try {
Expand Down Expand Up @@ -115,7 +116,8 @@ const Value& RelationalExpression::eval(ExpressionContext& ctx) {
case Kind::kContains: {
if (lhs.isBadNull() || rhs.isBadNull()) {
result_ = Value::kNullBadType;
} else if ((!lhs.isNull() && !lhs.isStr()) || (!rhs.isNull() && !rhs.isStr())) {
} else if ((!lhs.isNull() && !lhs.empty() && !lhs.isStr()) ||
(!rhs.isNull() && !rhs.empty() && !rhs.isStr())) {
result_ = Value::kNullBadType;
} else if (lhs.isStr() && rhs.isStr()) {
result_ = lhs.getStr().size() >= rhs.getStr().size() &&
Expand All @@ -128,7 +130,8 @@ const Value& RelationalExpression::eval(ExpressionContext& ctx) {
case Kind::kNotContains: {
if (lhs.isBadNull() || rhs.isBadNull()) {
result_ = Value::kNullBadType;
} else if ((!lhs.isNull() && !lhs.isStr()) || (!rhs.isNull() && !rhs.isStr())) {
} else if ((!lhs.isNull() && !lhs.empty() && !lhs.isStr()) ||
(!rhs.isNull() && !rhs.empty() && !rhs.isStr())) {
result_ = Value::kNullBadType;
} else if (lhs.isStr() && rhs.isStr()) {
result_ = !(lhs.getStr().size() >= rhs.getStr().size() &&
Expand All @@ -141,7 +144,8 @@ const Value& RelationalExpression::eval(ExpressionContext& ctx) {
case Kind::kStartsWith: {
if (lhs.isBadNull() || rhs.isBadNull()) {
result_ = Value::kNullBadType;
} else if ((!lhs.isNull() && !lhs.isStr()) || (!rhs.isNull() && !rhs.isStr())) {
} else if ((!lhs.isNull() && !lhs.empty() && !lhs.isStr()) ||
(!rhs.isNull() && !rhs.empty() && !rhs.isStr())) {
result_ = Value::kNullBadType;
} else if (lhs.isStr() && rhs.isStr()) {
result_ =
Expand All @@ -154,7 +158,8 @@ const Value& RelationalExpression::eval(ExpressionContext& ctx) {
case Kind::kNotStartsWith: {
if (lhs.isBadNull() || rhs.isBadNull()) {
result_ = Value::kNullBadType;
} else if ((!lhs.isNull() && !lhs.isStr()) || (!rhs.isNull() && !rhs.isStr())) {
} else if ((!lhs.isNull() && !lhs.empty() && !lhs.isStr()) ||
(!rhs.isNull() && !rhs.empty() && !rhs.isStr())) {
result_ = Value::kNullBadType;
} else if (lhs.isStr() && rhs.isStr()) {
result_ =
Expand All @@ -167,7 +172,8 @@ const Value& RelationalExpression::eval(ExpressionContext& ctx) {
case Kind::kEndsWith: {
if (lhs.isBadNull() || rhs.isBadNull()) {
result_ = Value::kNullBadType;
} else if ((!lhs.isNull() && !lhs.isStr()) || (!rhs.isNull() && !rhs.isStr())) {
} else if ((!lhs.isNull() && !lhs.empty() && !lhs.isStr()) ||
(!rhs.isNull() && !rhs.empty() && !rhs.isStr())) {
result_ = Value::kNullBadType;
} else if (lhs.isStr() && rhs.isStr()) {
result_ =
Expand All @@ -182,7 +188,8 @@ const Value& RelationalExpression::eval(ExpressionContext& ctx) {
case Kind::kNotEndsWith: {
if (lhs.isBadNull() || rhs.isBadNull()) {
result_ = Value::kNullBadType;
} else if ((!lhs.isNull() && !lhs.isStr()) || (!rhs.isNull() && !rhs.isStr())) {
} else if ((!lhs.isNull() && !lhs.empty() && !lhs.isStr()) ||
(!rhs.isNull() && !rhs.empty() && !rhs.isStr())) {
result_ = Value::kNullBadType;
} else if (lhs.isStr() && rhs.isStr()) {
result_ = !(lhs.getStr().size() >= rhs.getStr().size() &&
Expand Down
9 changes: 8 additions & 1 deletion src/common/function/FunctionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@ FunctionManager::FunctionManager() {
// More information of encoding could be found in `NebulaKeyUtils.h`
auto &attr = functions_["none_direct_dst"];
attr.minArity_ = 1;
attr.maxArity_ = 1;
attr.maxArity_ = 2;
attr.isAlwaysPure_ = true;
attr.body_ = [](const auto &args) -> Value {
switch (args[0].get().type()) {
Expand All @@ -2035,6 +2035,13 @@ FunctionManager::FunctionManager() {
case Value::Type::LIST: {
const auto &listVal = args[0].get().getList().values;
if (listVal.empty()) {
if (args.size() == 2) {
if (args[1].get().type() == Value::Type::VERTEX) {
const auto &v = args[1].get().getVertex();
return v.vid;
}
return Value::kNullBadType;
}
return Value::kNullBadType;
}
auto &lastVal = listVal.back();
Expand Down
1 change: 0 additions & 1 deletion src/common/meta/GflagsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ std::unordered_map<std::string, std::pair<cpp2::ConfigMode, bool>> GflagsManager
{"meta_client_retry_times", {cpp2::ConfigMode::MUTABLE, false}},
{"wal_ttl", {cpp2::ConfigMode::MUTABLE, false}},
{"clean_wal_interval_secs", {cpp2::ConfigMode::MUTABLE, false}},
{"custom_filter_interval_secs", {cpp2::ConfigMode::MUTABLE, false}},
{"accept_partial_success", {cpp2::ConfigMode::MUTABLE, false}},

{"rocksdb_db_options", {cpp2::ConfigMode::MUTABLE, true}},
Expand Down
20 changes: 20 additions & 0 deletions src/common/meta/SchemaManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,33 @@ class SchemaManager {

virtual StatusOr<int32_t> getPartsNum(GraphSpaceID space) = 0;

std::shared_ptr<const NebulaSchemaProvider> getTagSchema(GraphSpaceID space,
const std::string& tag,
SchemaVer ver = -1) {
auto tagId = toTagID(space, tag);
if (!tagId.ok()) {
return nullptr;
}
return getTagSchema(space, tagId.value(), ver);
}

virtual std::shared_ptr<const NebulaSchemaProvider> getTagSchema(GraphSpaceID space,
TagID tag,
SchemaVer ver = -1) = 0;

// Returns a negative number when the schema does not exist
virtual StatusOr<SchemaVer> getLatestTagSchemaVersion(GraphSpaceID space, TagID tag) = 0;

std::shared_ptr<const NebulaSchemaProvider> getEdgeSchema(GraphSpaceID space,
const std::string& edge,
SchemaVer ver = -1) {
auto edgeType = toEdgeType(space, edge);
if (!edgeType.ok()) {
return nullptr;
}
return getEdgeSchema(space, edgeType.value(), ver);
}

virtual std::shared_ptr<const NebulaSchemaProvider> getEdgeSchema(GraphSpaceID space,
EdgeType edge,
SchemaVer ver = -1) = 0;
Expand Down
42 changes: 40 additions & 2 deletions src/common/session/SessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef COMMON_SESSION_SESSIONMANAGER_H_
#define COMMON_SESSION_SESSIONMANAGER_H_

#include <folly/RWSpinLock.h>
#include <folly/concurrency/ConcurrentHashMap.h>

#include "clients/meta/MetaClient.h"
Expand All @@ -23,7 +24,7 @@ namespace nebula {

class SessionCount {
private:
std::atomic<int32_t> count_ = 1;
std::atomic<int32_t> count_{0};

public:
int fetch_add(int step) {
Expand Down Expand Up @@ -75,11 +76,48 @@ class SessionManager {
protected:
using SessionPtr = std::shared_ptr<SessionType>;
using SessionCountPtr = std::shared_ptr<SessionCount>;

// Get session count pointer according to key
SessionCountPtr sessionCnt(const std::string& key) {
folly::RWSpinLock::ReadHolder rh(&sessCntLock_);
auto iter = userIpSessionCount_.find(key);
if (iter != userIpSessionCount_.end()) {
return iter->second;
}
return nullptr;
}

// add sessionCount
void addSessionCount(std::string& key) {
auto sessCntPtr = sessionCnt(key);
if (!sessCntPtr) {
folly::RWSpinLock::WriteHolder wh(&sessCntLock_);
auto iter = userIpSessionCount_.emplace(key, std::make_shared<SessionCount>());
sessCntPtr = iter.first->second;
}
sessCntPtr->fetch_add(1);
}

// sub sessionCount
void subSessionCount(std::string& key) {
auto countFindPtr = sessionCnt(key);
if (countFindPtr) {
auto count = countFindPtr->fetch_sub(1);
if (count == 1) {
folly::RWSpinLock::WriteHolder wh(&sessCntLock_);
userIpSessionCount_.erase(key);
}
}
}

folly::ConcurrentHashMap<SessionID, SessionPtr> activeSessions_;
folly::ConcurrentHashMap<std::string, SessionCountPtr> userIpSessionCount_;
std::unique_ptr<thread::GenericWorker> scavenger_;
meta::MetaClient* metaClient_{nullptr};
HostAddr myAddr_;

private:
folly::RWSpinLock sessCntLock_;
std::unordered_map<std::string, SessionCountPtr> userIpSessionCount_;
};

} // namespace nebula
Expand Down
2 changes: 2 additions & 0 deletions src/graph/context/ast/CypherAstContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct EdgeInfo {
MatchEdge::Direction direction{MatchEdge::Direction::OUT_EDGE};
std::vector<std::string> types;
std::string alias;
// use for construct path struct
std::string innerAlias;
const MapExpression* props{nullptr};
Expression* filter{nullptr};
};
Expand Down
3 changes: 3 additions & 0 deletions src/graph/executor/algo/BatchShortestPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace graph {
folly::Future<Status> BatchShortestPath::execute(const HashSet& startVids,
const HashSet& endVids,
DataSet* result) {
if (maxStep_ == 0) {
return Status::OK();
}
// MemoryTrackerVerified
size_t rowSize = init(startVids, endVids);
std::vector<folly::Future<Status>> futures;
Expand Down
1 change: 1 addition & 0 deletions src/graph/executor/algo/CartesianProductExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "graph/executor/algo/CartesianProductExecutor.h"

#include "graph/planner/plan/Algo.h"
#include "graph/planner/plan/Query.h"

namespace nebula {
namespace graph {
Expand Down
3 changes: 3 additions & 0 deletions src/graph/executor/algo/SingleShortestPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ namespace graph {
folly::Future<Status> SingleShortestPath::execute(const HashSet& startVids,
const HashSet& endVids,
DataSet* result) {
if (maxStep_ == 0) {
return Status::OK();
}
size_t rowSize = startVids.size() * endVids.size();
init(startVids, endVids, rowSize);
std::vector<folly::Future<Status>> futures;
Expand Down
Loading