Skip to content

Commit

Permalink
Minor enhancement about error message (vesoft-inc#1943)
Browse files Browse the repository at this point in the history
* Minor enhancement about error message

* fix conflict

* resolve conflicts

Co-authored-by: Doodle <[email protected]>
Co-authored-by: Sophie <[email protected]>
  • Loading branch information
3 people authored Dec 19, 2022
1 parent 3885f74 commit 4a5ab97
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 38 deletions.
6 changes: 3 additions & 3 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ Status MetaClient::handleResponse(const RESP& resp) {
case nebula::cpp2::ErrorCode::E_FAIL_TO_CONNECT:
return Status::Error("Fail to connect!");
case nebula::cpp2::ErrorCode::E_RPC_FAILURE:
return Status::Error("Rpc failure!");
return Status::Error("Rpc failure, probably timeout!");
case nebula::cpp2::ErrorCode::E_LEADER_CHANGED:
return Status::LeaderChanged("Leader changed!");
case nebula::cpp2::ErrorCode::E_NO_HOSTS:
Expand Down Expand Up @@ -1145,8 +1145,6 @@ Status MetaClient::handleResponse(const RESP& resp) {
return Status::Error("The balancer is running!");
case nebula::cpp2::ErrorCode::E_CONFIG_IMMUTABLE:
return Status::Error("Config immutable!");
case nebula::cpp2::ErrorCode::E_CONFLICT:
return Status::Error("Conflict!");
case nebula::cpp2::ErrorCode::E_INVALID_PARM:
return Status::Error("Invalid param!");
case nebula::cpp2::ErrorCode::E_WRONGCLUSTER:
Expand Down Expand Up @@ -1274,6 +1272,8 @@ Status MetaClient::handleResponse(const RESP& resp) {
return Status::Error("User privilege need basic role!");
case nebula::cpp2::ErrorCode::E_PRIVILEGE_ACTION_INVALID:
return Status::Error("User privilege action invalid!");
case nebula::cpp2::ErrorCode::E_RELATED_FULLTEXT_INDEX_EXISTS:
return Status::Error("Related fulltext index exists, please drop it first");
default:
return Status::Error("Unknown error!");
}
Expand Down
2 changes: 1 addition & 1 deletion src/clients/storage/StorageClientBase-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ folly::Future<StatusOr<Response>> StorageClientBase<ClientType, ClientManagerTyp
invalidLeader(spaceId, partsId);
LOG(ERROR) << "Request to " << host << " failed: " << ex->what();
}
return Status::Error("RPC failure in StorageClient: %s", ex->what());
return Status::Error("RPC failure in StorageClient, probably timeout: %s", ex->what());
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/graph/executor/StorageAccessExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class StorageAccessExecutor : public Executor {

Status handleErrorCode(nebula::cpp2::ErrorCode code, PartitionID partId) const {
switch (code) {
case nebula::cpp2::ErrorCode::E_RPC_FAILURE:
return Status::Error("Storage Error: RPC failure, probably timeout.");
case nebula::cpp2::ErrorCode::E_KEY_NOT_FOUND:
return Status::Error("Storage Error: Vertex or edge not found.");
case nebula::cpp2::ErrorCode::E_DATA_TYPE_MISMATCH: {
Expand Down
1 change: 1 addition & 0 deletions src/interface/common.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ enum ErrorCode {
E_SCHEMA_NAME_EXISTS = -2014, // Schema name already exists
E_RELATED_INDEX_EXISTS = -2015, // There are still indexes related to tag or edge, cannot drop it
E_RELATED_SPACE_EXISTS = -2016, // There are still some space on the host, cannot drop it
E_RELATED_FULLTEXT_INDEX_EXISTS = -2017, // There are still fulltext index on tag/edge

E_STORE_FAILURE = -2021, // Failed to store data
E_STORE_SEGMENT_ILLEGAL = -2022, // Illegal storage segment
Expand Down
4 changes: 2 additions & 2 deletions src/meta/processors/BaseProcessor-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ nebula::cpp2::ErrorCode BaseProcessor<RESP>::indexCheck(
if (it != indexCols.end()) {
LOG(INFO) << "Index conflict, index :" << index.get_index_name()
<< ", column : " << tCol.name;
return nebula::cpp2::ErrorCode::E_CONFLICT;
return nebula::cpp2::ErrorCode::E_RELATED_INDEX_EXISTS;
}
}
}
Expand All @@ -490,7 +490,7 @@ nebula::cpp2::ErrorCode BaseProcessor<RESP>::ftIndexCheck(
std::find_if(cols.begin(), cols.end(), [&](const auto& c) { return c == iCol.name; });
if (it != cols.end()) {
LOG(INFO) << "fulltext index conflict";
return nebula::cpp2::ErrorCode::E_CONFLICT;
return nebula::cpp2::ErrorCode::E_RELATED_FULLTEXT_INDEX_EXISTS;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/meta/processors/BaseProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class BaseProcessor {
* @tparam RESP
* @param items
* @param alterItems
* @return ErrorCode::E_CONFLICT if contains
* @return ErrorCode::E_RELATED_INDEX_EXISTS if contains
*/
nebula::cpp2::ErrorCode indexCheck(const std::vector<cpp2::IndexItem>& items,
const std::vector<cpp2::AlterSchemaItem>& alterItems);
Expand All @@ -362,7 +362,7 @@ class BaseProcessor {
* @tparam RESP
* @param cols
* @param alterItems
* @return nebula::cpp2::ErrorCode
* @return ErrorCode::E_RELATED_FULLTEXT_INDEX_EXISTS if contains
*/
nebula::cpp2::ErrorCode ftIndexCheck(const std::vector<std::string>& cols,
const std::vector<cpp2::AlterSchemaItem>& alterItems);
Expand Down
4 changes: 2 additions & 2 deletions src/meta/processors/index/CreateEdgeIndexProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ void CreateEdgeIndexProcessor::process(const cpp2::CreateEdgeIndexReq& req) {
}
if (fields.size() != columnSet.size()) {
LOG(INFO) << "Conflict field in the edge index.";
handleErrorCode(nebula::cpp2::ErrorCode::E_CONFLICT);
handleErrorCode(nebula::cpp2::ErrorCode::E_INVALID_PARM);
onFinished();
return;
}

// A maximum of 16 columns are allowed in the index
if (columnSet.size() > maxIndexLimit) {
LOG(INFO) << "The number of index columns exceeds maximum limit " << maxIndexLimit;
handleErrorCode(nebula::cpp2::ErrorCode::E_CONFLICT);
handleErrorCode(nebula::cpp2::ErrorCode::E_INVALID_PARM);
onFinished();
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/meta/processors/index/CreateTagIndexProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ void CreateTagIndexProcessor::process(const cpp2::CreateTagIndexReq& req) {
}
if (fields.size() != columnSet.size()) {
LOG(INFO) << "Conflict field in the tag index.";
handleErrorCode(nebula::cpp2::ErrorCode::E_CONFLICT);
handleErrorCode(nebula::cpp2::ErrorCode::E_INVALID_PARM);
onFinished();
return;
}

// A maximum of 16 columns are allowed in the index.
if (columnSet.size() > maxIndexLimit) {
LOG(INFO) << "The number of index columns exceeds maximum limit " << maxIndexLimit;
handleErrorCode(nebula::cpp2::ErrorCode::E_CONFLICT);
handleErrorCode(nebula::cpp2::ErrorCode::E_INVALID_PARM);
onFinished();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/schema/CreateTagProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void CreateTagProcessor::process(const cpp2::CreateTagReq& req) {
LOG(INFO) << "Failed to create tag `" << tagName
<< "': some edge with the same name already exists.";
resp_.id_ref() = to(nebula::value(conflictRet), EntryType::TAG);
handleErrorCode(nebula::cpp2::ErrorCode::E_CONFLICT);
handleErrorCode(nebula::cpp2::ErrorCode::E_SCHEMA_NAME_EXISTS);
onFinished();
return;
} else {
Expand Down
24 changes: 12 additions & 12 deletions src/meta/test/IndexProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ TEST(IndexProcessorTest, TagIndexTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_INVALID_PARM, resp.get_code());
}
{
cpp2::CreateTagIndexReq req;
Expand Down Expand Up @@ -665,7 +665,7 @@ TEST(IndexProcessorTest, EdgeIndexTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_INVALID_PARM, resp.get_code());
}
{
cpp2::CreateEdgeIndexReq req;
Expand Down Expand Up @@ -834,7 +834,7 @@ TEST(IndexProcessorTest, EdgeIndexTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_INVALID_PARM, resp.get_code());
}
{
cpp2::CreateEdgeIndexReq req;
Expand All @@ -846,7 +846,7 @@ TEST(IndexProcessorTest, EdgeIndexTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_INVALID_PARM, resp.get_code());
}
}

Expand Down Expand Up @@ -1001,7 +1001,7 @@ TEST(IndexProcessorTest, IndexCheckAlterEdgeTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_RELATED_INDEX_EXISTS, resp.get_code());
}
// Verify ErrorCode of drop
{
Expand All @@ -1024,7 +1024,7 @@ TEST(IndexProcessorTest, IndexCheckAlterEdgeTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_RELATED_INDEX_EXISTS, resp.get_code());
}
}

Expand Down Expand Up @@ -1128,7 +1128,7 @@ TEST(IndexProcessorTest, IndexCheckAlterTagTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_RELATED_INDEX_EXISTS, resp.get_code());
}
{
cpp2::AlterTagReq req;
Expand All @@ -1149,7 +1149,7 @@ TEST(IndexProcessorTest, IndexCheckAlterTagTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_RELATED_INDEX_EXISTS, resp.get_code());
}
}

Expand Down Expand Up @@ -1997,7 +1997,7 @@ TEST(IndexProcessorTest, AlterWithFTIndexTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_RELATED_FULLTEXT_INDEX_EXISTS, resp.get_code());
}
{
cpp2::AlterTagReq req;
Expand All @@ -2018,7 +2018,7 @@ TEST(IndexProcessorTest, AlterWithFTIndexTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_RELATED_FULLTEXT_INDEX_EXISTS, resp.get_code());
}
{
cpp2::AlterTagReq req;
Expand Down Expand Up @@ -2060,7 +2060,7 @@ TEST(IndexProcessorTest, AlterWithFTIndexTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_RELATED_FULLTEXT_INDEX_EXISTS, resp.get_code());
}
{
cpp2::AlterEdgeReq req;
Expand All @@ -2081,7 +2081,7 @@ TEST(IndexProcessorTest, AlterWithFTIndexTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_RELATED_FULLTEXT_INDEX_EXISTS, resp.get_code());
}
{
cpp2::AlterEdgeReq req;
Expand Down
2 changes: 1 addition & 1 deletion src/meta/test/ProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ TEST(ProcessorTest, CreateEdgeTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
ASSERT_EQ(nebula::cpp2::ErrorCode::E_SCHEMA_NAME_EXISTS, resp.get_code());
}

// Set schema ttl property
Expand Down
24 changes: 12 additions & 12 deletions src/tools/db-dump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ nebula_add_executable(
curl
)

install(
TARGETS
db_dump
PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
DESTINATION
bin
COMPONENT
tool
)
#install(
# TARGETS
# db_dump
# PERMISSIONS
# OWNER_EXECUTE OWNER_WRITE OWNER_READ
# GROUP_EXECUTE GROUP_READ
# WORLD_EXECUTE WORLD_READ
# DESTINATION
# bin
# COMPONENT
# tool
#)

0 comments on commit 4a5ab97

Please sign in to comment.