Repository navigation
fix(store): size the RocksDB memory budget from available memory #3355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
byteayan
wants to merge
17
commits into
apache:master
Choose a base branch
from
byteayan:fix/store-rocksdb-memory-budget
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,218
−43
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
62376ee
fix(store): size the RocksDB memory budget from available memory
byteayan 1927fbe
fix(store): keep the derived write buffer above RocksDB's minimum
byteayan e691489
ci: re-run checks
byteayan 84e8e27
fix(store): count unset direct memory as at most 1 GiB in the budget
byteayan 3fb0da0
ci: select the store suite for the Store entrypoint test
byteayan 03a4d43
fix(store): honor ancestor cgroup limits and flag the old 32 GB value
byteayan 33e53ee
fix(store): rebase the cgroup path onto its mount root
byteayan 535c2d0
fix(store): take the lowest limit over every matching cgroup mount
byteayan 0b287bc
fix(store): flag a cgroup mount that can't be matched to the process
byteayan 5139e18
fix(store): budget the JVM's real direct-memory allowance
byteayan 119f819
fix(store): leave the direct-memory cap to a -j heap
byteayan 643db96
fix(store): detect a -j heap the way the JVM receives it
byteayan a5942ff
Merge remote-tracking branch 'apache/master' into fix/store-rocksdb-m…
byteayan 9e6dc50
ci: keep start-server.sh config writes idempotent across restarts
byteayan e8dd9ec
docs(store): list -XX:MaxHeapSize where the launcher skips the cap
byteayan 37597c4
ci: escape start-server.sh property keys without sed
byteayan 6fd1f75
docs(store): add a direct-memory cap to the large-heap JVM examples
byteayan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
hugegraph-server/hugegraph-dist/src/assembly/travis/test-start-server.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # run-api-test.sh starts the same Server directory twice. Run start-server.sh | ||
| # twice on one fixture, with init-store and the launcher stubbed, and check | ||
| # that every key it writes appears exactly once: a duplicate usePD reached | ||
| # HugeConfig as '[true, true]' and failed the second init-store. | ||
| set -euo pipefail | ||
|
|
||
| TRAVIS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
| STATIC_BIN="${TRAVIS_DIR}/../static/bin" | ||
| FIXTURE=$(mktemp -d "${TMPDIR:-/tmp}/start-server-test.XXXXXX") | ||
| trap 'rm -rf "${FIXTURE}"' EXIT | ||
|
|
||
| PASS=0 | ||
| FAIL=0 | ||
|
|
||
| expect_once() { | ||
| # expect_once <file> <key> <value> | ||
| local lines | ||
| lines=$(grep -E "^[[:space:]]*${2//./\\.}[[:space:]]*[=:]" "$1" || true) | ||
| if [[ "${lines}" == "$2=$3" ]]; then | ||
| PASS=$((PASS + 1)) | ||
| else | ||
| echo " FAIL $(basename "$1"): expected one '$2=$3', got: ${lines:-nothing}" >&2 | ||
| FAIL=$((FAIL + 1)) | ||
| fi | ||
| } | ||
|
|
||
| for backend in hstore hbase; do | ||
| base="${FIXTURE}/${backend}" | ||
| mkdir -p "${base}/bin" "${base}/conf/graphs" "${base}/travis" | ||
| cp "${TRAVIS_DIR}/start-server.sh" "${base}/travis/" | ||
| cp "${STATIC_BIN}/util.sh" "${base}/bin/" | ||
| printf '#!/bin/bash\ncat >/dev/null\n' > "${base}/bin/init-store.sh" | ||
| printf '#!/bin/bash\nexit 0\n' > "${base}/bin/start-hugegraph.sh" | ||
| chmod +x "${base}/bin/"*.sh "${base}/travis/start-server.sh" | ||
| printf 'backend=rocksdb\nserializer=binary\n' > "${base}/conf/graphs/hugegraph.properties" | ||
| printf 'restserver.url=http://127.0.0.1:8080\n' > "${base}/conf/rest-server.properties" | ||
| printf 'evaluationTimeout: 30000\n' > "${base}/conf/gremlin-server.yaml" | ||
|
|
||
| for run in 1 2; do | ||
| if ! bash "${base}/travis/start-server.sh" "${base}" "${backend}" "" \ | ||
| > "${base}/start-${run}.log" 2>&1; then | ||
| echo " FAIL ${backend}: start-server.sh run ${run} failed" >&2 | ||
| tail -5 "${base}/start-${run}.log" >&2 | ||
| FAIL=$((FAIL + 1)) | ||
| fi | ||
| done | ||
|
|
||
| graph="${base}/conf/graphs/hugegraph.properties" | ||
| rest="${base}/conf/rest-server.properties" | ||
| expect_once "${graph}" "backend" "${backend}" | ||
| expect_once "${graph}" "schema.sync_deletion" "true" | ||
| if [[ "${backend}" == hstore ]]; then | ||
| expect_once "${rest}" "usePD" "true" | ||
| else | ||
| expect_once "${rest}" "restserver.request_timeout" "200" | ||
| expect_once "${rest}" "gremlinserver.timeout" "200" | ||
| fi | ||
| done | ||
|
|
||
| echo "start-server.sh twice on one directory: ${PASS} passed, ${FAIL} failed" | ||
| [[ "${FAIL}" -eq 0 ]] |
107 changes: 107 additions & 0 deletions
107
hugegraph-server/hugegraph-dist/src/assembly/travis/test-store-docker-entrypoint.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # Checks that the Store Docker entrypoint passes HG_STORE_ROCKSDB_TOTAL_MEMORY_SIZE | ||
| # into SPRING_APPLICATION_JSON as rocksdb.total_memory_size, leaves the rocksdb key | ||
| # out when the variable is unset (so conf/application-pd.yml or auto-sizing applies), | ||
| # and refuses values that are not a plain number of bytes. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../../.." && pwd)" | ||
| ENTRYPOINT="${REPO_ROOT}/hugegraph-store/hg-store-dist/docker/docker-entrypoint.sh" | ||
| TMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/store-entrypoint-test.XXXXXX") | ||
| trap 'rm -rf "${TMP_DIR}"' EXIT | ||
|
|
||
| PASS=0 | ||
| FAIL=0 | ||
|
|
||
| [[ -f "${ENTRYPOINT}" ]] || { echo "entrypoint not found at ${ENTRYPOINT}" >&2; exit 1; } | ||
| command -v python3 >/dev/null || { echo "python3 required" >&2; exit 1; } | ||
|
|
||
| mkdir -p "${TMP_DIR}/bin" | ||
| cp "${ENTRYPOINT}" "${TMP_DIR}/docker-entrypoint.sh" | ||
| # Stand in for the launcher: record the generated config instead of starting Store | ||
| cat > "${TMP_DIR}/bin/start-hugegraph-store.sh" <<'STUB' | ||
| #!/usr/bin/env bash | ||
| printf '%s' "${SPRING_APPLICATION_JSON}" > ./spring.json | ||
| STUB | ||
| chmod +x "${TMP_DIR}/bin/start-hugegraph-store.sh" "${TMP_DIR}/docker-entrypoint.sh" | ||
|
|
||
| run_entrypoint() { | ||
| rm -f "${TMP_DIR}/spring.json" | ||
| # Drop any value from the caller's environment so "unset" really is unset | ||
| (cd "${TMP_DIR}" && env -u HG_STORE_ROCKSDB_TOTAL_MEMORY_SIZE \ | ||
| HG_STORE_PD_ADDRESS=pd0:8686 \ | ||
| HG_STORE_GRPC_HOST=store0 \ | ||
| HG_STORE_RAFT_ADDRESS=store0:8510 \ | ||
| "$@" \ | ||
| ./docker-entrypoint.sh 2>&1) | ||
| } | ||
|
|
||
| expect_memory() { | ||
| # expect_memory <name> <expected value, or "absent"> [NAME=VALUE ...] | ||
| local name="$1" expected="$2" | ||
| shift 2 | ||
| local out | ||
| if ! out=$(run_entrypoint "$@"); then | ||
| echo " FAIL ${name}: entrypoint exited non-zero" | ||
| printf '%s\n' "${out}" | tail -3 | ||
| FAIL=$((FAIL + 1)) | ||
| return | ||
| fi | ||
| if ! EXPECTED="${expected}" python3 - "${TMP_DIR}/spring.json" <<'PY' | ||
| import json, os, sys | ||
| with open(sys.argv[1], encoding="utf-8") as fh: | ||
| doc = json.load(fh) | ||
| want = os.environ["EXPECTED"] | ||
| got = doc.get("rocksdb", {}).get("total_memory_size", "absent") | ||
| if got != want: | ||
| print(" rocksdb.total_memory_size is %r, expected %r" % (got, want)) | ||
| sys.exit(1) | ||
| if doc["app"]["data-path"] != "/hugegraph-store/storage": | ||
| print(" app.data-path was lost") | ||
| sys.exit(1) | ||
| PY | ||
| then | ||
| echo " FAIL ${name}: invalid JSON or wrong rocksdb.total_memory_size" | ||
| FAIL=$((FAIL + 1)) | ||
| return | ||
| fi | ||
| echo " PASS ${name}" | ||
| PASS=$((PASS + 1)) | ||
| } | ||
|
|
||
| echo "Store docker-entrypoint rocksdb memory override" | ||
| expect_memory "unset leaves the key out" absent | ||
| expect_memory "empty leaves the key out" absent HG_STORE_ROCKSDB_TOTAL_MEMORY_SIZE= | ||
| expect_memory "bytes are passed through" 2147483648 \ | ||
| HG_STORE_ROCKSDB_TOTAL_MEMORY_SIZE=2147483648 | ||
| expect_memory "0 is passed through for auto-sizing" 0 HG_STORE_ROCKSDB_TOTAL_MEMORY_SIZE=0 | ||
|
|
||
| for bad in '4GB' '-1' '1.5e9' '1 2' '1"}'; do | ||
| if run_entrypoint HG_STORE_ROCKSDB_TOTAL_MEMORY_SIZE="${bad}" >/dev/null; then | ||
| echo " FAIL '${bad}' was accepted" | ||
| FAIL=$((FAIL + 1)) | ||
| else | ||
| echo " PASS '${bad}' is refused" | ||
| PASS=$((PASS + 1)) | ||
| fi | ||
| done | ||
|
|
||
| echo "${PASS} passed, ${FAIL} failed" | ||
| [[ "${FAIL}" -eq 0 ]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.