Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,11 @@ if [[ -n "$STORE_UTIL_SH" ]]; then
}

curl() {
[[ "$1" == "-fL" && "$2" == "-o" && "$4" == "--" ]] || return 64
[[ "$1" == "-fL" && "$2" == "--connect-timeout" && "$3" == "5" &&
"$4" == "--max-time" && "$5" == "30" && "$6" == "-o" &&
"$8" == "--" ]] || return 64
if [[ "$CALLER" == "installer" ]]; then
echo "valid" > "$3"
echo "valid" > "$7"
return 0
fi
touch "$STALE_DOWNLOAD"
Expand Down Expand Up @@ -660,6 +662,46 @@ if [[ -n "$STORE_UTIL_SH" ]]; then
LEFTOVERS=$(find "$WORK" -name 'lib.so.*' -type f | wc -l | tr -d ' ')
expect "concurrent replacement cleans private temp files" "0" "$LEFTOVERS"
)

echo ""
echo "10. Store optional download timeout preserves the cache and cleans partial bytes"
(
source "$STORE_UTIL_SH"
WORK=$(mktemp -d)
DEST="$WORK/lib.so"
CURL_CALLED="$WORK/curl-called"
trap 'rm -rf "$WORK"' EXIT
echo "cached" > "$DEST"

md5sum() { echo "good $1"; }
curl() { touch "$CURL_CALLED"; return 28; }
if download_and_verify "https://example.com/lib.so" "$DEST" "good" >/dev/null 2>&1 &&
[[ ! -e "$CURL_CALLED" ]]; then
pass "verified jemalloc cache requires no network"
else
fail "verified jemalloc cache requires no network" "cache was rejected or curl was called"
fi

md5sum() { echo "bad $1"; }
curl() {
[[ "$1" == "-fL" && "$2" == "--connect-timeout" && "$3" == "5" &&
"$4" == "--max-time" && "$5" == "30" && "$6" == "-o" &&
"$8" == "--" ]] || return 64
touch "$CURL_CALLED"
echo "partial" > "$7"
return 28
}
if download_and_verify "https://example.com/lib.so" "$DEST" "good" >/dev/null 2>&1; then
fail "bounded jemalloc timeout is reported" "download incorrectly succeeded"
elif [[ -e "$CURL_CALLED" ]]; then
pass "bounded jemalloc timeout is reported"
else
fail "bounded jemalloc timeout is reported" "curl did not receive the required timeouts"
fi
expect "timed out replacement preserves the old destination" "cached" "$(cat "$DEST")"
LEFTOVERS=$(find "$WORK" -name 'lib.so.*' -type f | wc -l | tr -d ' ')
expect "jemalloc timeout discards partial bytes" "0" "$LEFTOVERS"
)
fi

# --------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions hugegraph-store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ bin/start-hugegraph-store.sh [-g GC_TYPE] [-j "JVM_OPTIONS"] [-d DAEMON]
- `-j`: Custom JVM options (e.g., `-j "-Xmx16g -Xms8g"`)
- `-d`: Daemon mode (`true` = daemon, `false` = foreground; default: `true`). Set to `false` when running under Docker or a process supervisor so the container exits if Java dies.

On supported architectures, startup reuses a checksum-verified jemalloc library or tries to download it.
The optional download allows 5 seconds to connect and 30 seconds for the complete transfer. If it fails
or times out, Store continues without adding jemalloc to `LD_PRELOAD`; partial downloads are discarded.

Default JVM memory settings (defined in `start-hugegraph-store.sh`):
- Max heap: 32GB
- Min heap: 512MB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ download_and_verify() {
local tmp
# mktemp, not $$: a PID is shared by concurrent background subshells.
tmp=$(mktemp -- "${filepath}.XXXXXX") || return 1
if curl -fL -o "$tmp" -- "$url"; then
# jemalloc is optional: an unavailable or stalled mirror must not block
# Store startup indefinitely. Bound both connection and complete transfer.
if curl -fL --connect-timeout 5 --max-time 30 -o "$tmp" -- "$url"; then
actual_md5=$(md5sum -- "$tmp" | awk '{ print $1 }')
if [[ "$actual_md5" != "$expected_md5" ]]; then
echo "MD5 checksum verification failed for $filepath after download. Expected: $expected_md5, but got: $actual_md5"
Expand Down
Loading