Skip to content

Commit 9c70b01

Browse files
fix(ci): align ToplingDB CI setup
1 parent 7d81f9d commit 9c70b01

5 files changed

Lines changed: 62 additions & 26 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
permissions:
2121
actions: read
2222
contents: read
23+
packages: read
2324
security-events: write
2425

2526
strategy:

docs/toplingdb/toplingdb.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ By supporting ToplingDB, HugeGraph empowers users with greater control over stor
3737

3838
Enable users to select ToplingDB via configuration, allowing tuning parameters through YAML files without recompilation and real-time monitoring via Web Server—without sacrificing compatibility with existing RocksDB APIs.
3939

40+
## Platform Scope
41+
42+
The current ToplingDB native integration supports Linux x86_64 only.
43+
On macOS, Linux arm64/aarch64, and other non-x86_64 platforms, HugeGraph should continue to use the standard RocksDB `rocksdbjni` dependency instead of preloading ToplingDB native libraries.
44+
4045
## Design
4146

4247
### Provider Selection

hugegraph-server/hugegraph-dist/src/assembly/static/bin/common-topling.sh

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,35 +153,36 @@ function ensure_libaio_symlink() {
153153
function download_and_verify() {
154154
local url=$1
155155
local filepath=$2
156-
local expected_md5=$3
156+
local expected_sha256=$3
157+
local actual_sha256
157158

158-
if [[ -f $filepath ]]; then
159-
echo "File $filepath exists. Verifying MD5 checksum..."
160-
actual_md5=$(md5sum $filepath | awk '{ print $1 }')
161-
if [[ $actual_md5 != $expected_md5 ]]; then
162-
echo "MD5 checksum verification failed for $filepath. Expected: $expected_md5, but got: $actual_md5"
159+
if [[ -f "$filepath" ]]; then
160+
echo "File $filepath exists. Verifying SHA-256 checksum..."
161+
actual_sha256=$(sha256sum "$filepath" | awk '{ print $1 }')
162+
if [[ "$actual_sha256" != "$expected_sha256" ]]; then
163+
echo "SHA-256 checksum verification failed for $filepath. Expected: $expected_sha256, but got: $actual_sha256"
163164
echo "Deleting $filepath..."
164-
rm -f $filepath
165+
rm -f "$filepath"
165166
else
166-
echo "MD5 checksum verification succeeded for $filepath."
167+
echo "SHA-256 checksum verification succeeded for $filepath."
167168
return 0
168169
fi
169170
fi
170171

171172
echo "Downloading $filepath..."
172-
curl -L -o $filepath $url
173+
curl -fL -o "$filepath" "$url"
173174

174-
actual_md5=$(md5sum $filepath | awk '{ print $1 }')
175-
if [[ $actual_md5 != $expected_md5 ]]; then
176-
echo "MD5 checksum verification failed for $filepath after download. Expected: $expected_md5, but got: $actual_md5"
175+
actual_sha256=$(sha256sum "$filepath" | awk '{ print $1 }')
176+
if [[ "$actual_sha256" != "$expected_sha256" ]]; then
177+
echo "SHA-256 checksum verification failed for $filepath after download. Expected: $expected_sha256, but got: $actual_sha256"
177178
return 1
178179
fi
179180

180181
return 0
181182
}
182183

183184
function download_and_setup_jemalloc() {
184-
local arch lib_file download_url expected_md5 system_lib top
185+
local arch lib_file download_url expected_sha256 system_lib top
185186
top=$1
186187

187188
# Prefer system-installed jemalloc if available
@@ -224,19 +225,19 @@ function download_and_setup_jemalloc() {
224225
if [[ $arch == "aarch64" || $arch == "arm64" ]]; then
225226
lib_file="$top/bin/libjemalloc_aarch64.so"
226227
download_url="${GITHUB}/apache/hugegraph-doc/raw/binary-1.5/dist/server/libjemalloc_aarch64.so"
227-
expected_md5="2a631d2f81837f9d5864586761c5e380"
228+
expected_sha256="6b7e6099b6da798829c6ce6fcb55a787508841edd52446332a73300889dcd1dc"
228229
elif [[ $arch == "x86_64" ]]; then
229230
lib_file="$top/bin/libjemalloc.so"
230231
download_url="${GITHUB}/apache/hugegraph-doc/raw/binary-1.5/dist/server/libjemalloc.so"
231-
expected_md5="fd61765eec3bfea961b646c269f298df"
232+
expected_sha256="53b25e8626e1605cbd8b60befb3431cabc1b8851a54285e0dda412796feab67d"
232233
else
233234
echo "Unsupported architecture: $arch"
234235
return 1
235236
fi
236237

237238
# Download and verify jemalloc library (fallback when system lib not found)
238-
if download_and_verify "$download_url" "$lib_file" "$expected_md5"; then
239-
if [[ ":${LD_PRELOAD:-}:" != *"libjemalloc.so:"* ]]; then
239+
if download_and_verify "$download_url" "$lib_file" "$expected_sha256"; then
240+
if [[ ":${LD_PRELOAD:-}:" != *":${lib_file}:"* ]]; then
240241
export LD_PRELOAD="${lib_file}${LD_PRELOAD:+:$LD_PRELOAD}"
241242
fi
242243
else
@@ -248,6 +249,16 @@ function download_and_setup_jemalloc() {
248249
function preload_toplingdb() {
249250
local lib_dir="$1"
250251
local dest_dir="$2"
252+
local os_name
253+
254+
# NOTE: The current ToplingDB rocksdbjni snapshot bundles Linux x86_64 native libraries.
255+
# Linux arm64/aarch64 support requires a matching native rocksdbjni artifact.
256+
os_name="$(uname -s)"
257+
if [ "$os_name" != "Linux" ]; then
258+
echo "[common-topling] Skip ToplingDB native preload on non-Linux platform: $os_name" >&2
259+
return 0
260+
fi
261+
251262
local top="$(cd "$lib_dir"/../ && pwd)"
252263

253264
local jar_file
@@ -275,7 +286,9 @@ function preload_toplingdb() {
275286
{
276287
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
277288
echo "LD_PRELOAD=$LD_PRELOAD"
278-
echo "SERVER_VERSION_DIR=$SERVER_VERSION_DIR"
289+
if [ -n "${SERVER_VERSION_DIR:-}" ]; then
290+
echo "SERVER_VERSION_DIR=$SERVER_VERSION_DIR"
291+
fi
279292
} >> "$GITHUB_ENV" || true
280293
echo "[common-topling] Exported LD_LIBRARY_PATH and LD_PRELOAD to GITHUB_ENV" >&2 || true
281294
fi

hugegraph-server/hugegraph-dist/src/assembly/travis/install-rocksdb.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,23 @@
1616
# limitations under the License.
1717
#
1818

19-
set -Eeuo pipefail
19+
if [ "$(uname -s)" != "Linux" ]; then
20+
echo "[install-rocksdb] Skip ToplingDB native preload on non-Linux platform: $(uname -s)"
21+
return 0 2>/dev/null || exit 0
22+
fi
23+
24+
ORIG_SHELL_FLAGS="$-"
25+
ORIG_PIPEFAIL="$(set -o | awk '$1 == "pipefail" { print $2 }')"
26+
ORIG_ERR_TRAP="$(trap -p ERR || true)"
2027
# Save original IFS to avoid leaking into parent shell when sourced
2128
ORIG_IFS="${IFS}"
29+
set -Eeuo pipefail
2230
IFS=$'\n\t'
2331
# Unified error capture for easy positioning
2432
trap 'echo "[install-rocksdb] error at line ${LINENO}: ${BASH_COMMAND}" >&2' ERR
2533

2634
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
27-
SERVER_VERSION_DIR="$(pwd)/hugegraph-server/apache-hugegraph-server-incubating-$VERSION"
35+
SERVER_VERSION_DIR="$(pwd)/hugegraph-server/apache-hugegraph-server-$VERSION"
2836
SERVER_BIN="$SERVER_VERSION_DIR/bin"
2937
SERVER_LIB="$SERVER_VERSION_DIR/lib"
3038
INSTALL_DEST_DIR="$SERVER_VERSION_DIR/library"
@@ -46,8 +54,19 @@ source "$SERVER_BIN/common-topling.sh"
4654
type preload_toplingdb >/dev/null 2>&1 || { echo "Error: function preload_toplingdb not found" >&2; exit 1; }
4755
preload_toplingdb "$SERVER_LIB" "$INSTALL_DEST_DIR"
4856

49-
# Reset shell options to prevent affecting the parent shell when sourced
50-
set +Eeuo pipefail
51-
trap - ERR
5257
# Restore original IFS
5358
IFS="$ORIG_IFS"
59+
if [ -n "$ORIG_ERR_TRAP" ]; then
60+
eval "$ORIG_ERR_TRAP"
61+
else
62+
trap - ERR
63+
fi
64+
# Reset shell options to prevent affecting the parent shell when sourced
65+
case "$ORIG_SHELL_FLAGS" in *e*) set -e ;; *) set +e ;; esac
66+
case "$ORIG_SHELL_FLAGS" in *u*) set -u ;; *) set +u ;; esac
67+
case "$ORIG_SHELL_FLAGS" in *E*) set -E ;; *) set +E ;; esac
68+
if [ "$ORIG_PIPEFAIL" = "on" ]; then
69+
set -o pipefail
70+
else
71+
set +o pipefail
72+
fi

install-dist/scripts/dependency/known-dependencies.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,6 @@ jnr-ffi-2.1.7.jar
318318
jnr-x86asm-1.0.2.jar
319319
joda-time-2.10.8.jar
320320
joni-2.2.1.jar
321-
jraft-core-1.3.11.jar
322-
jraft-core-1.3.13.jar
323321
jraft-core-1.3.14.jar
324322
jraft-core-1.3.9.jar
325323
json-path-2.5.0.jar
@@ -512,7 +510,7 @@ psjava-0.1.19.jar
512510
reporter-config-base-3.0.3.jar
513511
reporter-config3-3.0.3.jar
514512
rewriting-9.0-9.0.20190305.jar
515-
rocksdbjni-8.10.2-SNAPSHOT.jar
513+
rocksdbjni-8.10.2.jar
516514
scala-java8-compat_2.12-0.8.0.jar
517515
scala-library-2.12.7.jar
518516
scala-reflect-2.12.7.jar

0 commit comments

Comments
 (0)