Skip to content

Commit 805c90e

Browse files
committed
add etcd meta store impl
Committed-by: [email protected] from Dev container Committed-by: [email protected] from Dev container code refactor Committed-by: [email protected] from Dev container Committed-by: [email protected] from Dev container Committed-by: xiaolei.zl from Dev container
1 parent 8abd636 commit 805c90e

27 files changed

+716
-39
lines changed

.github/workflows/interactive.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
git submodule update --init
5656
cd ${GITHUB_WORKSPACE}/flex
5757
mkdir build && cd build
58-
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/graphscope -DCMAKE_BUILD_TYPE=DEBUG && sudo make -j$(nproc)
58+
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/graphscope -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_ETCD_METASTORE=ON && sudo make -j$(nproc)
5959
# package the build artifacts
6060
cd .. && tar -zcf build.tar.gz build
6161
@@ -186,6 +186,22 @@ jobs:
186186
cd ${GITHUB_WORKSPACE}/flex/tests/hqps
187187
bash hqps_admin_test.sh ${TMP_INTERACTIVE_WORKSPACE} ./interactive_config_test.yaml ${GS_TEST_DIR}
188188
189+
# test admin service with etcd metastore
190+
GOOGLE_URL=https://storage.googleapis.com/etcd
191+
GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
192+
DOWNLOAD_URL=${GOOGLE_URL}
193+
rm -rf /tmp/etcd-download-test && mkdir -p /tmp/etcd-download-test
194+
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
195+
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test
196+
/tmp/etcd-download-test/etcd &
197+
sleep 3
198+
199+
cd ${GITHUB_WORKSPACE}/flex/tests/hqps
200+
python3 -c 'import yaml;f=open("./interactive_config_test.yaml");y=yaml.safe_load(f);y["compute_engine"]["metadata_store"]["uri"] = "http://localhost:2379"; f.close();f=open("./interactive_config_test_etcd.yaml","w");yaml.dump(y,f);f.close()'
201+
bash hqps_admin_test.sh ${TMP_INTERACTIVE_WORKSPACE} ./interactive_config_test_etcd.yaml ${GS_TEST_DIR}
202+
rm ./interactive_config_test_etcd.yaml
203+
204+
189205
- name: Build and test Interactive Java/Python SDK
190206
env:
191207
FLEX_DATA_DIR: ${{ github.workspace }}/flex/interactive/examples/modern_graph
@@ -483,7 +499,7 @@ jobs:
483499
git clone --single-branch https://github.com/alibaba/libgrape-lite.git /tmp/libgrape-lite
484500
cd /tmp/libgrape-lite
485501
mkdir -p build && cd build
486-
cmake ..
502+
cmake .. -BUILD_ETCD_METASTORE=ON
487503
make -j$(nproc)
488504
make install
489505
@@ -649,3 +665,16 @@ jobs:
649665
BULK_LOAD_FILE=${GITHUB_WORKSPACE}/flex/interactive/examples/modern_graph/bulk_load.yaml
650666
sed -i 's/|/\\t/g' ${BULK_LOAD_FILE}
651667
GLOG_v=10 ./bin/bulk_loader -g ${SCHEMA_FILE} -l ${BULK_LOAD_FILE} -d /tmp/csr-data-dir/
668+
669+
- name: Test etcd-based metadata service
670+
run: |
671+
GOOGLE_URL=https://storage.googleapis.com/etcd
672+
GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
673+
DOWNLOAD_URL=${GOOGLE_URL}
674+
rm -rf /tmp/etcd-download-test && mkdir -p /tmp/etcd-download-test
675+
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
676+
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test
677+
/tmp/etcd-download-test/etcd &
678+
sleep 3
679+
680+
GLOG_v=10 ./tests/hqps/etcd_meta_test http://localhost:2379/

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@
1313
[submodule "flex/third_party/parallel-hashmap"]
1414
path = flex/third_party/parallel-hashmap
1515
url = https://github.com/greg7mdp/parallel-hashmap.git
16+
[submodule "flex/third_party/etcd-cpp-apiv3"]
17+
path = flex/third_party/etcd-cpp-apiv3
18+
url = https://github.com/etcd-cpp-apiv3/etcd-cpp-apiv3.git
19+
[submodule "flex/third_party/cpprestsdk"]
20+
path = flex/third_party/cpprestsdk
21+
url = https://github.com/microsoft/cpprestsdk.git

