Skip to content

Commit

Permalink
Cherry pick 3.2.0 (0712-0713) (#4408)
Browse files Browse the repository at this point in the history
* Fix web service crash(issue:#4398) (#4405)

* when we use flags put interface, but we does not specify the body.
* The service will be crashed.
For example:
curl -X PUT xxx.xxx.xxx.xxxx:19559/flags

* Fix delete vertex or edge, the storage crashed.(#4397) (#4406)

* When our space has tag index or edge index.
* When delete vertex or edge, we specify one vid more than our defined
  in space.
* The sotrage will be crashed.

Solution:
1. Add vid valid verfication.

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

* Release with separate debug info in ELF format (#4400)

Co-authored-by: Milittle <[email protected]>
Co-authored-by: dutor <[email protected]>
  • Loading branch information
3 people authored Jul 13, 2022
1 parent 518bfe3 commit 324d134
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
10 changes: 9 additions & 1 deletion package/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function _extra_release_variables {
package_one="OFF"
enable_compressed_debug_info="ON"
dump_symbols="OFF"
fi
fi
}

_default_release_variables
Expand Down Expand Up @@ -227,7 +227,15 @@ function dump_syms {
tmp=${pack#nebula-graph}
ver=${tmp%.*}

hash objcopy &> /dev/null || {
echo "'objcopy' is not installed"
exit 1
}

for bin in nebula-graphd nebula-storaged nebula-metad; do
# Create separate debuginfo for GDB
objcopy --only-keep-debug ${build_dir}/bin/${bin} ${syms_dir}/${bin}${ver}.debug
# Create separate debuginfo for breakpad
if ! (${dump_syms} ${build_dir}/bin/${bin} > ${syms_dir}/${bin}${ver}.sym); then
echo ">>> dump ${bin} symbols failed: $?. <<<"
exit 1
Expand Down
8 changes: 8 additions & 0 deletions src/storage/mutate/DeleteEdgesProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ void DeleteEdgesProcessor::process(const cpp2::DeleteEdgesRequest& req) {

nebula::cpp2::ErrorCode err = nebula::cpp2::ErrorCode::SUCCEEDED;
for (const auto& edgeKey : part.second) {
if (!NebulaKeyUtils::isValidVidLen(
spaceVidLen_, edgeKey.src_ref()->getStr(), edgeKey.dst_ref()->getStr())) {
LOG(ERROR) << "Space " << spaceId_ << " vertex length invalid, "
<< "space vid len: " << spaceVidLen_ << ", edge srcVid: " << *edgeKey.src_ref()
<< " dstVid: " << *edgeKey.dst_ref();
err = nebula::cpp2::ErrorCode::E_INVALID_VID;
break;
}
auto l = std::make_tuple(spaceId_,
partId,
edgeKey.src_ref()->getStr(),
Expand Down
6 changes: 6 additions & 0 deletions src/storage/mutate/DeleteVerticesProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ ErrorOr<nebula::cpp2::ErrorCode, std::string> DeleteVerticesProcessor::deleteVer
target.reserve(vertices.size());
std::unique_ptr<kvstore::BatchHolder> batchHolder = std::make_unique<kvstore::BatchHolder>();
for (auto& vertex : vertices) {
if (!NebulaKeyUtils::isValidVidLen(spaceVidLen_, vertex.getStr())) {
LOG(ERROR) << "Space " << spaceId_ << ", vertex length invalid, "
<< " space vid len: " << spaceVidLen_ << ", vid is " << vertex;
auto code = nebula::cpp2::ErrorCode::E_INVALID_VID;
return code;
}
batchHolder->remove(NebulaKeyUtils::vertexKey(spaceVidLen_, partId, vertex.getStr()));
auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen_, partId, vertex.getStr());
std::unique_ptr<kvstore::KVIterator> iter;
Expand Down
11 changes: 8 additions & 3 deletions src/webservice/SetFlagsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ void SetFlagsHandler::onBody(std::unique_ptr<folly::IOBuf> body) noexcept {
void SetFlagsHandler::onEOM() noexcept {
folly::dynamic flags;
try {
std::string body = body_->moveToFbString().toStdString();
flags = folly::parseJson(body);
if (flags.empty()) {
if (!body_) {
LOG(ERROR) << "Got an empty body";
err_ = HttpCode::E_UNPROCESSABLE;
} else {
std::string body = body_->moveToFbString().toStdString();
flags = folly::parseJson(body);
if (flags.empty()) {
err_ = HttpCode::E_UNPROCESSABLE;
}
}
} catch (const std::exception &e) {
LOG(ERROR) << "Fail to update flags: " << e.what();
Expand Down

0 comments on commit 324d134

Please sign in to comment.