Skip to content

Commit

Permalink
Cherry pick v3.0.0 0126-2 (#3831)
Browse files Browse the repository at this point in the history
* Add ci for standalone compile and ut. (#3637)

* Add standalone workflow

* remove tmp note

* Add meta v2 thrift obj for sa

* Add tck test

* Fix port and dist tck

* skip some test on sa

* Fix merge

* Fix add host

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

* disable add hosts into zone (#3825)

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

* Check active zone before create space (#3822)

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

* abandon upgrader for old version (#3818)

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

* put dataVersionKey on create space for storage (#3817)

* put dataVersionKey on create space for storage

* address some comments

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

Co-authored-by: Alex Xing <[email protected]>
Co-authored-by: yaphet <[email protected]>
Co-authored-by: hs.zhang <[email protected]>
Co-authored-by: Doodle <[email protected]>
  • Loading branch information
5 people authored Jan 26, 2022
1 parent 7ff28c4 commit 684e11a
Show file tree
Hide file tree
Showing 21 changed files with 485 additions and 55 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,92 @@ jobs:
with:
name: ${{ matrix.os }}-${{ matrix.compiler }}-nebula-test-logs
path: ./build/server_*/logs/

standalone:
name: standalone-build
needs: lint
runs-on: [self-hosted, nebula]
strategy:
fail-fast: false
matrix:
os:
- centos7
compiler:
- gcc-9.3
env:
CCACHE_DIR: /tmp/ccache/nebula/${{ matrix.os }}-${{ matrix.compiler }}
CCACHE_MAXSIZE: 8G
container:
image: vesoft/nebula-dev:${{ matrix.os }}
volumes:
- /tmp/ccache/nebula/${{ matrix.os }}-${{ matrix.compiler }}:/tmp/ccache/nebula/${{ matrix.os }}-${{ matrix.compiler }}
options: --cap-add=SYS_PTRACE
steps:
- uses: webiny/[email protected]
with:
run: sh -c "find . -mindepth 1 -delete"
- uses: actions/checkout@v2
- name: Prepare environment
id: prepare
run: |
[ -d build/ ] && rm -rf build/* || mkdir -p build
make init -C tests
- name: CMake
id: cmake
run: |
case ${{ matrix.compiler }} in
gcc-*)
case ${{ matrix.os }} in
centos7)
# build with Release type
cmake \
-DCMAKE_CXX_COMPILER=$TOOLSET_GCC_DIR/bin/g++ \
-DCMAKE_C_COMPILER=$TOOLSET_GCC_DIR/bin/gcc \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_TESTING=on \
-DENABLE_STANDALONE_VERSION=on \
-GNinja \
-B build
echo "::set-output name=j::10"
;;
esac
;;
esac
- name: Make
run: |
ccache -z
ninja -j $(nproc)
ccache -s
working-directory: build/
- name: CTest
env:
ASAN_OPTIONS: fast_unwind_on_malloc=1
run: ctest -j $(($(nproc)/2+1)) --timeout 400 --output-on-failure
working-directory: build/
timeout-minutes: 20
- name: Setup Cluster
run: |
make standalone-up
working-directory: tests/
timeout-minutes: 60
- name: TCK
run: |
make RM_DIR=false DEBUG=false J=${{ steps.cmake.outputs.j }} standalone-tck
working-directory: tests/
timeout-minutes: 60
- name: LDBC
run: |
make RM_DIR=false DEBUG=false J=${{ steps.cmake.outputs.j }} ldbc
working-directory: tests/
timeout-minutes: 60
- name: Down cluster
run: |
make RM_DIR=false down
working-directory: tests/
timeout-minutes: 2
- name: Upload logs
uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: ${{ matrix.os }}-${{ matrix.compiler }}-nebula-test-logs
path: ./build/server_*/logs/
14 changes: 8 additions & 6 deletions src/clients/storage/StorageClientBase-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,18 @@ void StorageClientBase<ClientType, ClientManagerType>::getResponseImpl(
DCHECK(!!ioThreadPool_);
evb = ioThreadPool_->getEventBase();
}
auto reqPtr = std::make_shared<std::pair<HostAddr, Request>>(std::move(request.first),
std::move(request.second));
folly::via(
evb,
[evb, request = std::move(request), remoteFunc = std::move(remoteFunc), pro, this]() mutable {
auto host = request.first;
[evb, request = std::move(reqPtr), remoteFunc = std::move(remoteFunc), pro, this]() mutable {
auto host = request->first;
auto client = clientsMan_->client(host, evb, false, FLAGS_storage_client_timeout_ms);
auto spaceId = request.second.get_space_id();
auto partsId = getReqPartsId(request.second);
remoteFunc(client.get(), request.second)
auto spaceId = request->second.get_space_id();
auto partsId = getReqPartsId(request->second);
remoteFunc(client.get(), request->second)
.via(evb)
.thenValue([spaceId, pro, this](Response&& resp) mutable {
.thenValue([spaceId, pro, request, this](Response&& resp) mutable {
auto& result = resp.get_result();
for (auto& code : result.get_failed_parts()) {
VLOG(3) << "Failure! Failed part " << code.get_part_id() << ", failed code "
Expand Down
4 changes: 4 additions & 0 deletions src/common/utils/NebulaKeyUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,8 @@ std::string NebulaKeyUtils::dataVersionKey() {
return "\xFF\xFF\xFF\xFF";
}

std::string NebulaKeyUtils::dataVersionValue() {
return "3.0";
}

} // namespace nebula
2 changes: 2 additions & 0 deletions src/common/utils/NebulaKeyUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ class NebulaKeyUtils final {

static std::string dataVersionKey();

static std::string dataVersionValue();

static_assert(sizeof(NebulaKeyType) == sizeof(PartitionID));

private:
Expand Down
1 change: 1 addition & 0 deletions src/daemons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ nebula_add_executable(
$<TARGET_OBJECTS:meta_http_handler>
$<TARGET_OBJECTS:meta_version_man_obj>
$<TARGET_OBJECTS:meta_data_upgrade_obj>
$<TARGET_OBJECTS:meta_v2_thrift_obj>
${storage_meta_deps}
${common_deps}
LIBRARIES
Expand Down
7 changes: 7 additions & 0 deletions src/daemons/StandAloneDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}

// load the time zone data
status = nebula::time::Timezone::init();
if (!status.ok()) {
LOG(ERROR) << status;
return EXIT_FAILURE;
}

// Initialize the global timezone, it's only used for datetime type compute
// won't affect the process timezone.
status = nebula::time::Timezone::initializeGlobalTimezone();
Expand Down
1 change: 0 additions & 1 deletion src/graph/executor/test/StorageServerStub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ std::shared_ptr<GraphStorageLocalServer> instance_ = nullptr;

void GraphStorageLocalServer::setThreadManager(
std::shared_ptr<apache::thrift::concurrency::ThreadManager> threadManager) {
// lock?
threadManager_ = threadManager;
}

Expand Down
2 changes: 1 addition & 1 deletion src/graph/validator/MaintainValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ Status ShowZonesValidator::toPlan() {
}

Status AddHostsIntoZoneValidator::validateImpl() {
return Status::OK();
return Status::SemanticError("Add hosts into zone is unsupported");
}

Status AddHostsIntoZoneValidator::toPlan() {
Expand Down
12 changes: 12 additions & 0 deletions src/kvstore/RocksEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "common/base/Base.h"
#include "common/fs/FileUtils.h"
#include "common/utils/MetaKeyUtils.h"
#include "common/utils/NebulaKeyUtils.h"
#include "kvstore/KVStore.h"

Expand Down Expand Up @@ -124,6 +125,17 @@ RocksEngine::RocksEngine(GraphSpaceID spaceId,
status = rocksdb::DB::Open(options, path, &db);
}
CHECK(status.ok()) << status.ToString();
if (!readonly && spaceId_ != kDefaultSpaceId /* only for storage*/) {
rocksdb::ReadOptions readOptions;
std::string dataVersionValue = "";
status = db->Get(readOptions, NebulaKeyUtils::dataVersionKey(), &dataVersionValue);
if (status.IsNotFound()) {
rocksdb::WriteOptions writeOptions;
status = db->Put(
writeOptions, NebulaKeyUtils::dataVersionKey(), NebulaKeyUtils::dataVersionValue());
}
CHECK(status.ok()) << status.ToString();
}
db_.reset(db);
extractorLen_ = sizeof(PartitionID) + vIdLen;
partsNum_ = allParts().size();
Expand Down
5 changes: 1 addition & 4 deletions src/meta/ActiveHostsMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ nebula::cpp2::ErrorCode ActiveHostsMan::updateHostInfo(kvstore::KVStore* kv,
}
}
// indicate whether any leader info is updated
bool hasUpdate = false;
if (!data.empty()) {
hasUpdate = true;
}
bool hasUpdate = !data.empty();
data.emplace_back(MetaKeyUtils::hostKey(hostAddr.host, hostAddr.port), HostInfo::encodeV2(info));

folly::SharedMutex::WriteHolder wHolder(LockUtils::spaceLock());
Expand Down
12 changes: 10 additions & 2 deletions src/meta/processors/parts/CreateSpaceProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ void CreateSpaceProcessor::process(const cpp2::CreateSpaceReq& req) {
return;
}

int32_t activeZoneSize = 0;
std::unordered_map<std::string, Hosts> zoneHosts;
for (auto& zone : zones) {
auto zoneKey = MetaKeyUtils::zoneKey(zone);
Expand All @@ -193,14 +194,14 @@ void CreateSpaceProcessor::process(const cpp2::CreateSpaceReq& req) {
auto key = MetaKeyUtils::hostKey(host.host, host.port);
auto ret = doGet(key);
if (!nebula::ok(ret)) {
code = nebula::error(ret);
LOG(ERROR) << "Get host " << host << " failed.";
break;
continue;
}

HostInfo info = HostInfo::decode(nebula::value(ret));
if (now - info.lastHBTimeInMilliSec_ <
FLAGS_heartbeat_interval_secs * FLAGS_expired_time_factor * 1000) {
activeZoneSize += 1;
auto hostIter = hostLoading_.find(host);
if (hostIter == hostLoading_.end()) {
hostLoading_[host] = 0;
Expand All @@ -217,6 +218,13 @@ void CreateSpaceProcessor::process(const cpp2::CreateSpaceReq& req) {
zoneHosts[zone] = std::move(hosts);
}

if (replicaFactor > activeZoneSize) {
LOG(ERROR) << "Replication number should less than or equal to active zone number.";
handleErrorCode(nebula::cpp2::ErrorCode::E_ZONE_NOT_ENOUGH);
onFinished();
return;
}

if (code != nebula::cpp2::ErrorCode::SUCCEEDED) {
LOG(ERROR) << "Create space failed";
handleErrorCode(code);
Expand Down
Loading

0 comments on commit 684e11a

Please sign in to comment.