docs/flex/interactive/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ In this following table, we use the `.` notation to represent the hierarchy with
116116
| verbose_level | 0 | The verbose level of database log, should be a int | 0.0.3 |
117117
| compute_engine.thread_num_per_worker | 1 | The number of threads will be used to process the queries. Increase the number can benefit the query throughput | 0.0.1 |
118118
| compute_engine.wal_uri | file://{GRAPH_DATA_DIR}/wal | The location where Interactive will store and access WALs. `GRAPH_DATA_DIR` is a placeholder that will be populated by Interactive. | 0.5 |
119+
| compute_engine.metadata_store.uri | file://{WORKSPACE}/METADATA | The location where Interactive will store and access metadatas. `WORKSPACE` is a placeholder that will be populated by Interactive. | 0.5 |
119120
| compiler.planner.is_on | true | Determines if query optimization is enabled for compiling Cypher queries | 0.0.1 |
120121
| compiler.planner.opt | RBO | Specifies the optimizer to be used for query optimization. Currently, only the Rule-Based Optimizer (RBO) is supported | 0.0.1 |
121122
| compiler.planner.rules.FilterMatchRule | N/A | An optimization rule that pushes filter (`Where`) conditions into the `Match` clause | 0.0.1 |

docs/flex/interactive/development/dev_and_test.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,38 @@ In Interactive's execution engine, transactions such as `ReadTransaction`, `Upda
262262
2. If a transaction returns `false` during the `commit()` process, the error occurred prior to applying the WAL to the graph data. This type of failure could arise during the construction of the WAL or during its writing phase.
263263

264264
3. It is important to note that errors can still occur when replaying the WAL to the graph database. Replaying might fail due to limitations in resources or due to unforeseen bugs. **However,** any errors encountered during this stage will be handled via exceptions or may result in process failure. Currently, there is no established mechanism to handle such failures. Future improvements should focus on implementing failover strategies, potentially allowing the GraphDB to continue replaying the WAL until it succeeds.
265+
266+
267+
## Using ETCD as Metadata storage
268+
269+
```bash
270+
ETCD_VER=v3.4.13
271+
272+
# choose either URL
273+
GOOGLE_URL=https://storage.googleapis.com/etcd
274+
GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
275+
DOWNLOAD_URL=${GOOGLE_URL}
276+
277+
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
278+
rm -rf /tmp/etcd-download-test && mkdir -p /tmp/etcd-download-test
279+
280+
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
281+
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test --strip-components=1
282+
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
283+
284+
cd /tmp/etcd-download-test
285+
# You may find etcd and etcdctl in the directory
286+
```
287+
288+
Start a local etcd server
289+
290+
```bash
291+
cd /tmp/etcd-download-test
292+
etcd
293+
```
294+
295+
Now in another terminal test etcd metadata store.
296+
```bash
297+
cd GraphScope/flex/build
298+
./tests/hqps/etcd_meta_test http://localhost:2379
299+
```

flex/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ option(USE_PTHASH "Whether to use pthash" OFF)
1717
option(OPTIMIZE_FOR_HOST "Whether to optimize on host" ON) # Whether to build optimized code on host
1818
option(USE_STATIC_ARROW "Whether to use static arrow" OFF) # Whether to link arrow statically, default is OFF
1919
option(BUILD_WITH_OTEL "Whether to build with opentelemetry-cpp" OFF) # Whether to build with opentelemetry-cpp, default is OFF
20+
option(BUILD_ETCD_METASTORE "Whether to build with etcd metastore" OFF) # Whether to build with etcd metastore, default is OFF
2021

2122
#print options
2223
message(STATUS "Build test: ${BUILD_TEST}")
@@ -226,6 +227,24 @@ macro(install_without_export_flex_target target)
226227
)
227228
endmacro()
228229

230+
if (BUILD_ETCD_METASTORE)
231+
add_definitions(-DBUILD_ETCD_METASTORE)
232+
# cd to third_party/cpprestsdk and run git submodule update --init
233+
include("cmake/BuildEtcdCpp.cmake")
234+
# set(WERROR OFF CACHE BOOL "Treat warnings as errors")
235+
# set(CPPREST_EXCLUDE_WEBSOCKETS ON CACHE BOOL "Exclude websockets functionality..")
236+
# add_subdirectory(third_party/cpprestsdk EXCLUDE_FROM_ALL)
237+
# set(CPPREST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/cpprestsdk/Release/include)
238+
# set(CPPREST_LIB cpprest)
239+
# add_subdirectory(third_party/etcd-cpp-apiv3 EXCLUDE_FROM_ALL)
240+
include_directories(SYSTEM ${CPPREST_INCLUDE_DIR})
241+
# for each directory in ${ETCD_CPP_INCLUDE_DIR}
242+
foreach(dir ${ETCD_CPP_INCLUDE_DIR})
243+
message(STATUS "Include directory: ${dir}")
244+
include_directories(SYSTEM ${dir})
245+
endforeach()
246+
endif()
247+
229248
add_subdirectory(utils)
230249
add_subdirectory(codegen)
231250
add_subdirectory(storages)

flex/cmake/BuildEtcdCpp.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2020-2023 Alibaba Group Holding Limited.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This File is copied from https://github.com/v6d-io/v6d/blob/main/cmake/BuildEtcdCpp.cmake
16+
# build cpprestsdk
17+
set(WERROR OFF CACHE BOOL "Treat warnings as errors")
18+
set(BUILD_TESTS OFF CACHE BOOL "Build tests.")
19+
set(BUILD_SAMPLES OFF CACHE BOOL "Build sample applications.")
20+
set(CPPREST_EXCLUDE_WEBSOCKETS ON CACHE BOOL "Exclude websockets functionality..")
21+
add_subdirectory(third_party/cpprestsdk)
22+
set(CPPREST_INCLUDE_DIR flex/third_party/cpprestsdk/Release/include)
23+
set(CPPREST_LIB cpprest)
24+
25+
# disable a warning message inside cpprestsdk on Mac with llvm/clang
26+
if(W_NO_UNUSED_BUT_SET_PARAMETER)
27+
target_compile_options(cpprest PRIVATE -Wno-unused-but-set-parameter)
28+
endif()
29+
30+
# build etcd-cpp-apiv3
31+
add_subdirectory(third_party/etcd-cpp-apiv3)
32+
set(ETCD_CPP_LIBRARIES etcd-cpp-api)
33+
set(ETCD_CPP_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/third_party/etcd-cpp-apiv3/
34+
${PROJECT_BINARY_DIR}/third_party/etcd-cpp-apiv3/proto/gen
35+
${PROJECT_BINARY_DIR}/third_party/etcd-cpp-apiv3/proto/gen/proto)

flex/engines/graph_db/database/wal/local_wal_parser.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ LocalWalParser::LocalWalParser(const std::string& wal_uri)
2828
}
2929

3030
void LocalWalParser::open(const std::string& wal_uri) {
31-
auto wal_dir = get_wal_uri_path(wal_uri);
31+
auto wal_dir = get_uri_path(wal_uri);
3232
if (!std::filesystem::exists(wal_dir)) {
3333
std::filesystem::create_directory(wal_dir);
3434
}

flex/engines/graph_db/database/wal/local_wal_parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <vector>
2020
#include "flex/engines/graph_db/database/wal/wal.h"
21+
#include "flex/utils/service_utils.h"
2122

2223
namespace gs {
2324

flex/engines/graph_db/database/wal/local_wal_writer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ std::unique_ptr<IWalWriter> LocalWalWriter::Make() {
2626
}
2727

2828
void LocalWalWriter::open(const std::string& wal_uri, int thread_id) {
29-
auto prefix = get_wal_uri_path(wal_uri);
29+
auto prefix = get_uri_path(wal_uri);
3030
if (!std::filesystem::exists(prefix)) {
3131
std::filesystem::create_directories(prefix);
3232
}

flex/engines/graph_db/database/wal/local_wal_writer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <memory>
2020
#include <unordered_map>
2121
#include "flex/engines/graph_db/database/wal/wal.h"
22+
#include "flex/utils/service_utils.h"
2223

2324
namespace gs {
2425

0 commit comments

Comments
 (0)