mirror of
https://github.com/facebook/rocksdb.git
synced 2026-11-06 02:52:35 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef3dd12e9a |
No files matched your search
@@ -0,0 +1,38 @@
|
||||
name: post-steps
|
||||
description: Steps that are taken after a RocksDB job
|
||||
inputs:
|
||||
artifact-prefix:
|
||||
description: Prefix to append to the name of artifacts that are uploaded
|
||||
required: true
|
||||
default: "${{ github.job }}"
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Upload Test Results artifact
|
||||
uses: actions/upload-artifact@v4.0.0
|
||||
with:
|
||||
name: "${{ inputs.artifact-prefix }}-test-results"
|
||||
path: "${{ runner.temp }}/test-results/**"
|
||||
- name: Upload DB LOG file artifact
|
||||
uses: actions/upload-artifact@v4.0.0
|
||||
with:
|
||||
name: "${{ inputs.artifact-prefix }}-db-log-file"
|
||||
path: LOG
|
||||
- name: Copy Test Logs (on Failure)
|
||||
if: ${{ failure() }}
|
||||
run: |
|
||||
mkdir -p ${{ runner.temp }}/failure-test-logs
|
||||
cp -r t/* ${{ runner.temp }}/failure-test-logs
|
||||
shell: bash
|
||||
- name: Upload Test Logs (on Failure) artifact
|
||||
uses: actions/upload-artifact@v4.0.0
|
||||
with:
|
||||
name: "${{ inputs.artifact-prefix }}-failure-test-logs"
|
||||
path: ${{ runner.temp }}/failure-test-logs/**
|
||||
if-no-files-found: ignore
|
||||
- name: Upload Core Dumps artifact
|
||||
uses: actions/upload-artifact@v4.0.0
|
||||
with:
|
||||
name: "${{ inputs.artifact-prefix }}-core-dumps"
|
||||
path: "core.*"
|
||||
if-no-files-found: ignore
|
||||
@@ -2,21 +2,12 @@ name: pre-steps
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Dump system info for diagnostics
|
||||
- name: Dump ulimits for diagnostics
|
||||
run: |
|
||||
echo "=== ulimits (soft) ==="
|
||||
ulimit -a -S || true
|
||||
echo "=== ulimits (hard) ==="
|
||||
ulimit -a -H || true
|
||||
echo "=== OS ==="
|
||||
uname -a || true
|
||||
echo "=== CPU ==="
|
||||
if [ "$RUNNER_OS" = "macOS" ]; then
|
||||
sysctl machdep.cpu.brand_string hw.ncpu || true
|
||||
else
|
||||
lscpu || true
|
||||
grep -m1 '^microcode' /proc/cpuinfo || true
|
||||
fi
|
||||
shell: bash
|
||||
- name: Install lld linker for faster builds
|
||||
run: apt-get update -y && apt-get install -y lld 2>/dev/null || true
|
||||
@@ -24,19 +15,20 @@ runs:
|
||||
- name: Setup Environment Variables
|
||||
run: |-
|
||||
echo "GTEST_THROW_ON_FAILURE=0" >> "$GITHUB_ENV"
|
||||
echo "GTEST_OUTPUT=\"xml:${{ runner.temp }}/test-results/\"" >> "$GITHUB_ENV"
|
||||
echo "SKIP_FORMAT_BUCK_CHECKS=1" >> "$GITHUB_ENV"
|
||||
echo "GTEST_COLOR=1" >> "$GITHUB_ENV"
|
||||
echo "CTEST_OUTPUT_ON_FAILURE=1" >> "$GITHUB_ENV"
|
||||
echo "CTEST_TEST_TIMEOUT=300" >> "$GITHUB_ENV"
|
||||
# These third-party sources are mirrored on the "third-party-deps" GitHub
|
||||
# release. To add one, upload the asset here (intentionally hidden):
|
||||
# https://github.com/meta/rocksdb/releases/edit/third-party-deps
|
||||
# https://github.com/facebook/rocksdb/releases/edit/third-party-deps
|
||||
# Note how file names are generated below (vs. from the original source)
|
||||
# before uploading. Removing or modifying files will break builds for
|
||||
# older releases/revisions (not found or checksum mismatch).
|
||||
echo "ZLIB_DOWNLOAD_PREFIX=https://github.com/meta/rocksdb/releases/download/third-party-deps/zlib-" >> "$GITHUB_ENV"
|
||||
echo "BZIP2_DOWNLOAD_PREFIX=https://github.com/meta/rocksdb/releases/download/third-party-deps/bzip2-" >> "$GITHUB_ENV"
|
||||
echo "SNAPPY_DOWNLOAD_PREFIX=https://github.com/meta/rocksdb/releases/download/third-party-deps/snappy-" >> "$GITHUB_ENV"
|
||||
echo "LZ4_DOWNLOAD_PREFIX=https://github.com/meta/rocksdb/releases/download/third-party-deps/lz4-" >> "$GITHUB_ENV"
|
||||
echo "ZSTD_DOWNLOAD_PREFIX=https://github.com/meta/rocksdb/releases/download/third-party-deps/zstd-" >> "$GITHUB_ENV"
|
||||
echo "ZLIB_DOWNLOAD_PREFIX=https://github.com/facebook/rocksdb/releases/download/third-party-deps/zlib-" >> "$GITHUB_ENV"
|
||||
echo "BZIP2_DOWNLOAD_PREFIX=https://github.com/facebook/rocksdb/releases/download/third-party-deps/bzip2-" >> "$GITHUB_ENV"
|
||||
echo "SNAPPY_DOWNLOAD_PREFIX=https://github.com/facebook/rocksdb/releases/download/third-party-deps/snappy-" >> "$GITHUB_ENV"
|
||||
echo "LZ4_DOWNLOAD_PREFIX=https://github.com/facebook/rocksdb/releases/download/third-party-deps/lz4-" >> "$GITHUB_ENV"
|
||||
echo "ZSTD_DOWNLOAD_PREFIX=https://github.com/facebook/rocksdb/releases/download/third-party-deps/zstd-" >> "$GITHUB_ENV"
|
||||
shell: bash
|
||||
@@ -8,7 +8,7 @@ runs:
|
||||
run: chown `whoami` . || true
|
||||
shell: bash
|
||||
- name: Set upstream
|
||||
run: git remote add upstream https://github.com/meta/rocksdb.git
|
||||
run: git remote add upstream https://github.com/facebook/rocksdb.git
|
||||
shell: bash
|
||||
- name: Fetch upstream
|
||||
run: git fetch upstream
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
// Parse Codex review artifacts and produce a markdown review comment.
|
||||
//
|
||||
// Usage from actions/github-script:
|
||||
// const parse = require('./.github/scripts/parse-codex-review.js');
|
||||
// const markdown = parse({ responseFile, recoveryFile, findingsFile, logFile,
|
||||
// exitCode, meta });
|
||||
//
|
||||
// Parameters:
|
||||
// responseFile - path to Codex final response output
|
||||
// recoveryFile - path to recovery output formatted from review-findings.md
|
||||
// findingsFile - path to incremental findings file written during review
|
||||
// logFile - path to Codex stdout/stderr log
|
||||
// exitCode - Codex process exit code
|
||||
// meta - { trigger, autoMode, headSha, reviewer, isQuery, isPartial }
|
||||
|
||||
const fs = require('fs');
|
||||
const buildComment = require('./build-ai-review-comment.js');
|
||||
|
||||
module.exports = function parseCodex(
|
||||
{responseFile, recoveryFile, findingsFile, logFile, exitCode, meta}) {
|
||||
function getTriggerLine() {
|
||||
if (meta.trigger !== 'auto') {
|
||||
return `*Requested by @${meta.reviewer}*`;
|
||||
}
|
||||
const shortSha = meta.headSha ? meta.headSha.substring(0, 7) : 'unknown';
|
||||
if (meta.autoMode === 'early') {
|
||||
return `*Auto-triggered after CI reached the early-review threshold — reviewing commit ${
|
||||
shortSha}*`;
|
||||
}
|
||||
return `*Auto-triggered after CI passed — reviewing commit ${shortSha}*`;
|
||||
}
|
||||
|
||||
function readIfPresent(path) {
|
||||
if (!path || !fs.existsSync(path)) {
|
||||
return '';
|
||||
}
|
||||
const text = fs.readFileSync(path, 'utf8').trim();
|
||||
return text;
|
||||
}
|
||||
|
||||
function tailFile(path, maxChars = 12000) {
|
||||
const text = readIfPresent(path);
|
||||
if (!text) {
|
||||
return '';
|
||||
}
|
||||
if (text.length <= maxChars) {
|
||||
return text;
|
||||
}
|
||||
return text.slice(text.length - maxChars);
|
||||
}
|
||||
|
||||
let responseBody = '';
|
||||
const recovered = readIfPresent(recoveryFile);
|
||||
const direct = readIfPresent(responseFile);
|
||||
const findings = readIfPresent(findingsFile);
|
||||
|
||||
if (recovered) {
|
||||
responseBody = recovered;
|
||||
} else if (direct) {
|
||||
responseBody = direct;
|
||||
} else if (findings) {
|
||||
responseBody =
|
||||
'⚠️ **Review incomplete — Codex did not produce a final response.**\n\n' +
|
||||
'Below are the incremental findings recovered from `review-findings.md`.\n\n---\n\n' +
|
||||
findings;
|
||||
} else {
|
||||
const logTail = tailFile(logFile);
|
||||
responseBody = logTail ?
|
||||
`❌ **Codex review failed before producing findings.**\n\n\`\`\`\n${
|
||||
logTail}\n\`\`\`` :
|
||||
'❌ Codex review failed before producing any output.';
|
||||
}
|
||||
|
||||
const isPartial = !!meta.isPartial;
|
||||
const code = Number.parseInt(exitCode || '1', 10);
|
||||
const icon = isPartial ? '🟡' : (code === 0 ? '✅' : '⚠️');
|
||||
const triggerLine = getTriggerLine();
|
||||
|
||||
return buildComment({
|
||||
icon,
|
||||
headerTitle: meta.isQuery ? 'Codex Response' : 'Codex Code Review',
|
||||
triggerLine,
|
||||
responseBody,
|
||||
footerLines: [
|
||||
'Generated by Codex CLI.',
|
||||
'Review methodology: `claude_md/ci_review_prompt.md`',
|
||||
'',
|
||||
'**Limitations:**',
|
||||
'- Codex may miss context from files not in the diff',
|
||||
'- Large PRs may be truncated',
|
||||
'- Always apply human judgment to AI suggestions',
|
||||
'',
|
||||
'**Commands:**',
|
||||
'- `/codex-review [context]` — Request a code review',
|
||||
'- `/codex-query <question>` — Ask about the PR or codebase',
|
||||
],
|
||||
});
|
||||
};
|
||||
@@ -117,7 +117,7 @@ function assertObsoleteComment(comment, originalBody) {
|
||||
|
||||
const context = {
|
||||
repo: {
|
||||
owner: 'meta',
|
||||
owner: 'facebook',
|
||||
repo: 'rocksdb',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
# Shared analysis workflow for AI PR reviews.
|
||||
#
|
||||
# This workflow is invoked by provider-specific wrappers (such as
|
||||
# claude-review.yml) so the event triggers and workflow names stay
|
||||
# user-friendly while the implementation lives in one place.
|
||||
# This workflow is invoked by provider-specific wrappers (Claude/Codex) so the
|
||||
# event triggers and workflow names stay user-friendly while the implementation
|
||||
# lives in one place.
|
||||
#
|
||||
# Security note for Codex:
|
||||
# Codex runs in non-interactive CI, so the Codex CLI steps below pass
|
||||
# `--dangerously-bypass-approvals-and-sandbox`. That disables Codex's
|
||||
# approval prompts and sandbox protections, so treat those steps as
|
||||
# arbitrary command execution on the runner. This file therefore keeps Codex
|
||||
# in the read-only analysis workflow, restricts the pull_request_target path
|
||||
# to same-repo PRs, and leaves write-scoped PR commenting in a separate
|
||||
# workflow. Re-evaluate that trust boundary before expanding Codex auto
|
||||
# review to broader trigger sources.
|
||||
|
||||
name: AI Review Analysis
|
||||
|
||||
@@ -10,7 +20,7 @@ on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
provider:
|
||||
description: Provider key, for example "claude"
|
||||
description: Provider key, for example "claude" or "codex"
|
||||
required: true
|
||||
type: string
|
||||
display_name:
|
||||
@@ -109,7 +119,7 @@ jobs:
|
||||
const FAIL_CONCLUSIONS = new Set([
|
||||
'failure', 'cancelled', 'timed_out', 'action_required'
|
||||
]);
|
||||
const AI_CHECK_TOKENS = ['claude'];
|
||||
const AI_CHECK_TOKENS = ['claude', 'codex'];
|
||||
const MIN_CHECKS = 10;
|
||||
const THRESHOLD = 0.5;
|
||||
const POLL_INTERVAL_MS = 90 * 1000;
|
||||
@@ -409,6 +419,24 @@ jobs:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Node.js
|
||||
if: >-
|
||||
steps.pr_info.outputs.skip != 'true' &&
|
||||
steps.check_existing.outputs.skip != 'true' &&
|
||||
inputs.provider == 'codex'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Install Codex CLI
|
||||
if: >-
|
||||
steps.pr_info.outputs.skip != 'true' &&
|
||||
steps.check_existing.outputs.skip != 'true' &&
|
||||
inputs.provider == 'codex'
|
||||
run: |
|
||||
npm install -g @openai/codex
|
||||
codex --version
|
||||
|
||||
- name: Generate diff and prompt
|
||||
if: steps.pr_info.outputs.skip != 'true' && steps.check_existing.outputs.skip != 'true'
|
||||
env:
|
||||
@@ -513,6 +541,72 @@ jobs:
|
||||
core.setOutput('label', label);
|
||||
core.setOutput('tokens', budget);
|
||||
|
||||
- name: Classify PR complexity (Codex)
|
||||
if: >-
|
||||
steps.pr_info.outputs.skip != 'true' &&
|
||||
steps.check_existing.outputs.skip != 'true' &&
|
||||
inputs.provider == 'codex'
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
CODEX_HOME: /tmp/codex-home
|
||||
CODEX_MODEL: ${{ inputs.default_model }}
|
||||
run: |
|
||||
if [ -z "${OPENAI_API_KEY}" ]; then
|
||||
echo "OPENAI_API_KEY not configured, skipping Codex review"
|
||||
printf 'complex\n' > codex-complexity-output.txt
|
||||
exit 0
|
||||
fi
|
||||
mkdir -p "${CODEX_HOME}"
|
||||
set +e
|
||||
codex exec \
|
||||
-m "${CODEX_MODEL}" \
|
||||
-c model_reasoning_effort="medium" \
|
||||
--dangerously-bypass-approvals-and-sandbox \
|
||||
--output-last-message codex-complexity-output.txt \
|
||||
- < /tmp/complexity_prompt.txt > codex-complexity.log 2>&1
|
||||
exit_code=$?
|
||||
set -e
|
||||
if [ "${exit_code}" -ne 0 ]; then
|
||||
echo "Codex complexity classification failed with exit code ${exit_code}"
|
||||
echo "Defaulting to complex review budget"
|
||||
if [ -s codex-complexity.log ]; then
|
||||
echo "Last 100 lines of codex-complexity.log:"
|
||||
tail -100 codex-complexity.log
|
||||
fi
|
||||
printf 'complex\n' > codex-complexity-output.txt
|
||||
fi
|
||||
|
||||
- name: Pick thinking budget (Codex)
|
||||
if: >-
|
||||
steps.pr_info.outputs.skip != 'true' &&
|
||||
steps.check_existing.outputs.skip != 'true' &&
|
||||
inputs.provider == 'codex'
|
||||
id: budget_codex
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
let label = 'complex';
|
||||
try {
|
||||
const text = fs.readFileSync(
|
||||
'codex-complexity-output.txt',
|
||||
'utf8'
|
||||
).trim().toLowerCase();
|
||||
if (/\bsimple\b/.test(text) && !/\bcomplex\b/.test(text)) {
|
||||
label = 'simple';
|
||||
}
|
||||
} catch (error) {
|
||||
core.warning(
|
||||
`Could not parse classifier output: ${error.message}`);
|
||||
}
|
||||
const effort = label === 'simple' ? 'high' : 'xhigh';
|
||||
core.info(
|
||||
`Complexity classified as: ${label} ` +
|
||||
`-> model_reasoning_effort=${effort}`
|
||||
);
|
||||
core.setOutput('label', label);
|
||||
core.setOutput('effort', effort);
|
||||
|
||||
- name: Run Claude
|
||||
if: >-
|
||||
steps.pr_info.outputs.skip != 'true' &&
|
||||
@@ -609,6 +703,99 @@ jobs:
|
||||
});
|
||||
fs.writeFileSync(process.env.COMMENT_FILE, body);
|
||||
|
||||
- name: Run Codex
|
||||
if: >-
|
||||
steps.pr_info.outputs.skip != 'true' &&
|
||||
steps.check_existing.outputs.skip != 'true' &&
|
||||
inputs.provider == 'codex'
|
||||
id: codex
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
CODEX_HOME: /tmp/codex-home
|
||||
CODEX_MODEL: ${{ inputs.default_model }}
|
||||
CODEX_REASONING_EFFORT: ${{ steps.budget_codex.outputs.effort }}
|
||||
run: |
|
||||
if [ -z "${OPENAI_API_KEY}" ]; then
|
||||
echo "OPENAI_API_KEY not configured, skipping Codex review"
|
||||
exit 0
|
||||
fi
|
||||
mkdir -p "${CODEX_HOME}"
|
||||
set +e
|
||||
codex exec \
|
||||
-m "${CODEX_MODEL}" \
|
||||
-c model_reasoning_effort="${CODEX_REASONING_EFFORT}" \
|
||||
--dangerously-bypass-approvals-and-sandbox \
|
||||
--output-last-message codex-review-output.md \
|
||||
- < /tmp/prompt.txt > codex-review-execution.log 2>&1
|
||||
exit_code=$?
|
||||
set -e
|
||||
echo "exit_code=${exit_code}" >> "${GITHUB_OUTPUT}"
|
||||
echo "${exit_code}" > codex-review-exit-code.txt
|
||||
|
||||
- name: Recover partial review (Codex)
|
||||
if: >-
|
||||
steps.pr_info.outputs.skip != 'true' &&
|
||||
steps.check_existing.outputs.skip != 'true' &&
|
||||
inputs.provider == 'codex' &&
|
||||
steps.codex.outputs.exit_code != '0' &&
|
||||
hashFiles('review-findings.md') != ''
|
||||
id: recover_codex
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
CODEX_HOME: /tmp/codex-home
|
||||
CODEX_MODEL: ${{ inputs.default_model }}
|
||||
CODEX_REASONING_EFFORT: ${{ steps.budget_codex.outputs.effort }}
|
||||
run: |
|
||||
set +e
|
||||
codex exec \
|
||||
-m "${CODEX_MODEL}" \
|
||||
-c model_reasoning_effort="${CODEX_REASONING_EFFORT}" \
|
||||
--dangerously-bypass-approvals-and-sandbox \
|
||||
--output-last-message codex-review-recovery.md \
|
||||
- < claude_md/ci_recovery_prompt.md > codex-review-recovery.log 2>&1
|
||||
exit_code=$?
|
||||
set -e
|
||||
echo "exit_code=${exit_code}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Build review comment (Codex)
|
||||
if: >-
|
||||
steps.pr_info.outputs.skip != 'true' &&
|
||||
steps.check_existing.outputs.skip != 'true' &&
|
||||
inputs.provider == 'codex'
|
||||
env:
|
||||
RESPONSE_FILE: codex-review-output.md
|
||||
RECOVERY_FILE: codex-review-recovery.md
|
||||
FINDINGS_FILE: review-findings.md
|
||||
LOG_FILE: codex-review-execution.log
|
||||
EXIT_CODE: ${{ steps.codex.outputs.exit_code }}
|
||||
HEAD_SHA: ${{ steps.pr_info.outputs.head_sha }}
|
||||
AUTO_MODE: ${{ steps.pr_info.outputs.auto_mode }}
|
||||
USED_RECOVERY: ${{ steps.recover_codex.outputs.exit_code == '0' && 'true' || 'false' }}
|
||||
COMMENT_FILE: ${{ inputs.comment_file }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
const parse = require('./.github/scripts/parse-codex-review.js');
|
||||
const body = parse({
|
||||
responseFile: process.env.RESPONSE_FILE,
|
||||
recoveryFile: process.env.RECOVERY_FILE,
|
||||
findingsFile: process.env.FINDINGS_FILE,
|
||||
logFile: process.env.LOG_FILE,
|
||||
exitCode: process.env.EXIT_CODE,
|
||||
meta: {
|
||||
trigger: 'auto',
|
||||
autoMode: process.env.AUTO_MODE,
|
||||
headSha: process.env.HEAD_SHA,
|
||||
reviewer: '',
|
||||
isQuery: false,
|
||||
isPartial: process.env.USED_RECOVERY === 'true' ||
|
||||
(!fs.existsSync(process.env.RESPONSE_FILE) &&
|
||||
fs.existsSync(process.env.FINDINGS_FILE)),
|
||||
}
|
||||
});
|
||||
fs.writeFileSync(process.env.COMMENT_FILE, body);
|
||||
|
||||
- name: Save PR number
|
||||
if: steps.pr_info.outputs.skip != 'true' && steps.check_existing.outputs.skip != 'true'
|
||||
run: |
|
||||
@@ -659,6 +846,27 @@ jobs:
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
|
||||
- name: Upload review logs (Codex)
|
||||
if: >-
|
||||
always() &&
|
||||
steps.pr_info.outputs.skip != 'true' &&
|
||||
steps.check_existing.outputs.skip != 'true' &&
|
||||
inputs.provider == 'codex'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: codex-review-logs
|
||||
path: |
|
||||
codex-review-execution.log
|
||||
codex-complexity.log
|
||||
codex-complexity-output.txt
|
||||
codex-review-recovery.log
|
||||
codex-review-output.md
|
||||
codex-review-recovery.md
|
||||
review-findings.md
|
||||
codex-review-exit-code.txt
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
|
||||
manual-review:
|
||||
name: Manual ${{ inputs.display_name }} Review
|
||||
runs-on: ubuntu-latest
|
||||
@@ -782,6 +990,18 @@ jobs:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Node.js
|
||||
if: steps.request.outputs.skip != 'true' && inputs.provider == 'codex'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Install Codex CLI
|
||||
if: steps.request.outputs.skip != 'true' && inputs.provider == 'codex'
|
||||
run: |
|
||||
npm install -g @openai/codex
|
||||
codex --version
|
||||
|
||||
- name: Generate diff and prompt
|
||||
if: steps.request.outputs.skip != 'true'
|
||||
env:
|
||||
@@ -933,6 +1153,89 @@ jobs:
|
||||
core.setOutput('label', label);
|
||||
core.setOutput('tokens', budget);
|
||||
|
||||
- name: Classify PR complexity (Codex)
|
||||
if: >-
|
||||
steps.request.outputs.skip != 'true' &&
|
||||
steps.request.outputs.type == 'review' &&
|
||||
inputs.provider == 'codex'
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
CODEX_HOME: /tmp/codex-home
|
||||
CODEX_MODEL: ${{ inputs.selected_model != '' && inputs.selected_model || inputs.default_model }}
|
||||
run: |
|
||||
if [ -z "${OPENAI_API_KEY}" ]; then
|
||||
echo "OPENAI_API_KEY not configured, skipping Codex review"
|
||||
printf 'complex\n' > codex-complexity-output.txt
|
||||
exit 0
|
||||
fi
|
||||
mkdir -p "${CODEX_HOME}"
|
||||
set +e
|
||||
codex exec \
|
||||
-m "${CODEX_MODEL}" \
|
||||
-c model_reasoning_effort="medium" \
|
||||
--dangerously-bypass-approvals-and-sandbox \
|
||||
--output-last-message codex-complexity-output.txt \
|
||||
- < /tmp/complexity_prompt.txt > codex-complexity.log 2>&1
|
||||
exit_code=$?
|
||||
set -e
|
||||
if [ "${exit_code}" -ne 0 ]; then
|
||||
echo "Codex complexity classification failed with exit code ${exit_code}"
|
||||
echo "Defaulting to complex review budget"
|
||||
if [ -s codex-complexity.log ]; then
|
||||
echo "Last 100 lines of codex-complexity.log:"
|
||||
tail -100 codex-complexity.log
|
||||
fi
|
||||
printf 'complex\n' > codex-complexity-output.txt
|
||||
fi
|
||||
|
||||
- name: Pick thinking budget (Codex)
|
||||
if: steps.request.outputs.skip != 'true' && inputs.provider == 'codex'
|
||||
id: manual_budget_codex
|
||||
env:
|
||||
OVERRIDE: ${{ inputs.thinking_budget }}
|
||||
COMMAND_TYPE: ${{ steps.request.outputs.type }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
if (process.env.COMMAND_TYPE !== 'review') {
|
||||
core.setOutput('label', 'query');
|
||||
core.setOutput('effort', 'medium');
|
||||
return;
|
||||
}
|
||||
const override = (process.env.OVERRIDE || '').trim();
|
||||
if (override && /^\d+$/.test(override)) {
|
||||
const budget = parseInt(override, 10);
|
||||
const effort = budget >= 32000 ? 'xhigh' : 'high';
|
||||
core.info(
|
||||
`Using thinking_budget override: ${override} ` +
|
||||
`-> model_reasoning_effort=${effort}`
|
||||
);
|
||||
core.setOutput('label', 'override');
|
||||
core.setOutput('effort', effort);
|
||||
return;
|
||||
}
|
||||
let label = 'complex';
|
||||
try {
|
||||
const text = fs.readFileSync(
|
||||
'codex-complexity-output.txt',
|
||||
'utf8'
|
||||
).trim().toLowerCase();
|
||||
if (/\bsimple\b/.test(text) && !/\bcomplex\b/.test(text)) {
|
||||
label = 'simple';
|
||||
}
|
||||
} catch (error) {
|
||||
core.warning(
|
||||
`Could not parse classifier output: ${error.message}`);
|
||||
}
|
||||
const effort = label === 'simple' ? 'high' : 'xhigh';
|
||||
core.info(
|
||||
`Complexity classified as: ${label} ` +
|
||||
`-> model_reasoning_effort=${effort}`
|
||||
);
|
||||
core.setOutput('label', label);
|
||||
core.setOutput('effort', effort);
|
||||
|
||||
- name: Run Claude
|
||||
if: steps.request.outputs.skip != 'true' && inputs.provider == 'claude'
|
||||
id: manual_claude
|
||||
@@ -1025,6 +1328,99 @@ jobs:
|
||||
});
|
||||
fs.writeFileSync(process.env.COMMENT_FILE, body);
|
||||
|
||||
- name: Run Codex
|
||||
if: steps.request.outputs.skip != 'true' && inputs.provider == 'codex'
|
||||
id: manual_codex
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
CODEX_HOME: /tmp/codex-home
|
||||
CODEX_MODEL: ${{ inputs.selected_model != '' && inputs.selected_model || inputs.default_model }}
|
||||
CODEX_REASONING_EFFORT: ${{ steps.manual_budget_codex.outputs.effort }}
|
||||
COMMAND_TYPE: ${{ steps.request.outputs.type }}
|
||||
run: |
|
||||
mkdir -p "${CODEX_HOME}"
|
||||
set +e
|
||||
if [ "${COMMAND_TYPE}" = "query" ]; then
|
||||
codex exec \
|
||||
-m "${CODEX_MODEL}" \
|
||||
-c model_reasoning_effort="${CODEX_REASONING_EFFORT}" \
|
||||
--dangerously-bypass-approvals-and-sandbox \
|
||||
--output-last-message codex-review-output.md \
|
||||
- < /tmp/prompt.txt > codex-review-execution.log 2>&1
|
||||
else
|
||||
codex exec \
|
||||
-m "${CODEX_MODEL}" \
|
||||
-c model_reasoning_effort="${CODEX_REASONING_EFFORT}" \
|
||||
--dangerously-bypass-approvals-and-sandbox \
|
||||
--output-last-message codex-review-output.md \
|
||||
- < /tmp/prompt.txt > codex-review-execution.log 2>&1
|
||||
fi
|
||||
exit_code=$?
|
||||
set -e
|
||||
echo "exit_code=${exit_code}" >> "${GITHUB_OUTPUT}"
|
||||
echo "${exit_code}" > codex-review-exit-code.txt
|
||||
|
||||
- name: Recover partial review (Codex)
|
||||
if: >-
|
||||
steps.request.outputs.skip != 'true' &&
|
||||
inputs.provider == 'codex' &&
|
||||
steps.request.outputs.type == 'review' &&
|
||||
steps.manual_codex.outputs.exit_code != '0' &&
|
||||
hashFiles('review-findings.md') != ''
|
||||
id: manual_recover_codex
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
CODEX_HOME: /tmp/codex-home
|
||||
CODEX_MODEL: ${{ inputs.selected_model != '' && inputs.selected_model || inputs.default_model }}
|
||||
CODEX_REASONING_EFFORT: ${{ steps.manual_budget_codex.outputs.effort }}
|
||||
run: |
|
||||
set +e
|
||||
codex exec \
|
||||
-m "${CODEX_MODEL}" \
|
||||
-c model_reasoning_effort="${CODEX_REASONING_EFFORT}" \
|
||||
--dangerously-bypass-approvals-and-sandbox \
|
||||
--output-last-message codex-review-recovery.md \
|
||||
- < claude_md/ci_recovery_prompt.md > codex-review-recovery.log 2>&1
|
||||
exit_code=$?
|
||||
set -e
|
||||
echo "exit_code=${exit_code}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Build review comment (Codex)
|
||||
if: steps.request.outputs.skip != 'true' && inputs.provider == 'codex'
|
||||
env:
|
||||
RESPONSE_FILE: codex-review-output.md
|
||||
RECOVERY_FILE: codex-review-recovery.md
|
||||
FINDINGS_FILE: review-findings.md
|
||||
LOG_FILE: codex-review-execution.log
|
||||
EXIT_CODE: ${{ steps.manual_codex.outputs.exit_code }}
|
||||
HEAD_SHA: ${{ steps.pr_info.outputs.head_sha }}
|
||||
REVIEWER: ${{ steps.request.outputs.reviewer }}
|
||||
COMMAND_TYPE: ${{ steps.request.outputs.type }}
|
||||
USED_RECOVERY: ${{ steps.manual_recover_codex.outputs.exit_code == '0' && 'true' || 'false' }}
|
||||
COMMENT_FILE: ${{ inputs.comment_file }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
const parse = require('./.github/scripts/parse-codex-review.js');
|
||||
const body = parse({
|
||||
responseFile: process.env.RESPONSE_FILE,
|
||||
recoveryFile: process.env.RECOVERY_FILE,
|
||||
findingsFile: process.env.FINDINGS_FILE,
|
||||
logFile: process.env.LOG_FILE,
|
||||
exitCode: process.env.EXIT_CODE,
|
||||
meta: {
|
||||
trigger: 'manual',
|
||||
headSha: process.env.HEAD_SHA,
|
||||
reviewer: process.env.REVIEWER,
|
||||
isQuery: process.env.COMMAND_TYPE !== 'review',
|
||||
isPartial: process.env.USED_RECOVERY === 'true' ||
|
||||
(!fs.existsSync(process.env.RESPONSE_FILE) &&
|
||||
fs.existsSync(process.env.FINDINGS_FILE)),
|
||||
}
|
||||
});
|
||||
fs.writeFileSync(process.env.COMMENT_FILE, body);
|
||||
|
||||
- name: Save PR number
|
||||
if: steps.request.outputs.skip != 'true'
|
||||
run: |
|
||||
@@ -1078,3 +1474,20 @@ jobs:
|
||||
path: ${{ steps.manual_format_recovery_claude.outputs.execution_file }}
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
|
||||
- name: Upload review logs (Codex)
|
||||
if: always() && steps.request.outputs.skip != 'true' && inputs.provider == 'codex'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: codex-review-logs
|
||||
path: |
|
||||
codex-review-execution.log
|
||||
codex-complexity.log
|
||||
codex-complexity-output.txt
|
||||
codex-review-recovery.log
|
||||
codex-review-output.md
|
||||
codex-review-recovery.md
|
||||
review-findings.md
|
||||
codex-review-exit-code.txt
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
@@ -6,7 +6,7 @@ on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
provider:
|
||||
description: Provider key, for example "claude"
|
||||
description: Provider key, for example "claude" or "codex"
|
||||
required: true
|
||||
type: string
|
||||
result_artifact_name:
|
||||
@@ -71,8 +71,7 @@ jobs:
|
||||
|
||||
const post = require('./.github/scripts/post-pr-comment.js');
|
||||
const provider = process.env.PROVIDER;
|
||||
const providerTitle =
|
||||
provider.charAt(0).toUpperCase() + provider.slice(1);
|
||||
const providerTitle = provider === 'codex' ? 'Codex' : 'Claude';
|
||||
const body = fs.readFileSync(commentFile, 'utf8');
|
||||
const prNumber = parseInt(
|
||||
fs.readFileSync(prNumberFile, 'utf8').trim(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: meta/rocksdb/benchmark-linux
|
||||
name: facebook/rocksdb/benchmark-linux
|
||||
on: workflow_dispatch
|
||||
permissions: {}
|
||||
# FIXME: Disabled temporarily
|
||||
@@ -6,7 +6,7 @@ permissions: {}
|
||||
# - cron: 7 */2 * * * # At minute 7 past every 2nd hour
|
||||
jobs:
|
||||
benchmark-linux:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on: ubuntu-latest # FIXME: change this back to self-hosted when ready
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
|
||||
@@ -7,11 +7,11 @@ permissions: {}
|
||||
|
||||
jobs:
|
||||
clang-tidy:
|
||||
if: github.repository_owner == 'meta'
|
||||
if: github.repository_owner == 'facebook'
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:24.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:24.1
|
||||
options: --shm-size=8gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
|
||||
@@ -8,7 +8,7 @@ name: Claude Code Review
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["meta/rocksdb/pr-jobs"]
|
||||
workflows: ["facebook/rocksdb/pr-jobs"]
|
||||
types: [completed]
|
||||
|
||||
# The early pull_request_target path is limited to same-repo PRs by the job
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# Codex Code Review — Comment Posting Workflow
|
||||
#
|
||||
# Thin wrapper around .github/workflows/ai-review-comment.yml so the provider
|
||||
# specific workflow name stays stable while the shared implementation lives in
|
||||
# one reusable workflow.
|
||||
|
||||
name: Post Codex Review Comment
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Codex Code Review"]
|
||||
types: [completed]
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
review-comment:
|
||||
uses: ./.github/workflows/ai-review-comment.yml
|
||||
with:
|
||||
provider: codex
|
||||
result_artifact_name: codex-review-result
|
||||
comment_file: codex-review-comment.md
|
||||
@@ -0,0 +1,63 @@
|
||||
# Codex Code Review — Analysis Workflow
|
||||
#
|
||||
# Thin wrapper around .github/workflows/ai-review-analysis.yml so provider
|
||||
# specific triggers and workflow_dispatch inputs stay stable while the shared
|
||||
# implementation lives in one reusable workflow.
|
||||
|
||||
name: Codex Code Review
|
||||
|
||||
on:
|
||||
# Automatic PR reviews are temporarily disabled while Codex authentication is
|
||||
# repaired. Manual review requests remain available through issue comments
|
||||
# and workflow_dispatch.
|
||||
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
pr_number:
|
||||
description: PR number to review
|
||||
required: true
|
||||
type: number
|
||||
model:
|
||||
description: Codex model to use
|
||||
required: false
|
||||
type: choice
|
||||
options:
|
||||
- gpt-5.5
|
||||
- gpt-5.3-codex
|
||||
- gpt-5.2-codex
|
||||
default: gpt-5.5
|
||||
thinking_budget:
|
||||
description: Override MAX_THINKING_TOKENS (blank = auto-classify)
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
# The shared analysis workflow polls check state, inspects prior runs, and
|
||||
# reads PR metadata. Keep those permissions read-only in the caller.
|
||||
actions: read
|
||||
checks: read
|
||||
pull-requests: read
|
||||
|
||||
jobs:
|
||||
review:
|
||||
if: >-
|
||||
github.event_name != 'pull_request_target' ||
|
||||
github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: ./.github/workflows/ai-review-analysis.yml
|
||||
with:
|
||||
provider: codex
|
||||
display_name: Codex
|
||||
review_command: /codex-review
|
||||
query_command: /codex-query
|
||||
result_artifact_name: codex-review-result
|
||||
comment_file: codex-review-comment.md
|
||||
default_model: gpt-5.5
|
||||
selected_model: ${{ github.event_name == 'workflow_dispatch' && inputs.model || '' }}
|
||||
thinking_budget: ${{ github.event_name == 'workflow_dispatch' && inputs.thinking_budget || '' }}
|
||||
dispatch_pr_number: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || '' }}
|
||||
secrets: inherit
|
||||
@@ -1,11 +1,11 @@
|
||||
name: meta/rocksdb/nightly-candidate
|
||||
name: facebook/rocksdb/nightly-candidate
|
||||
on: workflow_dispatch
|
||||
permissions: {}
|
||||
jobs:
|
||||
# These jobs would be in nightly but are failing or otherwise broken for
|
||||
# some reason.
|
||||
build-linux-arm-test-full:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: arm64large
|
||||
container:
|
||||
@@ -16,3 +16,4 @@ jobs:
|
||||
- uses: "./.github/actions/pre-steps"
|
||||
- uses: "./.github/actions/install-gflags"
|
||||
- run: make V=1 J=4 -j4 check
|
||||
- uses: "./.github/actions/post-steps"
|
||||
@@ -1,4 +1,4 @@
|
||||
name: meta/rocksdb/nightly
|
||||
name: facebook/rocksdb/nightly
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 9 * * *
|
||||
@@ -6,11 +6,11 @@ on:
|
||||
permissions: {}
|
||||
jobs:
|
||||
build-format-compatible:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -26,30 +26,13 @@ jobs:
|
||||
mkdir /dev/shm/rocksdb
|
||||
git config --global --add safe.directory /__w/rocksdb/rocksdb
|
||||
tools/check_format_compatible.sh
|
||||
- name: Check that old facebook/rocksdb URLs still redirect
|
||||
# Alerts the RocksDB team if GitHub stops redirecting the pre-transfer
|
||||
# repo URL to its current location (or the old name gets taken by
|
||||
# another repo). Existing releases (e.g. dependency download URLs in
|
||||
# java/Makefile), existing clones, and external links still use the old
|
||||
# URL, so they would all break.
|
||||
if: ${{ !cancelled() }}
|
||||
run: |-
|
||||
if ! result=$(curl -sSL --retry 3 --retry-all-errors -o /dev/null \
|
||||
-w '%{http_code} %{url_effective}' https://github.com/facebook/rocksdb); then
|
||||
echo "::error::Failed to fetch https://github.com/facebook/rocksdb (network problem?)"
|
||||
exit 1
|
||||
fi
|
||||
echo "Old URL resolved to: $result"
|
||||
if [ "$result" != "200 https://github.com/meta/rocksdb" ]; then
|
||||
echo "::error::https://github.com/facebook/rocksdb no longer redirects to https://github.com/meta/rocksdb. Builds of existing releases, existing clones, and external links that use the old URL are likely broken."
|
||||
exit 1
|
||||
fi
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-non-shm:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
env:
|
||||
TEST_TMPDIR: "/tmp/rocksdb_test_tmp"
|
||||
@@ -57,12 +40,13 @@ jobs:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
- uses: "./.github/actions/pre-steps"
|
||||
- run: make V=1 -j32 check
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-clang-21-asan-ubsan-with-folly:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:24.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:24.1
|
||||
options: --shm-size=32gb
|
||||
env:
|
||||
CC: clang-21
|
||||
@@ -93,12 +77,13 @@ jobs:
|
||||
make build_folly
|
||||
shell: bash
|
||||
- run: LIB_MODE=static USE_CLANG=1 USE_FOLLY=1 COMPILE_WITH_UBSAN=1 COMPILE_WITH_ASAN=1 make -j32 check
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-cmake-with-folly:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -111,12 +96,13 @@ jobs:
|
||||
with:
|
||||
cache-hit: ${{ steps.cache-folly.outputs.cache-hit }}
|
||||
- run: "(mkdir build && cd build && cmake -DUSE_FOLLY=1 -DWITH_GFLAGS=1 -DROCKSDB_BUILD_SHARED=0 .. && make VERBOSE=1 -j20 && ctest -j20)"
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-release-with-folly:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -126,51 +112,17 @@ jobs:
|
||||
- run: "DEBUG_LEVEL=0 make -j20 build_folly"
|
||||
- run: "USE_FOLLY=1 LIB_MODE=static DEBUG_LEVEL=0 V=1 make -j20 release"
|
||||
- run: "(mkdir build && cd build && cmake -DUSE_FOLLY=1 -DWITH_GFLAGS=1 -DROCKSDB_BUILD_SHARED=0 -DCMAKE_BUILD_TYPE=Release .. && make VERBOSE=1 -j20 && ctest -j20)"
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-windows-msvc-avx2:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on: windows-8-core
|
||||
env:
|
||||
CMAKE_PORTABLE: AVX2
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
- uses: "./.github/actions/windows-build-steps"
|
||||
build-macos-cmake:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
runs-on: macos-15-xlarge
|
||||
strategy:
|
||||
matrix:
|
||||
run_sharded_tests: [0, 1, 2, 3]
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
- uses: maxim-lobanov/setup-xcode@v1.6.0
|
||||
with:
|
||||
xcode-version: 16.4.0
|
||||
- uses: "./.github/actions/setup-ccache"
|
||||
with:
|
||||
cache-key-prefix: macos-cmake
|
||||
- uses: "./.github/actions/increase-max-open-files-on-macos"
|
||||
- uses: "./.github/actions/install-gflags-on-macos"
|
||||
- uses: "./.github/actions/pre-steps-macos"
|
||||
- name: cmake generate project file
|
||||
run: ulimit -S -n `ulimit -H -n` && mkdir build && cd build && cmake -DWITH_GFLAGS=1 ..
|
||||
- name: Build tests
|
||||
run: cd build && make VERBOSE=1 -j8
|
||||
- name: Run shard 0 out of 4 test shards
|
||||
run: ulimit -S -n `ulimit -H -n` && cd build && ctest -j8 -I 0,,4
|
||||
if: ${{ matrix.run_sharded_tests == 0 }}
|
||||
- name: Run shard 1 out of 4 test shards
|
||||
run: ulimit -S -n `ulimit -H -n` && cd build && ctest -j8 -I 1,,4
|
||||
if: ${{ matrix.run_sharded_tests == 1 }}
|
||||
- name: Run shard 2 out of 4 test shards
|
||||
run: ulimit -S -n `ulimit -H -n` && cd build && ctest -j8 -I 2,,4
|
||||
if: ${{ matrix.run_sharded_tests == 2 }}
|
||||
- name: Run shard 3 out of 4 test shards
|
||||
run: ulimit -S -n `ulimit -H -n` && cd build && ctest -j8 -I 3,,4
|
||||
if: ${{ matrix.run_sharded_tests == 3 }}
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
build-linux-arm-test-full:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu-arm
|
||||
steps:
|
||||
@@ -178,8 +130,9 @@ jobs:
|
||||
- uses: "./.github/actions/pre-steps"
|
||||
- run: sudo apt-get update && sudo apt-get install -y build-essential libgflags-dev
|
||||
- run: make V=1 J=4 -j4 check
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-arm-crashtest:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu-arm
|
||||
steps:
|
||||
@@ -201,24 +154,26 @@ jobs:
|
||||
- run: ulimit -S -n `ulimit -H -n` && make V=1 -j8 CRASH_TEST_EXT_ARGS='--duration=1800 --max_key=2500000' blackbox_crash_test_with_atomic_flush
|
||||
- run: rm -rf /dev/shm/rocksdb.*
|
||||
- run: ulimit -S -n `ulimit -H -n` && make V=1 -j8 CRASH_TEST_EXT_ARGS='--duration=1800 --max_key=2500000' blackbox_crash_test_with_multiops_wc_txn
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-examples:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=8gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
- uses: "./.github/actions/pre-steps"
|
||||
- name: Build examples
|
||||
run: make V=1 -j4 static_lib && cd examples && make V=1 -j4
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-fuzzers:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:24.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:24.1
|
||||
options: --shm-size=8gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -227,12 +182,13 @@ jobs:
|
||||
run: CC=clang-21 CXX=clang++-21 USE_CLANG=1 make -j4 static_lib
|
||||
- name: Build fuzzers
|
||||
run: cd fuzz && make sst_file_writer_fuzzer db_fuzzer db_map_fuzzer
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-cmake-with-folly-lite:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -240,3 +196,4 @@ jobs:
|
||||
- uses: "./.github/actions/cache-getdeps-downloads"
|
||||
- uses: "./.github/actions/setup-folly"
|
||||
- run: "(mkdir build && cd build && cmake -DUSE_FOLLY_LITE=1 -DWITH_GFLAGS=1 -DCMAKE_CXX_FLAGS=-DGLOG_USE_GLOG_EXPORT .. && make VERBOSE=1 -j20 && ctest -j20)"
|
||||
- uses: "./.github/actions/post-steps"
|
||||
@@ -1,4 +1,4 @@
|
||||
name: meta/rocksdb/pr-jobs-candidate
|
||||
name: facebook/rocksdb/pr-jobs-candidate
|
||||
on: workflow_dispatch
|
||||
permissions: {}
|
||||
jobs:
|
||||
@@ -6,7 +6,7 @@ jobs:
|
||||
# some reason.
|
||||
# =========================== ARM Jobs ============================ #
|
||||
build-linux-arm:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: arm64large # GitHub hosted ARM runners do not yet exist
|
||||
steps:
|
||||
@@ -14,8 +14,9 @@ jobs:
|
||||
- uses: "./.github/actions/pre-steps"
|
||||
- uses: "./.github/actions/install-gflags"
|
||||
- run: ROCKSDBTESTS_PLATFORM_DEPENDENT=only make V=1 J=4 -j4 all_but_some_tests check_some
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-arm-cmake-no_test_run:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: arm64large # GitHub hosted ARM runners do not yet exist
|
||||
env:
|
||||
@@ -43,3 +44,4 @@ jobs:
|
||||
cd build
|
||||
cmake -DJNI=1 -DCMAKE_BUILD_TYPE=Release -DWITH_GFLAGS=1 ..
|
||||
make -j4 rocksdb rocksdbjni
|
||||
- uses: "./.github/actions/post-steps"
|
||||
+115
-49
@@ -1,9 +1,9 @@
|
||||
name: meta/rocksdb/pr-jobs
|
||||
name: facebook/rocksdb/pr-jobs
|
||||
on: [push, pull_request]
|
||||
permissions: {}
|
||||
env:
|
||||
# Set to a job name to run only that job (on any repo), or leave empty for
|
||||
# normal behavior (all jobs on meta/rocksdb repo only).
|
||||
# normal behavior (all jobs on facebook repo only).
|
||||
ONLY_JOB: ''
|
||||
jobs:
|
||||
config:
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
# workflow minimizes the problem because it will be suspicious if there are
|
||||
# no GHA results.
|
||||
#
|
||||
# The if: ${{ github.repository_owner == 'meta' }} lines prevent the
|
||||
# The if: ${{ github.repository_owner == 'facebook' }} lines prevent the
|
||||
# jobs from attempting to run on repo forks, because of a few problems:
|
||||
# * runs-on labels are repository (owner) specific, so the job might wait
|
||||
# for days waiting for a runner that simply isn't available.
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
|
||||
# ======================== Fast Initial Checks ====================== #
|
||||
check-format-and-targets:
|
||||
if: needs.config.outputs.only_job == 'check-format-and-targets' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'check-format-and-targets' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
@@ -66,8 +66,8 @@ jobs:
|
||||
clang-format --version
|
||||
- name: Download clang-format-diff.py
|
||||
# Mirrored on the "third-party-deps" GitHub release; add/update via
|
||||
# https://github.com/meta/rocksdb/releases/edit/third-party-deps
|
||||
run: wget --tries=3 --retry-on-host-error https://github.com/meta/rocksdb/releases/download/third-party-deps/clang-format-diff.py
|
||||
# https://github.com/facebook/rocksdb/releases/edit/third-party-deps
|
||||
run: wget --tries=3 --retry-on-host-error https://github.com/facebook/rocksdb/releases/download/third-party-deps/clang-format-diff.py
|
||||
- name: Check format
|
||||
run: VERBOSE_CHECK=1 make check-format
|
||||
- name: Compare buckify output
|
||||
@@ -86,12 +86,12 @@ jobs:
|
||||
SANITY_CHECK=1 LONG_TEST=1 tools/check_format_compatible.sh
|
||||
# ========================= Linux With Tests ======================== #
|
||||
build-linux:
|
||||
if: needs.config.outputs.only_job == 'build-linux' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -102,13 +102,14 @@ jobs:
|
||||
- run: make V=1 J=32 -j32 check
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-cmake-mingw:
|
||||
if: needs.config.outputs.only_job == 'build-linux-cmake-mingw' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-cmake-mingw' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:24.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:24.1
|
||||
options: --shm-size=8gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -126,13 +127,14 @@ jobs:
|
||||
mkdir build && cd build && cmake -DJNI=1 -DWITH_GFLAGS=OFF .. -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows && make -j4 rocksdb rocksdbjni
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-make-with-folly:
|
||||
if: needs.config.outputs.only_job == 'build-linux-make-with-folly' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-make-with-folly' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 32-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=64gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -150,13 +152,14 @@ jobs:
|
||||
- run: USE_FOLLY=1 LIB_MODE=static V=1 make -j64 check
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-make-with-folly-lite-no-test:
|
||||
if: needs.config.outputs.only_job == 'build-linux-make-with-folly-lite-no-test' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-make-with-folly-lite-no-test' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -169,13 +172,14 @@ jobs:
|
||||
- run: USE_FOLLY_LITE=1 EXTRA_CXXFLAGS=-DGLOG_USE_GLOG_EXPORT V=1 make -j32 all
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-cmake-with-folly-coroutines:
|
||||
if: needs.config.outputs.only_job == 'build-linux-cmake-with-folly-coroutines' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-cmake-with-folly-coroutines' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 32-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=64gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -193,8 +197,9 @@ jobs:
|
||||
- run: "(mkdir build && cd build && cmake -DUSE_COROUTINES=1 -DWITH_GFLAGS=1 -DROCKSDB_BUILD_SHARED=0 -DPORTABLE=ON .. && make VERBOSE=1 -j64 && ctest -j64)"
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-cmake-with-benchmark-no-thread-status:
|
||||
if: needs.config.outputs.only_job == 'build-linux-cmake-with-benchmark-no-thread-status' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-cmake-with-benchmark-no-thread-status' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
@@ -203,7 +208,7 @@ jobs:
|
||||
matrix:
|
||||
shard: [0, 1, 2, 3]
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -217,13 +222,16 @@ jobs:
|
||||
run: cd build && ctest -j20 -I ${{ matrix.shard }},,4
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
with:
|
||||
artifact-prefix: "${{ github.job }}-shard${{ matrix.shard }}"
|
||||
build-linux-encrypted_env-no_compression:
|
||||
if: needs.config.outputs.only_job == 'build-linux-encrypted_env-no_compression' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-encrypted_env-no_compression' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -235,14 +243,15 @@ jobs:
|
||||
- run: "./sst_dump --help | grep -E -q 'Supported built-in compression types: kNoCompression$' # Verify no compiled in compression\n"
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
# ======================== Linux No Test Runs ======================= #
|
||||
build-linux-release:
|
||||
if: needs.config.outputs.only_job == 'build-linux-release' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-release' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -267,13 +276,14 @@ jobs:
|
||||
- run: if ./trace_analyzer --version; then false; else true; fi
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-clang-13-no_test_run:
|
||||
if: needs.config.outputs.only_job == 'build-linux-clang-13-no_test_run' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-clang-13-no_test_run' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 8-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=16gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -288,13 +298,14 @@ jobs:
|
||||
- run: CC=clang-13 CXX=clang++-13 USE_CLANG=1 EXTRA_CXXFLAGS=-stdlib=libc++ EXTRA_LDFLAGS=-stdlib=libc++ DEBUG_LEVEL=0 make -j32 shared_lib
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-clang-21-no_test_run:
|
||||
if: needs.config.outputs.only_job == 'build-linux-clang-21-no_test_run' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-clang-21-no_test_run' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:24.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:24.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -354,13 +365,14 @@ jobs:
|
||||
CLANG_FORMAT_BINARY=clang-format-21
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-gcc-14-no_test_run:
|
||||
if: needs.config.outputs.only_job == 'build-linux-gcc-14-no_test_run' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-gcc-14-no_test_run' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:24.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:24.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -371,11 +383,12 @@ jobs:
|
||||
- run: CC=gcc-14 CXX=g++-14 V=1 make -j32 all microbench
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
|
||||
# ======================== Linux Other Checks ======================= #
|
||||
|
||||
build-linux-unity-and-headers:
|
||||
if: needs.config.outputs.only_job == 'build-linux-unity-and-headers' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-unity-and-headers' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu
|
||||
@@ -393,8 +406,9 @@ jobs:
|
||||
- run: make V=1 -j8 -k check-headers
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-mini-crashtest:
|
||||
if: needs.config.outputs.only_job == 'build-linux-mini-crashtest' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-mini-crashtest' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu
|
||||
@@ -407,7 +421,7 @@ jobs:
|
||||
- crash_test_target: blackbox_crash_test
|
||||
crash_duration: 240
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=8gb --ulimit nofile=1048576:1048576
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -428,9 +442,12 @@ jobs:
|
||||
USE_COROUTINES=1 USE_FOLLY=1 LIB_MODE=static make V=1 -j8 CRASH_TEST_EXT_ARGS='--duration=${{ matrix.crash_duration }} --max_key=2500000' ${{ matrix.crash_test_target }}
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
with:
|
||||
artifact-prefix: "${{ github.job }}-${{ matrix.crash_test_target }}"
|
||||
# ======================= Linux with Sanitizers ===================== #
|
||||
build-linux-clang21-asan-ubsan:
|
||||
if: needs.config.outputs.only_job == 'build-linux-clang21-asan-ubsan' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-clang21-asan-ubsan' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 32-core-ubuntu
|
||||
@@ -439,7 +456,7 @@ jobs:
|
||||
matrix:
|
||||
shard: [0, 1, 2]
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:24.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:24.1
|
||||
options: --shm-size=64gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -453,8 +470,11 @@ jobs:
|
||||
CI_TOTAL_SHARDS: 3
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
with:
|
||||
artifact-prefix: "${{ github.job }}-shard${{ matrix.shard }}"
|
||||
build-linux-clang21-mini-tsan:
|
||||
if: needs.config.outputs.only_job == 'build-linux-clang21-mini-tsan' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-clang21-mini-tsan' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 32-core-ubuntu
|
||||
@@ -463,7 +483,7 @@ jobs:
|
||||
matrix:
|
||||
shard: [0, 1, 2]
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:24.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:24.1
|
||||
options: --shm-size=64gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -477,13 +497,16 @@ jobs:
|
||||
CI_TOTAL_SHARDS: 3
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
with:
|
||||
artifact-prefix: "${{ github.job }}-shard${{ matrix.shard }}"
|
||||
build-linux-static_lib-alt_namespace-status_checked:
|
||||
if: needs.config.outputs.only_job == 'build-linux-static_lib-alt_namespace-status_checked' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-static_lib-alt_namespace-status_checked' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -494,10 +517,10 @@ jobs:
|
||||
- run: ASSERT_STATUS_CHECKED=1 TEST_UINT128_COMPAT=1 ROCKSDB_MODIFY_NPHASH=1 LIB_MODE=static OPT="-DROCKSDB_USE_STD_SEMAPHORES -DROCKSDB_NAMESPACE=alternative_rocksdb_ns" make V=1 -j24 check
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
# ========================= MacOS build only ======================== #
|
||||
# NOTE: build-macos-cmake (with tests) is in "nightly" to save resources
|
||||
build-macos:
|
||||
if: needs.config.outputs.only_job == 'build-macos' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-macos' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on: macos-15-xlarge
|
||||
env:
|
||||
@@ -517,10 +540,49 @@ jobs:
|
||||
run: ulimit -S -n `ulimit -H -n` && make V=1 J=16 -j8 all
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
# ========================= MacOS with Tests ======================== #
|
||||
build-macos-cmake:
|
||||
if: needs.config.outputs.only_job == 'build-macos-cmake' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on: macos-15-xlarge
|
||||
strategy:
|
||||
matrix:
|
||||
run_sharded_tests: [0, 1, 2, 3]
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
- uses: maxim-lobanov/setup-xcode@v1.6.0
|
||||
with:
|
||||
xcode-version: 16.4.0
|
||||
- uses: "./.github/actions/setup-ccache"
|
||||
with:
|
||||
cache-key-prefix: macos-cmake
|
||||
- uses: "./.github/actions/increase-max-open-files-on-macos"
|
||||
- uses: "./.github/actions/install-gflags-on-macos"
|
||||
- uses: "./.github/actions/pre-steps-macos"
|
||||
- name: cmake generate project file
|
||||
run: ulimit -S -n `ulimit -H -n` && mkdir build && cd build && cmake -DWITH_GFLAGS=1 ..
|
||||
- name: Build tests
|
||||
run: cd build && make VERBOSE=1 -j8
|
||||
- name: Run shard 0 out of 4 test shards
|
||||
run: ulimit -S -n `ulimit -H -n` && cd build && ctest -j8 -I 0,,4
|
||||
if: ${{ matrix.run_sharded_tests == 0 }}
|
||||
- name: Run shard 1 out of 4 test shards
|
||||
run: ulimit -S -n `ulimit -H -n` && cd build && ctest -j8 -I 1,,4
|
||||
if: ${{ matrix.run_sharded_tests == 1 }}
|
||||
- name: Run shard 2 out of 4 test shards
|
||||
run: ulimit -S -n `ulimit -H -n` && cd build && ctest -j8 -I 2,,4
|
||||
if: ${{ matrix.run_sharded_tests == 2 }}
|
||||
- name: Run shard 3 out of 4 test shards
|
||||
run: ulimit -S -n `ulimit -H -n` && cd build && ctest -j8 -I 3,,4
|
||||
if: ${{ matrix.run_sharded_tests == 3 }}
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
# ======================== Windows with Tests ======================= #
|
||||
# NOTE: some windows jobs are in "nightly" to save resources
|
||||
build-windows-msvc:
|
||||
if: needs.config.outputs.only_job == 'build-windows-msvc' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-windows-msvc' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on: windows-8-core
|
||||
strategy:
|
||||
@@ -546,12 +608,12 @@ jobs:
|
||||
run-java: ${{ matrix.run_java }}
|
||||
# ============================ Java Jobs ============================ #
|
||||
build-linux-java:
|
||||
if: needs.config.outputs.only_job == 'build-linux-java' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-java' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=8gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -569,12 +631,12 @@ jobs:
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
build-linux-java-static:
|
||||
if: needs.config.outputs.only_job == 'build-linux-java-static' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-java-static' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=8gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
@@ -592,7 +654,7 @@ jobs:
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
build-macos-java:
|
||||
if: needs.config.outputs.only_job == 'build-macos-java' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-macos-java' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on: macos-15-xlarge
|
||||
env:
|
||||
@@ -618,8 +680,9 @@ jobs:
|
||||
run: make V=1 J=16 -j16 jtest
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-macos-java-static:
|
||||
if: needs.config.outputs.only_job == 'build-macos-java-static' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-macos-java-static' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on: macos-15-xlarge
|
||||
steps:
|
||||
@@ -643,8 +706,9 @@ jobs:
|
||||
run: make V=1 J=16 -j16 rocksdbjavastaticosx
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-macos-java-static-universal:
|
||||
if: needs.config.outputs.only_job == 'build-macos-java-static-universal' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-macos-java-static-universal' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on: macos-15-xlarge
|
||||
steps:
|
||||
@@ -668,8 +732,9 @@ jobs:
|
||||
run: make V=1 J=16 -j16 rocksdbjavastaticosx_ub
|
||||
- uses: "./.github/actions/teardown-ccache"
|
||||
if: always()
|
||||
- uses: "./.github/actions/post-steps"
|
||||
build-linux-java-pmd:
|
||||
if: needs.config.outputs.only_job == 'build-linux-java-pmd' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-java-pmd' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu
|
||||
@@ -696,7 +761,7 @@ jobs:
|
||||
name: maven-site
|
||||
path: "${{ github.workspace }}/java/target/site"
|
||||
build-linux-arm:
|
||||
if: needs.config.outputs.only_job == 'build-linux-arm' || (needs.config.outputs.only_job == '' && github.repository_owner == 'meta')
|
||||
if: needs.config.outputs.only_job == 'build-linux-arm' || (needs.config.outputs.only_job == '' && github.repository_owner == 'facebook')
|
||||
needs: config
|
||||
runs-on:
|
||||
labels: 4-core-ubuntu-arm
|
||||
@@ -712,3 +777,4 @@ jobs:
|
||||
run: ccache -s
|
||||
if: always()
|
||||
shell: bash
|
||||
- uses: "./.github/actions/post-steps"
|
||||
@@ -1,4 +1,4 @@
|
||||
name: meta/rocksdb/weekly
|
||||
name: facebook/rocksdb/weekly
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 9 * * 0
|
||||
@@ -6,14 +6,15 @@ on:
|
||||
permissions: {}
|
||||
jobs:
|
||||
build-linux-valgrind:
|
||||
if: ${{ github.repository_owner == 'meta' }}
|
||||
if: ${{ github.repository_owner == 'facebook' }}
|
||||
runs-on:
|
||||
labels: 16-core-ubuntu
|
||||
timeout-minutes: 840
|
||||
container:
|
||||
image: ghcr.io/meta/rocksdb_ubuntu:22.1
|
||||
image: ghcr.io/facebook/rocksdb_ubuntu:22.1
|
||||
options: --shm-size=32gb
|
||||
steps:
|
||||
- uses: actions/checkout@v4.1.0
|
||||
- uses: "./.github/actions/pre-steps"
|
||||
- run: make V=1 -j20 valgrind_test
|
||||
- uses: "./.github/actions/post-steps"
|
||||
@@ -259,7 +259,6 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
|
||||
"tools/sst_dump_tool.cc",
|
||||
"trace_replay/block_cache_tracer.cc",
|
||||
"trace_replay/io_tracer.cc",
|
||||
"trace_replay/trace_analyzer.cc",
|
||||
"trace_replay/trace_record.cc",
|
||||
"trace_replay/trace_record_handler.cc",
|
||||
"trace_replay/trace_record_result.cc",
|
||||
@@ -282,7 +281,6 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
|
||||
"util/file_checksum_helper.cc",
|
||||
"util/hash.cc",
|
||||
"util/io_dispatcher_imp.cc",
|
||||
"util/io_prefetch_scheduler.cc",
|
||||
"util/murmurhash.cc",
|
||||
"util/random.cc",
|
||||
"util/rate_limiter.cc",
|
||||
@@ -316,7 +314,6 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
|
||||
"utilities/convenience/info_log_finder.cc",
|
||||
"utilities/copy_engine/copy_engine.cc",
|
||||
"utilities/counted_fs.cc",
|
||||
"utilities/db_split_merge.cc",
|
||||
"utilities/debug.cc",
|
||||
"utilities/env_mirror.cc",
|
||||
"utilities/env_timed.cc",
|
||||
@@ -324,8 +321,6 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
|
||||
"utilities/fault_injection_fs.cc",
|
||||
"utilities/fault_injection_secondary_cache.cc",
|
||||
"utilities/leveldb_options/leveldb_options.cc",
|
||||
"utilities/live_tune/live_tune_options_helper.cc",
|
||||
"utilities/live_tune/live_tuner.cc",
|
||||
"utilities/memory/memory_util.cc",
|
||||
"utilities/merge_operators.cc",
|
||||
"utilities/merge_operators/bytesxor.cc",
|
||||
@@ -390,22 +385,22 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
|
||||
"utilities/write_batch_with_index/write_batch_with_index.cc",
|
||||
"utilities/write_batch_with_index/write_batch_with_index_internal.cc",
|
||||
], deps=[
|
||||
"fbsource//xplat/folly/container:f14_hash",
|
||||
"fbsource//xplat/folly/coro:baton",
|
||||
"fbsource//xplat/folly/coro:blocking_wait",
|
||||
"fbsource//xplat/folly/coro:collect",
|
||||
"fbsource//xplat/folly/coro:coroutine",
|
||||
"fbsource//xplat/folly/coro:nothrow",
|
||||
"fbsource//xplat/folly/coro:task",
|
||||
"fbsource//xplat/folly/executors/thread_factory:named_thread_factory",
|
||||
"fbsource//xplat/folly/executors:io_executor",
|
||||
"fbsource//xplat/folly/executors:io_thread_pool_executor",
|
||||
"fbsource//xplat/folly/io/async:async_base",
|
||||
"fbsource//xplat/folly/io/async:event_base_manager",
|
||||
"fbsource//xplat/folly/io/async:io_uring_backend",
|
||||
"fbsource//xplat/folly/io/async:request_context",
|
||||
"fbsource//xplat/folly/synchronization:distributed_mutex",
|
||||
"fbsource//xplat/folly:executor",
|
||||
"//folly/container:f14_hash",
|
||||
"//folly/coro:baton",
|
||||
"//folly/coro:blocking_wait",
|
||||
"//folly/coro:collect",
|
||||
"//folly/coro:coroutine",
|
||||
"//folly/coro:nothrow",
|
||||
"//folly/coro:task",
|
||||
"//folly/executors/thread_factory:named_thread_factory",
|
||||
"//folly/executors:io_executor",
|
||||
"//folly/executors:io_thread_pool_executor",
|
||||
"//folly/io/async:async_base",
|
||||
"//folly/io/async:event_base_manager",
|
||||
"//folly/io/async:io_uring_backend",
|
||||
"//folly/io/async:request_context",
|
||||
"//folly/synchronization:distributed_mutex",
|
||||
"//folly:executor",
|
||||
], headers=glob(["**/*.h"]), link_whole=False, extra_test_libs=False)
|
||||
|
||||
cpp_library_wrapper(name="rocksdb_whole_archive_lib", srcs=[], deps=[":rocksdb_lib"], headers=[], link_whole=True, extra_test_libs=False)
|
||||
@@ -533,8 +528,6 @@ rocks_cpp_library_wrapper(name="rocksdb_stress_lib", srcs=[
|
||||
|
||||
cpp_binary_wrapper(name="ldb", srcs=["tools/ldb.cc"], deps=[":rocksdb_tools_lib"], extra_preprocessor_flags=[], extra_bench_libs=False)
|
||||
|
||||
cpp_binary_wrapper(name="db_split_merge", srcs=["tools/db_split_merge.cc"], deps=[":rocksdb_lib"], extra_preprocessor_flags=[], extra_bench_libs=False)
|
||||
|
||||
cpp_binary_wrapper(name="db_stress", srcs=["db_stress_tool/db_stress.cc"], deps=[":rocksdb_stress_lib"], extra_preprocessor_flags=[], extra_bench_libs=False)
|
||||
|
||||
cpp_binary_wrapper(name="db_bench", srcs=["tools/db_bench.cc"], deps=[":rocksdb_tools_lib"], extra_preprocessor_flags=[], extra_bench_libs=False)
|
||||
@@ -5095,12 +5088,6 @@ cpp_unittest_wrapper(name="db_secondary_test",
|
||||
extra_compiler_flags=[])
|
||||
|
||||
|
||||
cpp_unittest_wrapper(name="db_split_merge_test",
|
||||
srcs=["utilities/db_split_merge_test.cc"],
|
||||
deps=[":rocksdb_test_lib"],
|
||||
extra_compiler_flags=[])
|
||||
|
||||
|
||||
cpp_unittest_wrapper(name="db_sst_test",
|
||||
srcs=["db/db_sst_test.cc"],
|
||||
deps=[":rocksdb_test_lib"],
|
||||
@@ -5397,12 +5384,6 @@ cpp_unittest_wrapper(name="listener_test",
|
||||
extra_compiler_flags=[])
|
||||
|
||||
|
||||
cpp_unittest_wrapper(name="live_tuner_test",
|
||||
srcs=["utilities/live_tune/live_tuner_test.cc"],
|
||||
deps=[":rocksdb_test_lib"],
|
||||
extra_compiler_flags=[])
|
||||
|
||||
|
||||
cpp_unittest_wrapper(name="log_test",
|
||||
srcs=["db/log_test.cc"],
|
||||
deps=[":rocksdb_test_lib"],
|
||||
|
||||
@@ -16,7 +16,7 @@ This document provides guidance for generating and reviewing code in the RocksDB
|
||||
|
||||
**Refactoring traps:** At least in production code, avoid constructs that could allow existing code to unexpectedly, quietly change meaning.
|
||||
Specifically:
|
||||
* Avoid new defaulted parameters. This is the #1 trap on refactoring! (Permitted exception: optional outputs that are generally safe to ignore.)
|
||||
* Avoid new defaulted parameters. This is the #1 trap on refactoring!
|
||||
* Avoid static_cast, reinterpret_cast, and C-style casts; static_cast_with_check, up_cast, and lossless_cast from cast_util.h are preferred.
|
||||
* Avoid declared type `auto` (`auto&`, `auto*` OK).
|
||||
|
||||
@@ -24,8 +24,7 @@ Specifically:
|
||||
|
||||
**Comprehensive Coverage:** Every change should include appropriate test coverage. This includes unit tests for isolated functionality, integration tests for component interactions, and stress tests for concurrency and performance validation. Reviewers will ask for additional tests if coverage is insufficient.
|
||||
|
||||
**Edge Cases and Failure Modes:** Tests should explicitly cover edge cases, boundary conditions, and potential failure scenarios. This is especially important for changes affecting core database operations, compaction, or recovery logic. For non-OK Statuses, prefer comparing code() rather than using ASSERT_TRUE
|
||||
which is bad for debugging.
|
||||
**Edge Cases and Failure Modes:** Tests should explicitly cover edge cases, boundary conditions, and potential failure scenarios. This is especially important for changes affecting core database operations, compaction, or recovery logic.
|
||||
|
||||
**Platform-Specific Testing:** RocksDB supports multiple platforms (Linux, Windows, macOS) and compilers (GCC, Clang, MSVC). Changes should be tested across relevant platforms, particularly when touching platform-specific code or using compiler-specific features.
|
||||
|
||||
@@ -437,8 +436,7 @@ architectures.
|
||||
objects are properly checked. This catches missing error handling that can
|
||||
lead to silent data corruption. Merely building with ASSERT_STATUS_CHECKED=1
|
||||
accomplishes nothing; it enables a runtime check. New unit tests missing
|
||||
Status checks is a common failure point, even from agents. Avoid new uses
|
||||
of PermitUncheckedError(). That's the lazy solution.
|
||||
Status checks is a common failure point, even from agents.
|
||||
|
||||
### Monitoring make check progress
|
||||
* Use `make check-progress` to get machine-parseable JSON progress while
|
||||
|
||||
+2
-16
@@ -522,6 +522,8 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")
|
||||
endif()
|
||||
endif()
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||
add_definitions(-DOS_SOLARIS)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD")
|
||||
add_definitions(-DOS_GNU_KFREEBSD)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
@@ -648,9 +650,6 @@ if(USE_FOLLY)
|
||||
exec_program(ls ARGS -d ${FOLLY_INST_PATH}/../glog* OUTPUT_VARIABLE
|
||||
GLOG_INST_PATH)
|
||||
set(Boost_DIR ${BOOST_INST_PATH}/lib/cmake/Boost-1.83.0)
|
||||
# Boost's per-library CMake configs find their dependencies (e.g.
|
||||
# boost_assert) only through the package search path.
|
||||
set(CMAKE_PREFIX_PATH ${BOOST_INST_PATH} ${CMAKE_PREFIX_PATH})
|
||||
if(EXISTS ${FMT_INST_PATH}/lib64)
|
||||
set(fmt_DIR ${FMT_INST_PATH}/lib64/cmake/fmt)
|
||||
else()
|
||||
@@ -697,13 +696,7 @@ if(USE_FOLLY)
|
||||
exec_program(sed ARGS -i 's/gflags_shared//g'
|
||||
${FOLLY_INST_PATH}/lib/cmake/folly/folly-targets.cmake)
|
||||
|
||||
# folly-config.cmake only checks for gflags under a target name that this
|
||||
# install doesn't define, then falls back to our Findgflags.cmake, which
|
||||
# mistakes the gflags_static target name for a library path. gflags is
|
||||
# resolved below instead.
|
||||
set(CMAKE_DISABLE_FIND_PACKAGE_gflags TRUE)
|
||||
include(${FOLLY_INST_PATH}/lib/cmake/folly/folly-config.cmake)
|
||||
unset(CMAKE_DISABLE_FIND_PACKAGE_gflags)
|
||||
|
||||
# Fix gflags library name for debug builds. The getdeps gflags shared
|
||||
# library is versioned (e.g. libgflags_debug.so.2.3), so resolve the
|
||||
@@ -1000,7 +993,6 @@ set(SOURCES
|
||||
tools/trace_analyzer_tool.cc
|
||||
trace_replay/block_cache_tracer.cc
|
||||
trace_replay/io_tracer.cc
|
||||
trace_replay/trace_analyzer.cc
|
||||
trace_replay/trace_record_handler.cc
|
||||
trace_replay/trace_record_result.cc
|
||||
trace_replay/trace_record.cc
|
||||
@@ -1021,7 +1013,6 @@ set(SOURCES
|
||||
util/dynamic_bloom.cc
|
||||
util/hash.cc
|
||||
util/io_dispatcher_imp.cc
|
||||
util/io_prefetch_scheduler.cc
|
||||
util/murmurhash.cc
|
||||
util/random.cc
|
||||
util/rate_limiter.cc
|
||||
@@ -1051,10 +1042,7 @@ set(SOURCES
|
||||
utilities/cassandra/format.cc
|
||||
utilities/cassandra/merge_operator.cc
|
||||
utilities/checkpoint/checkpoint_impl.cc
|
||||
utilities/live_tune/live_tune_options_helper.cc
|
||||
utilities/live_tune/live_tuner.cc
|
||||
utilities/compaction_filters.cc
|
||||
utilities/db_split_merge.cc
|
||||
utilities/sorted_run_builder/sorted_run_builder.cc
|
||||
utilities/compaction_filters/remove_emptyvalue_compactionfilter.cc
|
||||
utilities/counted_fs.cc
|
||||
@@ -1511,7 +1499,6 @@ if(WITH_TESTS)
|
||||
db/db_compaction_test.cc
|
||||
db/db_compaction_abort_test.cc
|
||||
db/db_clip_test.cc
|
||||
utilities/db_split_merge_test.cc
|
||||
db/db_dynamic_level_test.cc
|
||||
db/db_encryption_test.cc
|
||||
db/db_etc2_test.cc
|
||||
@@ -1662,7 +1649,6 @@ if(WITH_TESTS)
|
||||
utilities/cassandra/cassandra_row_merge_test.cc
|
||||
utilities/cassandra/cassandra_serialize_test.cc
|
||||
utilities/checkpoint/checkpoint_test.cc
|
||||
utilities/live_tune/live_tuner_test.cc
|
||||
utilities/copy_engine/copy_engine_test.cc
|
||||
utilities/sorted_run_builder/sorted_run_builder_test.cc
|
||||
utilities/env_timed_test.cc
|
||||
|
||||
+17
-129
@@ -1,117 +1,6 @@
|
||||
# Rocksdb Change Log
|
||||
> NOTE: Entries for next release do not go here. Follow instructions in `unreleased_history/README.txt`
|
||||
|
||||
## 11.14.0 (11/05/2026)
|
||||
### New Features
|
||||
* Added experimental `SetAsyncReadCPUTimeEnabled()`: the next async or coroutine read started on the thread records its CPU time in `PerfContext::get_cpu_nanos` at any perf level except `kDisable`, without turning on the other timers of `kEnableTimeAndCPUTimeExceptForMutex`.
|
||||
* Added `SplitDB()`, `DeleteSplitRanges()`, and `MergeDB()` in `rocksdb/utilities/db_split_merge.h`, plus a `db_split_merge` command-line tool, for moving selected column-family key ranges into a new DB and copying ranges into existing column families.
|
||||
* Added opt-in sampled logging of long-held DB-wide mutexes under `StatsLevel::kAll`, with a runtime-changeable `mutex_hold_log_threshold_us` DB option defaulting to 0 (disabled).
|
||||
* Add experimental live tuning of a DB's options (`StartLiveTuneCycle()`, `GetLiveTuneStatus()`, `StopLiveTuneCycle()` in `include/rocksdb/live_tune.h`): one call runs a cycle that measures the DB, asks an application-provided `LiveTuneAdvisor` for option changes, applies them, and reverts them when they break the application's constraints or do not prove better.
|
||||
* Added `CompactionFilter::GetMergeOrder()` and `CompactionFilterFactory::GetMergeOrder()` to optionally run the merge operator before the compaction filter during compaction, so that the filter sees merge results. The default behavior is unchanged.
|
||||
* Parallel compression (`CompressionOptions::parallel_threads > 1`) now works with a `user_defined_index_factory` whose builders support it, including the built-in trie index. Previously a custom index always forced single-threaded compression.
|
||||
* Added option `reject_too_old_file` to `IngestExternalFileOptions` and `ImportColumnFamilyOptions` to reject files whose data is already older than the column family's `periodic_compaction_seconds` (or `ttl` for FIFO compaction).
|
||||
* Added BlobDB support for remote compaction. Blob garbage collection uses the
|
||||
cutoff computed by the primary; workers receiving legacy input without a cutoff
|
||||
safely disable blob garbage collection for that job. When the primary rejects a
|
||||
remote blob result because its metadata, files, or capabilities fail validation,
|
||||
it reruns the compaction locally, so `CompactRange` and `CompactFiles` succeed.
|
||||
`CompactionService` `kFailure` semantics are unchanged; ZippyDB production also
|
||||
maps service failures to local fallback through `HandleFailure(FALLBACK_LOCAL)`.
|
||||
* `CompactRangeOptions::skip_missing_blob_files` enables offline repair that deletes values referencing integrated external blob files absent from Version metadata, preserves available wide entity columns, and rewrites selected SSTs locally, bypassing `DBOptions::compaction_service`. It defaults to false; FIFO compaction and legacy BlobDB are unsupported.
|
||||
* Added `db_ownership_start_time` and `data_file_provenance` (decoded by `DataFileProvenance`) to `SstFileMetaData`, recording when the DB began holding each SST file and how it got the file (e.g. flush, compaction, ingestion, or import).
|
||||
* Added `TableFactory::IsTableBuilderSupported()` and `ExternalTableFactory::IsTableBuilderSupported()` for table factories that only read ingested or imported files. A column family whose factory returns false must set `disallow_memtable_writes`, is never scheduled for automatic compaction, does not stall writes for L0 files or pending compaction bytes, and returns `NotSupported` from `CompactRange()` and `CompactFiles()` instead of failing a background compaction.
|
||||
* trace_analyzer: new `--analyze_put_entity` flag analyzes PutEntity queries (previously their statistics were neither enabled nor disabled explicitly).
|
||||
* Added `TraceOptions::include_read_write_options`: query traces can record the main `ReadOptions` and `WriteOptions` of each traced call (e.g. `fill_cache`, `disableWAL`), which replay then uses instead of default options.
|
||||
|
||||
### Public API Changes
|
||||
* Added `GetEncodedEntrySize()` and an `EncodeEntry()` overload that writes internal keys into caller-owned buffers without allocating on success.
|
||||
* Added `Env::Priority::READ` and `ThreadStatus::READ_PRIORITY` for a dedicated Env-managed read-work thread pool. `Env::Priority::USER` remains reserved for internal statistics and is not backed by a thread pool.
|
||||
* Added experimental `MultiScanArgs::use_parallel_async_io_block_decompression` for materializing asynchronously prefetched data blocks, including decompression, in parallel on the `Env::Priority::READ` thread pool. A zero-sized pool preserves inline materialization.
|
||||
* Added the experimental `IndexFactory` interface (`include/rocksdb/index_factory.h`) for pluggable SST indexes; the `UserDefinedIndex*` names remain as aliases. `BlockBasedTableOptions::index_mode` chooses which indexes an SST is built with and which one reads use by default, superseding the now-deprecated `use_udi_as_primary_index` and `fail_if_no_udi_on_open`. `ReadOptions::read_index` overrides that choice per read, and the `standard_index_is_stub` table property marks SSTs built with `kCustomOnly`. Both options are also available in the C API.
|
||||
* Added experimental `DB::GetEntityWithMetadata()` and `DB::MultiGetEntityWithMetadata()`, the wide-column entity counterparts of `DB::GetWithMetadata()` and `DB::MultiGetWithMetadata()` with opt-in explicit-snapshot newer-version detection. Requesting key timestamps returns `NotSupported`.
|
||||
* Removed support for building on Solaris, which had not compiled since 5.18. Removed RocksJava `Environment.isSolaris()`.
|
||||
|
||||
### Behavior Changes
|
||||
* With `ReadOptions::async_io`, `MultiGet` now reads data blocks of direct-IO files with asynchronous reads (`FSRandomAccessFile::ReadAsync`) instead of a synchronous `MultiRead`. Each block read is aligned separately rather than merged with adjacent reads. The bytes read are still charged to `DBOptions::rate_limiter` at `ReadOptions::rate_limiter_priority`.
|
||||
* Asynchronous file reads (`FSRandomAccessFile::ReadAsync`, used with `ReadOptions::async_io` by `MultiGet` and iterator prefetching) are now charged to `DBOptions::rate_limiter` at `ReadOptions::rate_limiter_priority`, like synchronous reads. A read is charged once the file system accepts it.
|
||||
* `CreateColumnFamily()` and `CreateColumnFamilies()` now run the table factory option validation that `DB::Open()` runs, so they return `InvalidArgument` instead of creating a column family that the next `DB::Open()` would reject. External table factories wrapped by `NewExternalTableFactory()` now receive `ValidateOptions()` calls.
|
||||
* With `CompactionOptionsFIFO::allow_trivial_copy_when_change_temperature`, each file copied for a temperature change is now reported to `EventListener::OnTableFileCreationStarted()` and `OnTableFileCreated()` (with the original file's table properties) and included in `CompactionJobInfo::table_properties`.
|
||||
* `DB::GetMergeOperands()` now resets only the `merge_operands` entries it fills, instead of all `expected_max_number_of_operands` entries. Entries past `*number_of_operands`, and the whole array on a non-OK result, are left as the caller passed them.
|
||||
* The JSON written to the info LOG by `EventLogger` (`EVENT_LOG_v1` lines) and by `VersionEdit::DebugJSON()` now escapes special characters in keys and string values, and writes non-finite floating-point values as `null`, so the output is always valid JSON.
|
||||
* Improved how `periodic_compaction_phase_recovery_percent` spreads catch-up periodic compactions after it is enabled or changed (or the DB is reopened). This reduces a transient burst in periodic compactions when many DBs make such a change at once.
|
||||
* The new DB option `use_separate_remote_compaction_pool` defaults to false and can be changed through `SetDBOptions()` for newly scheduled jobs. When enabled with CompactionService, remote jobs use a dedicated pool and each local subcompaction uses LOW/BOTTOM and counts against the DB compaction limit. Existing jobs finish using their original scheduling model.
|
||||
* `DB::SetOptions()` now returns OK without writing a new OPTIONS file or installing a new SuperVersion when the call changes no option value, as `DB::SetDBOptions()` already does. Calls that set an object option, such as `table_factory` or one of its fields, are still applied in full. After a failed OPTIONS file write, the next `SetOptions()` or `SetDBOptions()` call writes the file even if no option value changes.
|
||||
* Custom index factories are rejected with user-defined timestamps in every index mode except `kStandardOnly`, which ignores the factory. Custom-index block-cache hits, misses, and adds now contribute to `BLOCK_CACHE_INDEX_*` instead of `BLOCK_CACHE_DATA_*`.
|
||||
Trie index construction returns `NotSupported` when a data-block offset or size exceeds `UINT32_MAX`, including when the trie is optional in `kStandardDefault`. Flush, compaction, and `SstFileWriter::Finish()` can therefore fail for such output; an SST larger than 4 GiB is not itself the rejection condition. File-size targets do not split L0 outputs or `SstFileWriter` outputs. Bound those outputs or disable trie construction with `kStandardOnly`.
|
||||
|
||||
### Bug Fixes
|
||||
* Fixed a race where `IngestExternalFiles()` with `atomic_replace_range` could delete an existing SST file that a concurrently picked compaction (e.g. a universal compaction outputting to L0) used as input, causing the compaction to fail with "Corruption: VersionBuilder: Cannot delete table file ... since it is not in the LSM tree" and putting the DB into read-only mode. Atomic range replacement now returns `NotSupported` with FIFO compaction.
|
||||
* Fixed blob direct write when sealing a blob file fails during a flush or a write: the flush left its memtables marked as being flushed, so no later flush picked them up and error recovery waited for them forever, and the blob file was dropped from tracking, so a retried flush could install table files whose blob file was never added to the MANIFEST.
|
||||
* Fixed blob direct write with more than one concurrent flush of a column family: a later flush sealed and published the blob files of the oldest pending memtable instead of its own, so flushes failed with `Corruption: VersionBuilder: Blob file #N already added` and the database stopped.
|
||||
* Fixed blob direct write when the `SstFileManager` space limit is reached while a blob file is sealed: the sealed blob file was deleted while memtables still referenced it, so reads of its values failed and the values were lost, and reporting the error could deadlock with a concurrent memtable switch. The seal and the write or flush now succeed and keep the file, and writes then stop with a `SpaceLimit` background error, so for blob direct write the limit is soft: usage can exceed it by up to about `blob_file_size` × `blob_direct_write_partitions` for each memtable not flushed yet. Also fixed a write batch that failed after writing some of its values to blob files: those blobs are now counted as garbage, so their blob file can still be deleted.
|
||||
* Values that retain external blob references now keep their original timestamps during history compaction, preventing blob key verification failures.
|
||||
* Fixed `DB::ClipColumnFamily()` leaving an empty-string key outside the kept range when it is the only key in an L0 SST file.
|
||||
* Fixed `format_version=8` with `ReverseBytewiseComparator`: a block's stored common key prefix could extend past a user key (one following longer user keys that extend it), so reads and iteration could miss that key (or its deletion, exposing an older value), and compactions could fail with `Corruption`. Files written by affected versions (11.10 through 11.13) are now read correctly, and new files no longer have this problem.
|
||||
* Fixed SST file times that could defer periodic compaction and TTL. Files written by `SstFileWriter`, flushed during WAL recovery, or recovered by `RepairDB` now record a file creation time. Files added by `IngestExternalFile()` or `CreateColumnFamilyWithImport()` now keep the creation and oldest ancestor times from the file or export metadata (capped at the current time) instead of taking the time they were added, so ingesting or importing old data can make it due for periodic compaction or TTL soon afterward. FIFO TTL compaction now also deletes ingested `SstFileWriter` files, which previously blocked TTL deletion of themselves and all newer files. Files copied by FIFO compaction for a temperature change now keep the original file's creation time.
|
||||
* Fixed a debug-build assertion failure and incorrect cache charge and block-cache byte statistics in release builds when a full, strict-capacity LRU cache with metadata charging creates an uncharged standalone handle, including during secondary-cache promotion.
|
||||
* Fixed atomic flushes of all column families when another column family is dropped while they wait: `CompactRange()` no longer fails with a "Column family dropped" error, and `WaitForCompact()` and DB close no longer return OK without flushing the remaining column families.
|
||||
* Fixed a bug where MemPurge returned with the DB mutex unlocked when the compaction filter created for flush did not ignore snapshots.
|
||||
* Fixed a crash in MultiScan `Iterator::Prepare()` with a single scan range without a limit when the DB has L0 files, and an assertion failure in debug builds when `Prepare()` is called on an already-positioned iterator. `Prepare()` now leaves the iterator invalid until it is positioned again (e.g. by `Seek()`).
|
||||
* Fixed `MultiGet` returning NotFound for existing keys that are outside the prefix extractor's domain, with partitioned filters, `whole_key_filtering=false`, and filter partitions cut together with index partitions (`decouple_partitioned_filters=false`, also the layout of files written by older versions). A filter partition holding only such keys is empty, and `MultiGet` treated every key mapped to it as absent. `Get` was not affected.
|
||||
* Fixed prepared external file ingestions retaining unrelated obsolete SSTs until commit or abort. Prepared ingestions now protect only their staged files from deletion.
|
||||
* Fixed data loss with `min_tombstones_for_range_conversion` and external file ingestion. An iterator whose view predated the ingestion could convert the deleted keys around the ingested keys into a range tombstone that deleted them. This happened when the file got no new sequence number (sequence number zero, `ingest_behind`, or `allow_db_generated_files`), and when an iterator was created during the ingestion.
|
||||
* Fixed a data loss bug where an iterator with `ReadOptions::read_tier = kMemtableTier` could, with `min_tombstones_for_range_conversion` enabled, insert a range tombstone that deleted live keys stored only in SST files. Read-path range tombstone conversion now runs only for iterators with `read_tier = kReadAllTier`.
|
||||
* Fixed a race with `recycle_log_file_num > 0` where an obsolete WAL could be reused for a new WAL while its old writer was still open. Closing the old writer then truncated the reused file to the old WAL's size, so writes in the new WAL past that point, including acknowledged `sync` writes, were lost on the next reopen.
|
||||
* Fixed remote compaction ignoring `preclude_last_level_data_seconds` and `preserve_internal_time_seconds`, which caused recent data to be written to the last level and recent sequence numbers to be zeroed. Takes effect once both the primary and the compaction worker are upgraded.
|
||||
* Fixed `DB::OpenAndCompact()` with `OpenAndCompactOptions::allow_resumption` not calling `EventListener::OnSubcompactionCompleted()` when the compaction fails to resume from its saved progress.
|
||||
* Fixed MANIFEST catch-up on secondary instances (`TryCatchUpWithPrimary()`) and follower instances installing a column family with no files and still returning OK. This happened when catch-up switched to a new MANIFEST and the primary deleted a file that MANIFEST lists before catch-up checked it, recording the deletion in a newer MANIFEST. Catch-up now keeps the column family's previous view until a complete state from the new MANIFEST is available.
|
||||
* Custom index blocks now reuse cached contents on SST reopen, and deprecated UDI boolean options can be cleared without overriding an explicitly configured index mode.
|
||||
Legacy UDI options copied from a factory can now be cleared before constructing a new factory without retaining the derived mode. The C API preserves both that rollback behavior and explicitly selected modes. OPTIONS files serialize equivalent legacy booleans for `kStandardDefault`, `kStandardRequired`, and `kCustomDefault` so older readers retain routing.
|
||||
Empty custom-index output retains the standard-index fallback in modes that write both indexes; custom-only output must remain nonempty. Default primary reads retain the table factory's precedence over a legacy per-read factory pointer, while explicit custom selectors still check its name.
|
||||
* Preserve legacy UDI routing when loading old OPTIONS files, and reject invalid index modes in standalone SST readers and writers. Table readers now charge the custom index blocks they own; a custom reader whose `ApproximateMemoryUsage()` already includes that block should override `IndexFactoryReader::MemoryUsageIncludesIndexBlock()` to return true so the block is not charged twice.
|
||||
Keep cached custom-index Slice views intact when a reader consumes its input. Register custom-index cache helpers without requiring a later change. Trie index size estimates now account for shared prefixes, preventing premature compaction file cuts, and reject data-block offsets or sizes exceeding the 32-bit on-disk limit instead of truncating them.
|
||||
|
||||
### Performance Improvements
|
||||
* With `ReadOptions::pin_data`, iterators over read-only DBs opened with `max_open_files = -1` and `allow_mmap_reads = true` no longer accumulate memory as they move across SST files.
|
||||
* On a read-write primary, `DB::GetSnapshot()` and `DB::ReleaseSnapshot()` no longer acquire the DB mutex in the common case. Secondary and follower snapshot creation retains the DB mutex needed to synchronize with view installation, while release remains sharded. The snapshot list is now split into 16 per-CPU shards, each with its own lock, so primary threads creating and releasing snapshots no longer serialize on one lock or wait behind flush, compaction, or other work holding the DB mutex. Snapshot-release maintenance is deferred to existing flush, compaction, and periodic maintenance paths. Primary snapshot creation serializes with the DB-mutex-held phases of external file ingestion but can proceed while the MANIFEST write temporarily releases that mutex.
|
||||
|
||||
|
||||
## 11.13.0 (10/21/2026)
|
||||
### New Features
|
||||
* Added `FileSystem::IsPreallocationSupported()`. A `FileSystem` that never preallocates file space can return false so that DB open skips reopening and truncating the last WAL file.
|
||||
|
||||
### Public API Changes
|
||||
* Added the experimental `DBOptions::track_options_file_number_in_manifest`
|
||||
rollout option (with C and Java bindings). The option is persisted in each
|
||||
OPTIONS file. When enabled, RocksDB durably creates an OPTIONS file and then
|
||||
commits its file number in MANIFEST. Column-family create/drop commits the
|
||||
configuration snapshot and membership in one MANIFEST record. A newer tracked
|
||||
OPTIONS file without a commit is ignored after a crash, while a newer OPTIONS
|
||||
file written with tracking disabled retains the legacy highest-numbered-file
|
||||
behavior. Batched column-family changes publish one snapshot; after partial
|
||||
success it can be a safe superset that persisted-options APIs filter against
|
||||
live MANIFEST membership. Ordinary `DB::Open` continues to use caller-supplied
|
||||
options and does not depend on the operational snapshot.
|
||||
* Added `EncodeEntry()`, `PackSequenceAndType()`, and `UnPackSequenceAndType()` in `rocksdb/utilities/types_util.h` to construct internal keys and pack or unpack their sequence numbers and entry types. `kInternalKeyFooterSize` exposes the footer size in bytes.
|
||||
* Added `ldb update_manifest --rebind_options_file --options_file=OPTIONS-<number>` for offline repair of a committed MANIFEST OPTIONS file number. Operators must select a trusted snapshot that has MANIFEST tracking enabled and provide any external DB/CF allocation roots that are not serialized in OPTIONS.
|
||||
|
||||
### Behavior Changes
|
||||
* With `max_bgerror_resume_count <= 0` (auto resume disabled), a retryable or file-scoped IO error during compaction or flush is now a hard background error that stops writes until `DB::Resume()` is called. Previously, compaction errors were silently retried, and flush errors with a healthy WAL were soft errors that let writes continue while flushes were stopped.
|
||||
|
||||
### Bug Fixes
|
||||
* Fixed two more `SstFileManager` trash accounting leaks: retrying a failed trash deletion immediately (for example with rate limiting disabled) after the file had disappeared, and a trash file that was deleted but whose directory sync then failed. In both cases the file's size stayed in the total trash size and tracked size until restart.
|
||||
* Fixed `SstFileManager` trash accounting leaking the size of a queued trash file that disappeared before deletion (for example because its directory was renamed). The leaked bytes stayed in the total trash size until restart, which could push every later deletion past `max_trash_db_ratio` and make it immediate instead of rate limited.
|
||||
* Fixed `MultiGet` with `ReadOptions::async_io` returning `NotSupported` when io_uring initialization or an asynchronous read submission fails. It now checks async I/O support on the reading thread and falls back to synchronous reads when needed.
|
||||
* Fixed subset checkpoints so their newest OPTIONS file lists only the column
|
||||
families retained by the checkpoint. This applies with both legacy
|
||||
highest-numbered OPTIONS selection and MANIFEST-tracked OPTIONS selection, and
|
||||
prevents `LoadLatestOptions` from recreating column families that the subset
|
||||
checkpoint intentionally dropped from its copied MANIFEST.
|
||||
|
||||
### Performance Improvements
|
||||
* Perf context counters and timers no longer call the thread-local init function of `perf_context` on every update. With `kEnableCount`, a counter update costs about 60% less.
|
||||
|
||||
|
||||
## 11.12.0 (10/07/2026)
|
||||
### New Features
|
||||
* Added `FullExternalTableFactory` and related full-mode external table APIs that preserve RocksDB internal keys, enabling external tables to support nonzero sequence numbers, point and single deletions, merge operands, blob indexes, wide-column entities, snapshots, live DB writes, and multi-level compactions.
|
||||
@@ -147,7 +36,6 @@ checkpoint intentionally dropped from its copied MANIFEST.
|
||||
### Performance Improvements
|
||||
* Single Get coroutine reads using non-mmap, non-direct I/O on a `kFSBuffer`-capable `FileSystem` now use `FSRandomAccessFile::SubmitReadAsync()` instead of falling back to synchronous `Read()`. When rate-limited, these reads acquire their full token budget before submission to preserve a single filesystem-owned buffer, which can make physical I/O burstier than reads using caller-provided buffers.
|
||||
|
||||
|
||||
## 11.11.0 (09/21/2026)
|
||||
### New Features
|
||||
* External tables now support DB-assigned global sequence numbers when `IngestExternalFileOptions::allow_global_seqno` is enabled, allowing overlapping external tables to be ingested across multiple levels when compactions are disabled. This includes the deprecated `write_global_seqno` path when the reader supplies the properties block's file offset.
|
||||
@@ -1156,7 +1044,7 @@ want to continue to use force enabling, they need to explicitly pass a `true` to
|
||||
* Overload the API CreateColumnFamilyWithImport() to support creating ColumnFamily by importing multiple ColumnFamilies It requires that CFs should not overlap in user key range.
|
||||
|
||||
### Behavior Changes
|
||||
* Change the default value for option `level_compaction_dynamic_level_bytes` to true. This affects users who use leveled compaction and do not set this option explicitly. These users may see additional background compactions following DB open. These compactions help to shape the LSM according to `level_compaction_dynamic_level_bytes` such that the size of each level Ln is approximately size of Ln-1 * `max_bytes_for_level_multiplier`. Turning on this option has other benefits too: see more detail in wiki: https://github.com/meta/rocksdb/wiki/Leveled-Compaction#option-level_compaction_dynamic_level_bytes-and-levels-target-size and in option comment in advanced_options.h (#11525).
|
||||
* Change the default value for option `level_compaction_dynamic_level_bytes` to true. This affects users who use leveled compaction and do not set this option explicitly. These users may see additional background compactions following DB open. These compactions help to shape the LSM according to `level_compaction_dynamic_level_bytes` such that the size of each level Ln is approximately size of Ln-1 * `max_bytes_for_level_multiplier`. Turning on this option has other benefits too: see more detail in wiki: https://github.com/facebook/rocksdb/wiki/Leveled-Compaction#option-level_compaction_dynamic_level_bytes-and-levels-target-size and in option comment in advanced_options.h (#11525).
|
||||
* For Leveled Compaction users, `CompactRange()` will now always try to compact to the last non-empty level. (#11468)
|
||||
For Leveled Compaction users, `CompactRange()` with `bottommost_level_compaction = BottommostLevelCompaction::kIfHaveCompactionFilter` will behave similar to `kForceOptimized` in that it will skip files created during this manual compaction when compacting files in the bottommost level. (#11468)
|
||||
* RocksDB will try to drop range tombstones during non-bottommost compaction when it is safe to do so. (#11459)
|
||||
@@ -1201,7 +1089,7 @@ For Leveled Compaction users, `CompactRange()` with `bottommost_level_compaction
|
||||
* Remove unnecessary constructor for CompressionOptions.
|
||||
|
||||
### Behavior changes
|
||||
* Changed default block cache size from an 8MB to 32MB LRUCache, which increases the default number of cache shards from 16 to 64. This change is intended to minimize cache mutex contention under stress conditions. See https://github.com/meta/rocksdb/wiki/Block-Cache for more information.
|
||||
* Changed default block cache size from an 8MB to 32MB LRUCache, which increases the default number of cache shards from 16 to 64. This change is intended to minimize cache mutex contention under stress conditions. See https://github.com/facebook/rocksdb/wiki/Block-Cache for more information.
|
||||
* For level compaction with `level_compaction_dynamic_level_bytes=true`, RocksDB now trivially moves levels down to fill LSM starting from bottommost level during DB open. See more in comments for option `level_compaction_dynamic_level_bytes` (#11321).
|
||||
* User-provided `ReadOptions` take effect for more reads of non-`CacheEntryRole::kDataBlock` blocks.
|
||||
* For level compaction with `level_compaction_dynamic_level_bytes=true`, RocksDB now drains unnecessary levels through background compaction automatically (#11340). This together with #11321 makes it automatic to migrate other compaction settings to level compaction with `level_compaction_dynamic_level_bytes=true`. In addition, a live DB that becomes smaller will now have unnecessary levels drained which can help to reduce read and space amp.
|
||||
@@ -1365,7 +1253,7 @@ For Leveled Compaction users, `CompactRange()` with `bottommost_level_compaction
|
||||
* Only periodic stats dumper triggered by options.stats_dump_period_sec will update stats interval. Ones triggered by DB::GetProperty() will not update stats interval and will report based on an interval since the last time stats dump period.
|
||||
|
||||
### Public API changes
|
||||
* Make kXXH3 checksum the new default, because it is faster on common hardware, especially with kCRC32c affected by a performance bug in some versions of clang (https://github.com/meta/rocksdb/issues/9891). DBs written with this new setting can be read by RocksDB 6.27 and newer.
|
||||
* Make kXXH3 checksum the new default, because it is faster on common hardware, especially with kCRC32c affected by a performance bug in some versions of clang (https://github.com/facebook/rocksdb/issues/9891). DBs written with this new setting can be read by RocksDB 6.27 and newer.
|
||||
* Refactor the classes, APIs and data structures for block cache tracing to allow a user provided trace writer to be used. Introduced an abstract BlockCacheTraceWriter class that takes a structured BlockCacheTraceRecord. The BlockCacheTraceWriter implementation can then format and log the record in whatever way it sees fit. The default BlockCacheTraceWriterImpl does file tracing using a user provided TraceWriter. More details in rocksdb/includb/block_cache_trace_writer.h.
|
||||
|
||||
## 7.7.0 (09/18/2022)
|
||||
@@ -1485,7 +1373,7 @@ For Leveled Compaction users, `CompactRange()` with `bottommost_level_compaction
|
||||
* Fix a bug in which backup/checkpoint can include a WAL deleted by RocksDB.
|
||||
* Fix a bug where concurrent compactions might cause unnecessary further write stalling. In some cases, this might cause write rate to drop to minimum.
|
||||
* Fix a bug in Logger where if dbname and db_log_dir are on different filesystems, dbname creation would fail wrt to db_log_dir path returning an error and fails to open the DB.
|
||||
* Fix a CPU and memory efficiency issue introduce by https://github.com/meta/rocksdb/pull/8336 which made InternalKeyComparator configurable as an unintended side effect.
|
||||
* Fix a CPU and memory efficiency issue introduce by https://github.com/facebook/rocksdb/pull/8336 which made InternalKeyComparator configurable as an unintended side effect.
|
||||
|
||||
## Behavior Change
|
||||
* In leveled compaction with dynamic levelling, level multiplier is not anymore adjusted due to oversized L0. Instead, compaction score is adjusted by increasing size level target by adding incoming bytes from upper levels. This would deprioritize compactions from upper levels if more data from L0 is coming. This is to fix some unnecessary full stalling due to drastic change of level targets, while not wasting write bandwidth for compaction while writes are overloaded.
|
||||
@@ -1524,7 +1412,7 @@ For Leveled Compaction users, `CompactRange()` with `bottommost_level_compaction
|
||||
* Add User Defined Timestamp in C API.
|
||||
* `rocksdb_comparator_with_ts_create` to create timestamp aware comparator
|
||||
* Put, Get, Delete, SingleDelete, MultiGet APIs has corresponding timestamp aware APIs with suffix `with_ts`
|
||||
* And Add C API's for Transaction, SstFileWriter, Compaction as mentioned [here](https://github.com/meta/rocksdb/wiki/User-defined-Timestamp-(Experimental))
|
||||
* And Add C API's for Transaction, SstFileWriter, Compaction as mentioned [here](https://github.com/facebook/rocksdb/wiki/User-defined-Timestamp-(Experimental))
|
||||
* The contract for implementations of Comparator::IsSameLengthImmediateSuccessor has been updated to work around a design bug in `auto_prefix_mode`.
|
||||
* The API documentation for `auto_prefix_mode` now notes some corner cases in which it returns different results than `total_order_seek`, due to design bugs that are not easily fixed. Users using built-in comparators and keys at least the size of a fixed prefix length are not affected.
|
||||
* Obsoleted the NUM_DATA_BLOCKS_READ_PER_LEVEL stat and introduced the NUM_LEVEL_READ_PER_MULTIGET and MULTIGET_COROUTINE_COUNT stats
|
||||
@@ -1755,7 +1643,7 @@ cache at some point (i.e, causing a cache full under `LRUCacheOptions::strict_ca
|
||||
* Experimental: Add support for new APIs ReadAsync in FSRandomAccessFile that reads the data asynchronously and Poll API in FileSystem that checks if requested read request has completed or not. ReadAsync takes a callback function. Poll API checks for completion of read IO requests and should call callback functions to indicate completion of read requests.
|
||||
|
||||
## 6.29.0 (01/21/2022)
|
||||
Note: The next release will be major release 7.0. See https://github.com/meta/rocksdb/issues/9390 for more info.
|
||||
Note: The next release will be major release 7.0. See https://github.com/facebook/rocksdb/issues/9390 for more info.
|
||||
### Public API change
|
||||
* Added values to `TraceFilterType`: `kTraceFilterIteratorSeek`, `kTraceFilterIteratorSeekForPrev`, and `kTraceFilterMultiGet`. They can be set in `TraceOptions` to filter out the operation types after which they are named.
|
||||
* Added `TraceOptions::preserve_write_order`. When enabled it guarantees write records are traced in the same order they are logged to WAL and applied to the DB. By default it is disabled (false) to match the legacy behavior and prevent regression.
|
||||
@@ -1904,7 +1792,7 @@ Note: The next release will be major release 7.0. See https://github.com/meta/ro
|
||||
### Java API Changes
|
||||
* Add Java API bindings for new integrated BlobDB options
|
||||
* `keyMayExist()` supports ByteBuffer.
|
||||
* Fix multiget throwing Null Pointer Exception for num of keys > 70k (https://github.com/meta/rocksdb/issues/8039).
|
||||
* Fix multiget throwing Null Pointer Exception for num of keys > 70k (https://github.com/facebook/rocksdb/issues/8039).
|
||||
|
||||
## 6.25.0 (2021-09-20)
|
||||
### Bug Fixes
|
||||
@@ -2591,7 +2479,7 @@ Note: The next release will be major release 7.0. See https://github.com/meta/ro
|
||||
* Errors related to the retrieval of the compression dictionary are now propagated to the user.
|
||||
* db_bench adds a "benchmark" stats_history, which prints out the whole stats history.
|
||||
* Overload GetAllKeyVersions() to support non-default column family.
|
||||
* Added new APIs ExportColumnFamily() and CreateColumnFamilyWithImport() to support export and import of a Column Family. https://github.com/meta/rocksdb/issues/3469
|
||||
* Added new APIs ExportColumnFamily() and CreateColumnFamilyWithImport() to support export and import of a Column Family. https://github.com/facebook/rocksdb/issues/3469
|
||||
* ldb sometimes uses a string-append merge operator if no merge operator is passed in. This is to allow users to print keys from a DB with a merge operator.
|
||||
* Replaces old Registra with ObjectRegistry to allow user to create custom object from string, also add LoadEnv() to Env.
|
||||
* Added new overload of GetApproximateSizes which gets SizeApproximationOptions object and returns a Status. The older overloads are redirecting their calls to this new method and no longer assert if the include_flags doesn't have either of INCLUDE_MEMTABLES or INCLUDE_FILES bits set. It's recommended to use the new method only, as it is more type safe and returns a meaningful status in case of errors.
|
||||
@@ -3178,7 +3066,7 @@ if set to something > 0 user will see 2 changes in iterators behavior 1) only ke
|
||||
## 4.8.0 (2016-05-02)
|
||||
### Public API Change
|
||||
* Allow preset compression dictionary for improved compression of block-based tables. This is supported for zlib, zstd, and lz4. The compression dictionary's size is configurable via CompressionOptions::max_dict_bytes.
|
||||
* Delete deprecated classes for creating backups (BackupableDB) and restoring from backups (RestoreBackupableDB). Now, BackupEngine should be used for creating backups, and BackupEngineReadOnly should be used for restorations. For more details, see https://github.com/meta/rocksdb/wiki/How-to-backup-RocksDB%3F
|
||||
* Delete deprecated classes for creating backups (BackupableDB) and restoring from backups (RestoreBackupableDB). Now, BackupEngine should be used for creating backups, and BackupEngineReadOnly should be used for restorations. For more details, see https://github.com/facebook/rocksdb/wiki/How-to-backup-RocksDB%3F
|
||||
* Expose estimate of per-level compression ratio via DB property: "rocksdb.compression-ratio-at-levelN".
|
||||
* Added EventListener::OnTableFileCreationStarted. EventListener::OnTableFileCreated will be called on failure case. User can check creation status via TableFileCreationInfo::status.
|
||||
|
||||
@@ -3188,7 +3076,7 @@ if set to something > 0 user will see 2 changes in iterators behavior 1) only ke
|
||||
## 4.7.0 (2016-04-08)
|
||||
### Public API Change
|
||||
* rename options compaction_measure_io_stats to report_bg_io_stats and include flush too.
|
||||
* Change some default options. Now default options will optimize for server-workloads. Also enable slowdown and full stop triggers for pending compaction bytes. These changes may cause sub-optimal performance or significant increase of resource usage. To avoid these risks, users can open existing RocksDB with options extracted from RocksDB option files. See https://github.com/meta/rocksdb/wiki/RocksDB-Options-File for how to use RocksDB option files. Or you can call Options.OldDefaults() to recover old defaults. DEFAULT_OPTIONS_HISTORY.md will track change history of default options.
|
||||
* Change some default options. Now default options will optimize for server-workloads. Also enable slowdown and full stop triggers for pending compaction bytes. These changes may cause sub-optimal performance or significant increase of resource usage. To avoid these risks, users can open existing RocksDB with options extracted from RocksDB option files. See https://github.com/facebook/rocksdb/wiki/RocksDB-Options-File for how to use RocksDB option files. Or you can call Options.OldDefaults() to recover old defaults. DEFAULT_OPTIONS_HISTORY.md will track change history of default options.
|
||||
|
||||
## 4.6.0 (2016-03-10)
|
||||
### Public API Changes
|
||||
@@ -3485,7 +3373,7 @@ Because of that, Options::disable_seek_compaction is now obsolete. It is still a
|
||||
|
||||
### Public API changes
|
||||
* Added _LEVEL to all InfoLogLevel enums
|
||||
* Deprecated ReadOptions.prefix and ReadOptions.prefix_seek. Seek() defaults to prefix-based seek when Options.prefix_extractor is supplied. More detail is documented in https://github.com/meta/rocksdb/wiki/Prefix-Seek-API-Changes
|
||||
* Deprecated ReadOptions.prefix and ReadOptions.prefix_seek. Seek() defaults to prefix-based seek when Options.prefix_extractor is supplied. More detail is documented in https://github.com/facebook/rocksdb/wiki/Prefix-Seek-API-Changes
|
||||
* MemTableRepFactory::CreateMemTableRep() takes info logger as an extra parameter.
|
||||
|
||||
### New Features
|
||||
@@ -3536,8 +3424,8 @@ Because of that, Options::disable_seek_compaction is now obsolete. It is still a
|
||||
|
||||
### New Features
|
||||
|
||||
* Added [BackupableDB](https://github.com/meta/rocksdb/wiki/How-to-backup-RocksDB%3F)
|
||||
* Implemented [TailingIterator](https://github.com/meta/rocksdb/wiki/Tailing-Iterator), a special type of iterator that
|
||||
* Added [BackupableDB](https://github.com/facebook/rocksdb/wiki/How-to-backup-RocksDB%3F)
|
||||
* Implemented [TailingIterator](https://github.com/facebook/rocksdb/wiki/Tailing-Iterator), a special type of iterator that
|
||||
doesn't create a snapshot (can be used to read newly inserted data)
|
||||
and is optimized for doing sequential reads.
|
||||
* Added property block for table, which allows (1) a table to store
|
||||
@@ -3554,8 +3442,8 @@ Because of that, Options::disable_seek_compaction is now obsolete. It is still a
|
||||
|
||||
* Huge benchmark performance improvements by multiple efforts. For example, increase in readonly QPS from about 530k in 2.6 release to 1.1 million in 2.7 [1]
|
||||
* Speeding up a way RocksDB deleted obsolete files - no longer listing the whole directory under a lock -- decrease in p99
|
||||
* Use raw pointer instead of shared pointer for statistics: [5b825d](https://github.com/meta/rocksdb/commit/5b825d6964e26ec3b4bb6faa708ebb1787f1d7bd) -- huge increase in performance -- shared pointers are slow
|
||||
* Optimized locking for `Get()` -- [1fdb3f](https://github.com/meta/rocksdb/commit/1fdb3f7dc60e96394e3e5b69a46ede5d67fb976c) -- 1.5x QPS increase for some workloads
|
||||
* Cache speedup - [e8d40c3](https://github.com/meta/rocksdb/commit/e8d40c31b3cca0c3e1ae9abe9b9003b1288026a9)
|
||||
* Implemented autovector, which allocates first N elements on stack. Most of vectors in RocksDB are small. Also, we never want to allocate heap objects while holding a mutex. -- [c01676e4](https://github.com/meta/rocksdb/commit/c01676e46d3be08c3c140361ef1f5884f47d3b3c)
|
||||
* Use raw pointer instead of shared pointer for statistics: [5b825d](https://github.com/facebook/rocksdb/commit/5b825d6964e26ec3b4bb6faa708ebb1787f1d7bd) -- huge increase in performance -- shared pointers are slow
|
||||
* Optimized locking for `Get()` -- [1fdb3f](https://github.com/facebook/rocksdb/commit/1fdb3f7dc60e96394e3e5b69a46ede5d67fb976c) -- 1.5x QPS increase for some workloads
|
||||
* Cache speedup - [e8d40c3](https://github.com/facebook/rocksdb/commit/e8d40c31b3cca0c3e1ae9abe9b9003b1288026a9)
|
||||
* Implemented autovector, which allocates first N elements on stack. Most of vectors in RocksDB are small. Also, we never want to allocate heap objects while holding a mutex. -- [c01676e4](https://github.com/facebook/rocksdb/commit/c01676e46d3be08c3c140361ef1f5884f47d3b3c)
|
||||
* Lots of efforts to move malloc, memcpy and IO outside of locks
|
||||
+13
-2
@@ -153,7 +153,7 @@ most processors made since roughly 2013.
|
||||
|
||||
* Build RocksDB from source:
|
||||
cd ~
|
||||
git clone https://github.com/meta/rocksdb.git
|
||||
git clone https://github.com/facebook/rocksdb.git
|
||||
cd rocksdb
|
||||
gmake static_lib
|
||||
|
||||
@@ -174,7 +174,7 @@ most processors made since roughly 2013.
|
||||
|
||||
```bash
|
||||
cd ~
|
||||
git clone https://github.com/meta/rocksdb.git
|
||||
git clone https://github.com/facebook/rocksdb.git
|
||||
cd rocksdb
|
||||
gmake static_lib
|
||||
```
|
||||
@@ -211,3 +211,14 @@ most processors made since roughly 2013.
|
||||
export LIBPATH=/opt/freeware/lib
|
||||
export JAVA_HOME=/usr/java8_64
|
||||
export PATH=/opt/freeware/bin:$PATH
|
||||
|
||||
* **Solaris Sparc**
|
||||
* Install GCC 11 and higher.
|
||||
* Use these environment variables:
|
||||
|
||||
export CC=gcc
|
||||
export EXTRA_CFLAGS=-m64
|
||||
export EXTRA_CXXFLAGS=-m64
|
||||
export EXTRA_LDFLAGS=-m64
|
||||
export PORTABLE=1
|
||||
export PLATFORM_LDFLAGS="-static-libstdc++ -static-libgcc"
|
||||
@@ -1,6 +1,6 @@
|
||||
This is the list of all known third-party language bindings for RocksDB. If something is missing, please open a pull request to add it.
|
||||
|
||||
* Java - https://github.com/meta/rocksdb/tree/main/java
|
||||
* Java - https://github.com/facebook/rocksdb/tree/main/java
|
||||
* Python
|
||||
* https://github.com/rocksdict/RocksDict
|
||||
* http://python-rocksdb.readthedocs.io/en/latest/ (unmaintained)
|
||||
|
||||
@@ -355,6 +355,10 @@ ARFLAGS = -X64 rs
|
||||
STRIPFLAGS = -X64 -x
|
||||
endif
|
||||
|
||||
ifeq ($(PLATFORM), OS_SOLARIS)
|
||||
PLATFORM_CXXFLAGS += -D _GLIBCXX_USE_C99
|
||||
endif
|
||||
|
||||
ifeq ($(LIB_MODE),shared)
|
||||
# So that binaries are executable from build location, in addition to install location
|
||||
EXEC_LDFLAGS += -Wl,-rpath -Wl,'$$ORIGIN'
|
||||
@@ -660,7 +664,6 @@ TESTS_PLATFORM_DEPENDENT := \
|
||||
dynamic_bloom_test \
|
||||
c_test \
|
||||
checkpoint_test \
|
||||
live_tuner_test \
|
||||
sorted_run_builder_test \
|
||||
crc32c_test \
|
||||
coding_test \
|
||||
@@ -1893,12 +1896,6 @@ backup_engine_test: $(OBJ_DIR)/utilities/backup/backup_engine_test.o $(TEST_LIBR
|
||||
checkpoint_test: $(OBJ_DIR)/utilities/checkpoint/checkpoint_test.o $(TEST_LIBRARY) $(LIBRARY)
|
||||
$(AM_LINK)
|
||||
|
||||
live_tuner_test: $(OBJ_DIR)/utilities/live_tune/live_tuner_test.o $(TEST_LIBRARY) $(LIBRARY)
|
||||
$(AM_LINK)
|
||||
|
||||
db_split_merge_test: $(OBJ_DIR)/utilities/db_split_merge_test.o $(TEST_LIBRARY) $(LIBRARY)
|
||||
$(AM_LINK)
|
||||
|
||||
copy_engine_test: $(OBJ_DIR)/utilities/copy_engine/copy_engine_test.o $(TEST_LIBRARY) $(LIBRARY)
|
||||
$(AM_LINK)
|
||||
|
||||
@@ -2211,9 +2208,6 @@ ldb_cmd_test: $(OBJ_DIR)/tools/ldb_cmd_test.o $(TOOLS_LIBRARY) $(TEST_LIBRARY) $
|
||||
ldb: $(OBJ_DIR)/tools/ldb.o $(TOOLS_LIBRARY) $(LIBRARY)
|
||||
$(AM_LINK)
|
||||
|
||||
db_split_merge: $(OBJ_DIR)/tools/db_split_merge.o $(LIBRARY)
|
||||
$(AM_LINK)
|
||||
|
||||
iostats_context_test: $(OBJ_DIR)/monitoring/iostats_context_test.o $(TEST_LIBRARY) $(LIBRARY)
|
||||
$(AM_V_CCLD)$(CXX) $^ $(EXEC_LDFLAGS) -o $@ $(LDFLAGS)
|
||||
|
||||
@@ -2413,7 +2407,9 @@ gen-pc:
|
||||
# Jni stuff
|
||||
# ---------------------------------------------------------------------------
|
||||
JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/linux
|
||||
ifeq ($(PLATFORM), OS_OPENBSD)
|
||||
ifeq ($(PLATFORM), OS_SOLARIS)
|
||||
ARCH := $(shell isainfo -b)
|
||||
else ifeq ($(PLATFORM), OS_OPENBSD)
|
||||
ifneq (,$(filter amd64 ppc64 ppc64le s390x arm64 aarch64 riscv64 sparc64 loongarch64, $(MACHINE)))
|
||||
ARCH := 64
|
||||
else
|
||||
@@ -2494,6 +2490,12 @@ ifeq ($(PLATFORM), OS_FREEBSD)
|
||||
ROCKSDBJNILIB = librocksdbjni-freebsd$(ARCH).so
|
||||
ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-freebsd$(ARCH).jar
|
||||
endif
|
||||
ifeq ($(PLATFORM), OS_SOLARIS)
|
||||
ROCKSDBJNILIB = librocksdbjni-solaris$(ARCH).so
|
||||
ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-solaris$(ARCH).jar
|
||||
JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/solaris
|
||||
SHA256_CMD = digest -a sha256
|
||||
endif
|
||||
ifeq ($(PLATFORM), OS_AIX)
|
||||
JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/aix
|
||||
ROCKSDBJNILIB = librocksdbjni-aix.so
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
## RocksDB: A Persistent Key-Value Store for Flash and RAM Storage
|
||||
|
||||
[](https://circleci.com/gh/facebook/rocksdb)
|
||||
|
||||
RocksDB is developed and maintained by Facebook Database Engineering Team.
|
||||
It is built on earlier work on [LevelDB](https://github.com/google/leveldb) by Sanjay Ghemawat (sanjay@google.com)
|
||||
and Jeff Dean (jeff@google.com)
|
||||
@@ -12,9 +14,9 @@ and Space-Amplification-Factor (SAF). It has multi-threaded compactions,
|
||||
making it especially suitable for storing multiple terabytes of data in a
|
||||
single database.
|
||||
|
||||
Start with example usage here: https://github.com/meta/rocksdb/tree/main/examples
|
||||
Start with example usage here: https://github.com/facebook/rocksdb/tree/main/examples
|
||||
|
||||
See the [github wiki](https://github.com/meta/rocksdb/wiki) for more explanation.
|
||||
See the [github wiki](https://github.com/facebook/rocksdb/wiki) for more explanation.
|
||||
|
||||
The public interface is in `include/`. Callers should not include or
|
||||
rely on the details of any other header files in this package. Those
|
||||
|
||||
@@ -188,22 +188,22 @@ def generate_buck(repo_path, deps_map):
|
||||
# always add range_tree, it's only excluded on ppc64, which we don't use internally
|
||||
src_mk["RANGE_TREE_SOURCES"] + src_mk["TOOL_LIB_SOURCES"],
|
||||
deps=[
|
||||
"fbsource//xplat/folly:executor",
|
||||
"fbsource//xplat/folly/container:f14_hash",
|
||||
"fbsource//xplat/folly/coro:baton",
|
||||
"fbsource//xplat/folly/coro:blocking_wait",
|
||||
"fbsource//xplat/folly/coro:collect",
|
||||
"fbsource//xplat/folly/coro:coroutine",
|
||||
"fbsource//xplat/folly/coro:nothrow",
|
||||
"fbsource//xplat/folly/coro:task",
|
||||
"fbsource//xplat/folly/executors:io_executor",
|
||||
"fbsource//xplat/folly/executors:io_thread_pool_executor",
|
||||
"fbsource//xplat/folly/executors/thread_factory:named_thread_factory",
|
||||
"fbsource//xplat/folly/io/async:async_base",
|
||||
"fbsource//xplat/folly/io/async:event_base_manager",
|
||||
"fbsource//xplat/folly/io/async:io_uring_backend",
|
||||
"fbsource//xplat/folly/io/async:request_context",
|
||||
"fbsource//xplat/folly/synchronization:distributed_mutex",
|
||||
"//folly:executor",
|
||||
"//folly/container:f14_hash",
|
||||
"//folly/coro:baton",
|
||||
"//folly/coro:blocking_wait",
|
||||
"//folly/coro:collect",
|
||||
"//folly/coro:coroutine",
|
||||
"//folly/coro:nothrow",
|
||||
"//folly/coro:task",
|
||||
"//folly/executors:io_executor",
|
||||
"//folly/executors:io_thread_pool_executor",
|
||||
"//folly/executors/thread_factory:named_thread_factory",
|
||||
"//folly/io/async:async_base",
|
||||
"//folly/io/async:event_base_manager",
|
||||
"//folly/io/async:io_uring_backend",
|
||||
"//folly/io/async:request_context",
|
||||
"//folly/synchronization:distributed_mutex",
|
||||
],
|
||||
headers=LiteralValue("glob([\"**/*.h\"])")
|
||||
)
|
||||
@@ -299,9 +299,6 @@ def generate_buck(repo_path, deps_map):
|
||||
BUCK.add_binary(
|
||||
"ldb", ["tools/ldb.cc"], [":rocksdb_tools_lib"]
|
||||
)
|
||||
BUCK.add_binary(
|
||||
"db_split_merge", ["tools/db_split_merge.cc"], [":rocksdb_lib"]
|
||||
)
|
||||
# db_stress binary
|
||||
BUCK.add_binary(
|
||||
"db_stress", ["db_stress_tool/db_stress.cc"], [":rocksdb_stress_lib"]
|
||||
|
||||
@@ -230,6 +230,12 @@ case "$TARGET_OS" in
|
||||
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lrt -ldl"
|
||||
# PORT_FILES=port/linux/linux_specific.cc
|
||||
;;
|
||||
SunOS)
|
||||
PLATFORM=OS_SOLARIS
|
||||
COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_SOLARIS -m64"
|
||||
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lrt -static-libstdc++ -static-libgcc -m64"
|
||||
# PORT_FILES=port/sunos/sunos_specific.cc
|
||||
;;
|
||||
AIX)
|
||||
PLATFORM=OS_AIX
|
||||
CC=gcc
|
||||
|
||||
@@ -129,13 +129,12 @@ uncommitted_code=`git diff HEAD`
|
||||
|
||||
# If there's no uncommitted changes, we assume user are doing post-commit
|
||||
# format check, in which case we'll try to check the modified lines vs. the
|
||||
# meta/rocksdb.git main branch. Otherwise, we'll check format of the
|
||||
# facebook/rocksdb.git main branch. Otherwise, we'll check format of the
|
||||
# uncommitted code only.
|
||||
if [ -z "$uncommitted_code" ]
|
||||
then
|
||||
# Attempt to get name of meta/rocksdb.git remote. Older clones might still
|
||||
# use the pre-transfer facebook/rocksdb.git URL, which GitHub redirects.
|
||||
[ "$FORMAT_REMOTE" ] || FORMAT_REMOTE="$(LC_ALL=POSIX LANG=POSIX git remote -v | grep -E '[:/](meta|facebook)/rocksdb\.git' | head -n 1 | cut -f 1)"
|
||||
# Attempt to get name of facebook/rocksdb.git remote.
|
||||
[ "$FORMAT_REMOTE" ] || FORMAT_REMOTE="$(LC_ALL=POSIX LANG=POSIX git remote -v | grep 'facebook/rocksdb.git' | head -n 1 | cut -f 1)"
|
||||
# Fall back on 'origin' if that fails
|
||||
[ "$FORMAT_REMOTE" ] || FORMAT_REMOTE=origin
|
||||
# Use main branch from that remote
|
||||
|
||||
@@ -23,7 +23,7 @@ mkdir -pv /usr/local/rocksdb-${ROCKSDB_VERSION}
|
||||
ln -sfT /usr/local/rocksdb-${ROCKSDB_VERSION} /usr/local/rocksdb
|
||||
|
||||
wget -qO /tmp/zstd-${ZSTD_VERSION}.tar.gz https://github.com/facebook/zstd/archive/v${ZSTD_VERSION}.tar.gz
|
||||
wget -qO /tmp/rocksdb-${ROCKSDB_VERSION}.tar.gz https://github.com/meta/rocksdb/archive/v${ROCKSDB_VERSION}.tar.gz
|
||||
wget -qO /tmp/rocksdb-${ROCKSDB_VERSION}.tar.gz https://github.com/facebook/rocksdb/archive/v${ROCKSDB_VERSION}.tar.gz
|
||||
|
||||
cd /tmp
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
# Then in the build_tools/ubuntu22_image directory, (bump minor version for
|
||||
# random docker file updates, major version tracks Ubuntu release)
|
||||
#
|
||||
# $ docker build -t ghcr.io/meta/rocksdb_ubuntu:22.2
|
||||
# $ docker push ghcr.io/meta/rocksdb_ubuntu:22.2
|
||||
# $ docker build -t ghcr.io/facebook/rocksdb_ubuntu:22.2
|
||||
# $ docker push ghcr.io/facebook/rocksdb_ubuntu:22.2
|
||||
#
|
||||
# Might need to change visibility to public through
|
||||
# https://github.com/orgs/facebook/packages/container/rocksdb_ubuntu/settings
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
# Then in the build_tools/ubuntu24_image directory, (bump minor version for
|
||||
# random docker file updates, major version tracks Ubuntu release)
|
||||
#
|
||||
# $ docker build -t ghcr.io/meta/rocksdb_ubuntu:24.1
|
||||
# $ docker push ghcr.io/meta/rocksdb_ubuntu:24.1
|
||||
# $ docker build -t ghcr.io/facebook/rocksdb_ubuntu:24.1
|
||||
# $ docker push ghcr.io/facebook/rocksdb_ubuntu:24.1
|
||||
#
|
||||
# Might need to change visibility to public through
|
||||
# https://github.com/orgs/facebook/packages/container/rocksdb_ubuntu/settings
|
||||
|
||||
@@ -109,12 +109,6 @@ int rocksdb_compactionjobinfo_job_id(const rocksdb_compactionjobinfo_t* info) {
|
||||
return info->rep.job_id;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
rocksdb_compactionjobinfo_separate_remote_compaction_pool_selected(
|
||||
const rocksdb_compactionjobinfo_t* info) {
|
||||
return info->rep.separate_remote_compaction_pool_selected;
|
||||
}
|
||||
|
||||
int rocksdb_compactionjobinfo_num_l0_files(
|
||||
const rocksdb_compactionjobinfo_t* info) {
|
||||
return info->rep.num_l0_files;
|
||||
@@ -178,12 +172,6 @@ int rocksdb_subcompactionjobinfo_job_id(
|
||||
return info->rep.job_id;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
rocksdb_subcompactionjobinfo_separate_remote_compaction_pool_selected(
|
||||
const rocksdb_subcompactionjobinfo_t* info) {
|
||||
return info->rep.separate_remote_compaction_pool_selected;
|
||||
}
|
||||
|
||||
int rocksdb_subcompactionjobinfo_subcompaction_job_id(
|
||||
const rocksdb_subcompactionjobinfo_t* info) {
|
||||
return info->rep.subcompaction_job_id;
|
||||
|
||||
@@ -78,10 +78,6 @@ rocksdb_compactionjobinfo_thread_id(const rocksdb_compactionjobinfo_t* info);
|
||||
extern ROCKSDB_LIBRARY_API int rocksdb_compactionjobinfo_job_id(
|
||||
const rocksdb_compactionjobinfo_t* info);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_compactionjobinfo_separate_remote_compaction_pool_selected(
|
||||
const rocksdb_compactionjobinfo_t* info);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API int rocksdb_compactionjobinfo_num_l0_files(
|
||||
const rocksdb_compactionjobinfo_t* info);
|
||||
|
||||
@@ -121,10 +117,6 @@ extern ROCKSDB_LIBRARY_API uint64_t rocksdb_subcompactionjobinfo_thread_id(
|
||||
extern ROCKSDB_LIBRARY_API int rocksdb_subcompactionjobinfo_job_id(
|
||||
const rocksdb_subcompactionjobinfo_t* info);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_subcompactionjobinfo_separate_remote_compaction_pool_selected(
|
||||
const rocksdb_subcompactionjobinfo_t* info);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API int
|
||||
rocksdb_subcompactionjobinfo_subcompaction_job_id(
|
||||
const rocksdb_subcompactionjobinfo_t* info);
|
||||
|
||||
@@ -67,11 +67,6 @@ uint64_t rocksdb_table_properties_udi_is_primary_index(
|
||||
return props->rep.udi_is_primary_index;
|
||||
}
|
||||
|
||||
uint64_t rocksdb_table_properties_standard_index_is_stub(
|
||||
const rocksdb_table_properties_t* props) {
|
||||
return props->rep.standard_index_is_stub;
|
||||
}
|
||||
|
||||
uint64_t rocksdb_table_properties_filter_size(
|
||||
const rocksdb_table_properties_t* props) {
|
||||
return props->rep.filter_size;
|
||||
|
||||
@@ -54,10 +54,6 @@ extern ROCKSDB_LIBRARY_API uint64_t
|
||||
rocksdb_table_properties_udi_is_primary_index(
|
||||
const rocksdb_table_properties_t* props);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API uint64_t
|
||||
rocksdb_table_properties_standard_index_is_stub(
|
||||
const rocksdb_table_properties_t* props);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API uint64_t
|
||||
rocksdb_table_properties_filter_size(const rocksdb_table_properties_t* props);
|
||||
|
||||
|
||||
@@ -741,16 +741,6 @@ unsigned char rocksdb_options_get_write_dbid_to_manifest(
|
||||
return opt->rep.write_dbid_to_manifest;
|
||||
}
|
||||
|
||||
void rocksdb_options_set_track_options_file_number_in_manifest(
|
||||
rocksdb_options_t* opt, unsigned char v) {
|
||||
opt->rep.track_options_file_number_in_manifest = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_options_get_track_options_file_number_in_manifest(
|
||||
rocksdb_options_t* opt) {
|
||||
return opt->rep.track_options_file_number_in_manifest;
|
||||
}
|
||||
|
||||
void rocksdb_options_set_write_identity_file(rocksdb_options_t* opt,
|
||||
unsigned char v) {
|
||||
opt->rep.write_identity_file = v;
|
||||
@@ -826,16 +816,6 @@ const char* rocksdb_options_get_db_host_id(rocksdb_options_t* opt,
|
||||
return opt->rep.db_host_id.data();
|
||||
}
|
||||
|
||||
void rocksdb_options_set_use_separate_remote_compaction_pool(
|
||||
rocksdb_options_t* opt, unsigned char v) {
|
||||
opt->rep.use_separate_remote_compaction_pool = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_options_get_use_separate_remote_compaction_pool(
|
||||
rocksdb_options_t* opt) {
|
||||
return opt->rep.use_separate_remote_compaction_pool;
|
||||
}
|
||||
|
||||
void rocksdb_options_set_remote_compaction_manifest_floor(
|
||||
rocksdb_options_t* opt, unsigned char v) {
|
||||
opt->rep.remote_compaction_manifest_floor = v;
|
||||
@@ -1929,16 +1909,6 @@ unsigned char rocksdb_trace_options_get_preserve_write_order(
|
||||
return opt->rep.preserve_write_order;
|
||||
}
|
||||
|
||||
void rocksdb_trace_options_set_include_read_write_options(
|
||||
rocksdb_trace_options_t* opt, unsigned char v) {
|
||||
opt->rep.include_read_write_options = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_trace_options_get_include_read_write_options(
|
||||
rocksdb_trace_options_t* opt) {
|
||||
return opt->rep.include_read_write_options;
|
||||
}
|
||||
|
||||
/* BlockCacheTraceOptions */
|
||||
|
||||
void rocksdb_block_cache_trace_options_set_sampling_frequency(
|
||||
@@ -2018,16 +1988,6 @@ unsigned char rocksdb_compaction_options_get_allow_trivial_move(
|
||||
|
||||
/* CompactRangeOptions */
|
||||
|
||||
void rocksdb_compactoptions_set_skip_missing_blob_files(
|
||||
rocksdb_compactoptions_t* opt, unsigned char v) {
|
||||
opt->rep.skip_missing_blob_files = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_compactoptions_get_skip_missing_blob_files(
|
||||
rocksdb_compactoptions_t* opt) {
|
||||
return opt->rep.skip_missing_blob_files;
|
||||
}
|
||||
|
||||
void rocksdb_compactoptions_set_blob_garbage_collection_policy(
|
||||
rocksdb_compactoptions_t* opt, int v) {
|
||||
opt->rep.blob_garbage_collection_policy =
|
||||
@@ -2175,16 +2135,6 @@ int rocksdb_ingestexternalfileoptions_get_file_opening_threads(
|
||||
return opt->rep.file_opening_threads;
|
||||
}
|
||||
|
||||
void rocksdb_ingestexternalfileoptions_set_reject_too_old_file(
|
||||
rocksdb_ingestexternalfileoptions_t* opt, unsigned char v) {
|
||||
opt->rep.reject_too_old_file = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_ingestexternalfileoptions_get_reject_too_old_file(
|
||||
rocksdb_ingestexternalfileoptions_t* opt) {
|
||||
return opt->rep.reject_too_old_file;
|
||||
}
|
||||
|
||||
/* OpenAndCompactOptions */
|
||||
|
||||
void rocksdb_open_and_compact_options_set_max_secondary_open_retries(
|
||||
@@ -2209,16 +2159,6 @@ unsigned char rocksdb_import_column_family_options_get_move_files(
|
||||
return opt->rep.move_files;
|
||||
}
|
||||
|
||||
void rocksdb_import_column_family_options_set_reject_too_old_file(
|
||||
rocksdb_import_column_family_options_t* opt, unsigned char v) {
|
||||
opt->rep.reject_too_old_file = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_import_column_family_options_get_reject_too_old_file(
|
||||
rocksdb_import_column_family_options_t* opt) {
|
||||
return opt->rep.reject_too_old_file;
|
||||
}
|
||||
|
||||
/* SizeApproximationOptions */
|
||||
|
||||
void rocksdb_size_approximation_options_set_include_memtables(
|
||||
@@ -2513,6 +2453,26 @@ unsigned char rocksdb_block_based_options_get_use_delta_encoding(
|
||||
return opt->rep.use_delta_encoding;
|
||||
}
|
||||
|
||||
void rocksdb_block_based_options_set_use_udi_as_primary_index(
|
||||
rocksdb_block_based_table_options_t* opt, unsigned char v) {
|
||||
opt->rep.use_udi_as_primary_index = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_block_based_options_get_use_udi_as_primary_index(
|
||||
rocksdb_block_based_table_options_t* opt) {
|
||||
return opt->rep.use_udi_as_primary_index;
|
||||
}
|
||||
|
||||
void rocksdb_block_based_options_set_fail_if_no_udi_on_open(
|
||||
rocksdb_block_based_table_options_t* opt, unsigned char v) {
|
||||
opt->rep.fail_if_no_udi_on_open = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_block_based_options_get_fail_if_no_udi_on_open(
|
||||
rocksdb_block_based_table_options_t* opt) {
|
||||
return opt->rep.fail_if_no_udi_on_open;
|
||||
}
|
||||
|
||||
void rocksdb_block_based_options_set_whole_key_filtering(
|
||||
rocksdb_block_based_table_options_t* opt, unsigned char v) {
|
||||
opt->rep.whole_key_filtering = v;
|
||||
|
||||
@@ -204,14 +204,6 @@ rocksdb_options_set_background_close_inactive_wals(rocksdb_options_t* opt,
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_options_get_background_close_inactive_wals(rocksdb_options_t* opt);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
rocksdb_options_set_track_options_file_number_in_manifest(
|
||||
rocksdb_options_t* opt, unsigned char v);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_options_get_track_options_file_number_in_manifest(
|
||||
rocksdb_options_t* opt);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_prefix_seek_opt_in_only(
|
||||
rocksdb_options_t* opt, unsigned char v);
|
||||
|
||||
@@ -255,13 +247,6 @@ extern ROCKSDB_LIBRARY_API void rocksdb_options_set_db_host_id(
|
||||
extern ROCKSDB_LIBRARY_API const char* rocksdb_options_get_db_host_id(
|
||||
rocksdb_options_t* opt, size_t* size);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
rocksdb_options_set_use_separate_remote_compaction_pool(rocksdb_options_t* opt,
|
||||
unsigned char v);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_options_get_use_separate_remote_compaction_pool(rocksdb_options_t* opt);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
rocksdb_options_set_remote_compaction_manifest_floor(rocksdb_options_t* opt,
|
||||
unsigned char v);
|
||||
@@ -715,14 +700,6 @@ extern ROCKSDB_LIBRARY_API void rocksdb_trace_options_set_preserve_write_order(
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_trace_options_get_preserve_write_order(rocksdb_trace_options_t* opt);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
rocksdb_trace_options_set_include_read_write_options(
|
||||
rocksdb_trace_options_t* opt, unsigned char v);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_trace_options_get_include_read_write_options(
|
||||
rocksdb_trace_options_t* opt);
|
||||
|
||||
/* BlockCacheTraceOptions */
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
@@ -785,14 +762,6 @@ rocksdb_compaction_options_get_allow_trivial_move(
|
||||
|
||||
/* CompactRangeOptions */
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
rocksdb_compactoptions_set_skip_missing_blob_files(
|
||||
rocksdb_compactoptions_t* opt, unsigned char v);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_compactoptions_get_skip_missing_blob_files(
|
||||
rocksdb_compactoptions_t* opt);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
rocksdb_compactoptions_set_blob_garbage_collection_policy(
|
||||
rocksdb_compactoptions_t* opt, int v);
|
||||
@@ -907,14 +876,6 @@ extern ROCKSDB_LIBRARY_API int
|
||||
rocksdb_ingestexternalfileoptions_get_file_opening_threads(
|
||||
rocksdb_ingestexternalfileoptions_t* opt);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
rocksdb_ingestexternalfileoptions_set_reject_too_old_file(
|
||||
rocksdb_ingestexternalfileoptions_t* opt, unsigned char v);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_ingestexternalfileoptions_get_reject_too_old_file(
|
||||
rocksdb_ingestexternalfileoptions_t* opt);
|
||||
|
||||
/* OpenAndCompactOptions */
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
@@ -935,14 +896,6 @@ extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_import_column_family_options_get_move_files(
|
||||
rocksdb_import_column_family_options_t* opt);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
rocksdb_import_column_family_options_set_reject_too_old_file(
|
||||
rocksdb_import_column_family_options_t* opt, unsigned char v);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_import_column_family_options_get_reject_too_old_file(
|
||||
rocksdb_import_column_family_options_t* opt);
|
||||
|
||||
/* SizeApproximationOptions */
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
@@ -1169,6 +1122,22 @@ extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_block_based_options_get_use_delta_encoding(
|
||||
rocksdb_block_based_table_options_t* opt);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
rocksdb_block_based_options_set_use_udi_as_primary_index(
|
||||
rocksdb_block_based_table_options_t* opt, unsigned char v);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_block_based_options_get_use_udi_as_primary_index(
|
||||
rocksdb_block_based_table_options_t* opt);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
rocksdb_block_based_options_set_fail_if_no_udi_on_open(
|
||||
rocksdb_block_based_table_options_t* opt, unsigned char v);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API unsigned char
|
||||
rocksdb_block_based_options_get_fail_if_no_udi_on_open(
|
||||
rocksdb_block_based_table_options_t* opt);
|
||||
|
||||
extern ROCKSDB_LIBRARY_API void
|
||||
rocksdb_block_based_options_set_whole_key_filtering(
|
||||
rocksdb_block_based_table_options_t* opt, unsigned char v);
|
||||
|
||||
@@ -87,6 +87,12 @@ static void rocksdb_roundtrip_test_rocksdb_block_based_options(void) {
|
||||
rocksdb_block_based_options_set_enable_index_compression(obj, 0);
|
||||
CheckCondition(
|
||||
rocksdb_block_based_options_get_enable_index_compression(obj) == 0);
|
||||
rocksdb_block_based_options_set_fail_if_no_udi_on_open(obj, 1);
|
||||
CheckCondition(rocksdb_block_based_options_get_fail_if_no_udi_on_open(obj) ==
|
||||
1);
|
||||
rocksdb_block_based_options_set_fail_if_no_udi_on_open(obj, 0);
|
||||
CheckCondition(rocksdb_block_based_options_get_fail_if_no_udi_on_open(obj) ==
|
||||
0);
|
||||
rocksdb_block_based_options_set_format_version(obj, 1);
|
||||
CheckCondition(rocksdb_block_based_options_get_format_version(obj) == 1);
|
||||
rocksdb_block_based_options_set_format_version(obj, 0);
|
||||
@@ -217,6 +223,12 @@ static void rocksdb_roundtrip_test_rocksdb_block_based_options(void) {
|
||||
CheckCondition(rocksdb_block_based_options_get_use_delta_encoding(obj) == 1);
|
||||
rocksdb_block_based_options_set_use_delta_encoding(obj, 0);
|
||||
CheckCondition(rocksdb_block_based_options_get_use_delta_encoding(obj) == 0);
|
||||
rocksdb_block_based_options_set_use_udi_as_primary_index(obj, 1);
|
||||
CheckCondition(
|
||||
rocksdb_block_based_options_get_use_udi_as_primary_index(obj) == 1);
|
||||
rocksdb_block_based_options_set_use_udi_as_primary_index(obj, 0);
|
||||
CheckCondition(
|
||||
rocksdb_block_based_options_get_use_udi_as_primary_index(obj) == 0);
|
||||
rocksdb_block_based_options_set_verify_compression(obj, 1);
|
||||
CheckCondition(rocksdb_block_based_options_get_verify_compression(obj) == 1);
|
||||
rocksdb_block_based_options_set_verify_compression(obj, 0);
|
||||
@@ -309,10 +321,6 @@ static void rocksdb_roundtrip_test_rocksdb_compactoptions(void) {
|
||||
rocksdb_compactoptions_set_blob_garbage_collection_policy(obj, 0);
|
||||
CheckCondition(
|
||||
rocksdb_compactoptions_get_blob_garbage_collection_policy(obj) == 0);
|
||||
rocksdb_compactoptions_set_skip_missing_blob_files(obj, 1);
|
||||
CheckCondition(rocksdb_compactoptions_get_skip_missing_blob_files(obj) == 1);
|
||||
rocksdb_compactoptions_set_skip_missing_blob_files(obj, 0);
|
||||
CheckCondition(rocksdb_compactoptions_get_skip_missing_blob_files(obj) == 0);
|
||||
rocksdb_compactoptions_destroy(obj);
|
||||
}
|
||||
|
||||
@@ -485,18 +493,6 @@ static void rocksdb_roundtrip_test_rocksdb_flushwaloptions(void) {
|
||||
rocksdb_flushwaloptions_destroy(obj);
|
||||
}
|
||||
|
||||
static void rocksdb_roundtrip_test_rocksdb_import_column_family_options(void) {
|
||||
rocksdb_import_column_family_options_t* obj =
|
||||
rocksdb_import_column_family_options_create();
|
||||
rocksdb_import_column_family_options_set_reject_too_old_file(obj, 1);
|
||||
CheckCondition(
|
||||
rocksdb_import_column_family_options_get_reject_too_old_file(obj) == 1);
|
||||
rocksdb_import_column_family_options_set_reject_too_old_file(obj, 0);
|
||||
CheckCondition(
|
||||
rocksdb_import_column_family_options_get_reject_too_old_file(obj) == 0);
|
||||
rocksdb_import_column_family_options_destroy(obj);
|
||||
}
|
||||
|
||||
static void rocksdb_roundtrip_test_rocksdb_ingestexternalfileoptions(void) {
|
||||
rocksdb_ingestexternalfileoptions_t* obj =
|
||||
rocksdb_ingestexternalfileoptions_create();
|
||||
@@ -538,12 +534,6 @@ static void rocksdb_roundtrip_test_rocksdb_ingestexternalfileoptions(void) {
|
||||
CheckCondition(
|
||||
rocksdb_ingestexternalfileoptions_get_prefetch_lmax_index_and_filter_blocks(
|
||||
obj) == 0);
|
||||
rocksdb_ingestexternalfileoptions_set_reject_too_old_file(obj, 1);
|
||||
CheckCondition(
|
||||
rocksdb_ingestexternalfileoptions_get_reject_too_old_file(obj) == 1);
|
||||
rocksdb_ingestexternalfileoptions_set_reject_too_old_file(obj, 0);
|
||||
CheckCondition(
|
||||
rocksdb_ingestexternalfileoptions_get_reject_too_old_file(obj) == 0);
|
||||
rocksdb_ingestexternalfileoptions_set_verify_checksums_before_ingest(obj, 1);
|
||||
CheckCondition(
|
||||
rocksdb_ingestexternalfileoptions_get_verify_checksums_before_ingest(
|
||||
@@ -923,12 +913,6 @@ static void rocksdb_roundtrip_test_rocksdb_options(void) {
|
||||
CheckCondition(rocksdb_options_get_track_and_verify_wals(obj) == 1);
|
||||
rocksdb_options_set_track_and_verify_wals(obj, 0);
|
||||
CheckCondition(rocksdb_options_get_track_and_verify_wals(obj) == 0);
|
||||
rocksdb_options_set_track_options_file_number_in_manifest(obj, 1);
|
||||
CheckCondition(
|
||||
rocksdb_options_get_track_options_file_number_in_manifest(obj) == 1);
|
||||
rocksdb_options_set_track_options_file_number_in_manifest(obj, 0);
|
||||
CheckCondition(
|
||||
rocksdb_options_get_track_options_file_number_in_manifest(obj) == 0);
|
||||
rocksdb_options_set_two_write_queues(obj, 1);
|
||||
CheckCondition(rocksdb_options_get_two_write_queues(obj) == 1);
|
||||
rocksdb_options_set_two_write_queues(obj, 0);
|
||||
@@ -947,12 +931,6 @@ static void rocksdb_roundtrip_test_rocksdb_options(void) {
|
||||
CheckCondition(rocksdb_options_get_use_fsync(obj) == 1);
|
||||
rocksdb_options_set_use_fsync(obj, 0);
|
||||
CheckCondition(rocksdb_options_get_use_fsync(obj) == 0);
|
||||
rocksdb_options_set_use_separate_remote_compaction_pool(obj, 1);
|
||||
CheckCondition(rocksdb_options_get_use_separate_remote_compaction_pool(obj) ==
|
||||
1);
|
||||
rocksdb_options_set_use_separate_remote_compaction_pool(obj, 0);
|
||||
CheckCondition(rocksdb_options_get_use_separate_remote_compaction_pool(obj) ==
|
||||
0);
|
||||
rocksdb_options_set_use_session_tmp_dir_for_remote_compaction(obj, 1);
|
||||
CheckCondition(
|
||||
rocksdb_options_get_use_session_tmp_dir_for_remote_compaction(obj) == 1);
|
||||
@@ -1140,12 +1118,6 @@ static void rocksdb_roundtrip_test_rocksdb_trace_options(void) {
|
||||
CheckCondition(rocksdb_trace_options_get_filter(obj) == 1);
|
||||
rocksdb_trace_options_set_filter(obj, 0);
|
||||
CheckCondition(rocksdb_trace_options_get_filter(obj) == 0);
|
||||
rocksdb_trace_options_set_include_read_write_options(obj, 1);
|
||||
CheckCondition(rocksdb_trace_options_get_include_read_write_options(obj) ==
|
||||
1);
|
||||
rocksdb_trace_options_set_include_read_write_options(obj, 0);
|
||||
CheckCondition(rocksdb_trace_options_get_include_read_write_options(obj) ==
|
||||
0);
|
||||
rocksdb_trace_options_set_max_trace_file_size(obj, 1);
|
||||
CheckCondition(rocksdb_trace_options_get_max_trace_file_size(obj) == 1);
|
||||
rocksdb_trace_options_set_max_trace_file_size(obj, 0);
|
||||
@@ -1421,7 +1393,6 @@ static void rocksdb_run_generated_roundtrip_tests(void) {
|
||||
rocksdb_roundtrip_test_rocksdb_fifo_compaction_options();
|
||||
rocksdb_roundtrip_test_rocksdb_flushoptions();
|
||||
rocksdb_roundtrip_test_rocksdb_flushwaloptions();
|
||||
rocksdb_roundtrip_test_rocksdb_import_column_family_options();
|
||||
rocksdb_roundtrip_test_rocksdb_ingestexternalfileoptions();
|
||||
rocksdb_roundtrip_test_rocksdb_livefiles_storage_info_options();
|
||||
rocksdb_roundtrip_test_rocksdb_open_and_compact_options();
|
||||
|
||||
Vendored
+2
-3
@@ -180,7 +180,7 @@ DEFINE_uint32(
|
||||
// than random." Even with this setting, file offsets are not randomized.
|
||||
DEFINE_bool(sck_randomize, false,
|
||||
"(-stress_cache_key) Randomize (hash) cache key");
|
||||
// See https://github.com/meta/rocksdb/pull/9058
|
||||
// See https://github.com/facebook/rocksdb/pull/9058
|
||||
DEFINE_bool(sck_footer_unique_id, false,
|
||||
"(-stress_cache_key) Simulate using proposed footer unique id");
|
||||
// ## END stress_cache_key sub-tool options ##
|
||||
@@ -276,8 +276,7 @@ struct KeyGen {
|
||||
// location, so we fix hash bits starting at the bottom of that word.
|
||||
auto hi_hash = uint64_t{0x9e3779b97f4a7c13U} ^
|
||||
(key_hash << 1 << (FLAGS_degenerate_hash_bits - 1));
|
||||
uint64_t un_hi;
|
||||
uint64_t un_lo;
|
||||
uint64_t un_hi, un_lo;
|
||||
BijectiveUnhash2x64(hi_hash, key_hash, &un_hi, &un_lo);
|
||||
un_lo ^= BitwiseAnd(FLAGS_seed, INT32_MAX);
|
||||
EncodeFixed64(key_data, un_lo);
|
||||
|
||||
Vendored
+2
-7
@@ -32,9 +32,9 @@ class CacheReservationManager {
|
||||
// for an incremental amount of memory used (i.e, incremental_memory_used)
|
||||
class CacheReservationHandle {
|
||||
public:
|
||||
virtual ~CacheReservationHandle() = default;
|
||||
virtual ~CacheReservationHandle() {}
|
||||
};
|
||||
virtual ~CacheReservationManager() = default;
|
||||
virtual ~CacheReservationManager() {}
|
||||
virtual Status UpdateCacheReservation(std::size_t new_memory_used) = 0;
|
||||
// TODO(hx235): replace the usage of
|
||||
// `UpdateCacheReservation(memory_used_delta, increase)` with
|
||||
@@ -235,11 +235,6 @@ class ConcurrentCacheReservationManager
|
||||
cache_res_mgr_ = cache_res_mgr;
|
||||
cache_res_handle_ = std::move(cache_res_handle);
|
||||
}
|
||||
// No copying allowed
|
||||
CacheReservationHandle(const CacheReservationHandle&) = delete;
|
||||
CacheReservationHandle& operator=(const CacheReservationHandle&) = delete;
|
||||
CacheReservationHandle(CacheReservationHandle&&) = delete;
|
||||
CacheReservationHandle& operator=(CacheReservationHandle&&) = delete;
|
||||
|
||||
~CacheReservationHandle() override {
|
||||
std::lock_guard<std::mutex> lock(cache_res_mgr_->cache_res_mgr_mu_);
|
||||
|
||||
+2
-2
@@ -407,8 +407,8 @@ TEST(CacheReservationHandleTest, HandleTest) {
|
||||
std::size_t mem_used = 0;
|
||||
const std::size_t incremental_mem_used_handle_1 = 1 * kSizeDummyEntry;
|
||||
const std::size_t incremental_mem_used_handle_2 = 2 * kSizeDummyEntry;
|
||||
std::unique_ptr<CacheReservationManager::CacheReservationHandle> handle_1;
|
||||
std::unique_ptr<CacheReservationManager::CacheReservationHandle> handle_2;
|
||||
std::unique_ptr<CacheReservationManager::CacheReservationHandle> handle_1,
|
||||
handle_2;
|
||||
|
||||
// To test consecutive CacheReservationManager::MakeCacheReservation works
|
||||
// correctly in terms of returning the handle as well as updating cache
|
||||
|
||||
Vendored
-19
@@ -948,25 +948,6 @@ TEST_P(CacheTest, GetChargeAndDeleter) {
|
||||
cache_->Release(h1);
|
||||
}
|
||||
|
||||
TEST_P(LRUCacheTest, UnchargedStandaloneGetCharge) {
|
||||
auto cache = NewCache(1000, 0, true, kFullChargeCacheMetadata);
|
||||
Cache::Handle* pinned = nullptr;
|
||||
ASSERT_OK(
|
||||
cache->Insert(EncodeKey(1), EncodeValue(1), &kHelper, 800, &pinned));
|
||||
|
||||
ASSERT_EQ(nullptr, cache->CreateStandalone(EncodeKey(2), EncodeValue(2),
|
||||
&kHelper, 500, false));
|
||||
|
||||
Cache::Handle* h = cache->CreateStandalone(EncodeKey(2), EncodeValue(2),
|
||||
&kHelper, 500, true);
|
||||
ASSERT_NE(h, nullptr);
|
||||
EXPECT_EQ(0, cache->GetCharge(h));
|
||||
EXPECT_EQ(0, cache->GetUsage(h));
|
||||
|
||||
cache->Release(h);
|
||||
cache->Release(pinned);
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool AreTwoCacheKeysOrdered(Cache* cache) {
|
||||
std::vector<std::string> keys;
|
||||
|
||||
Vendored
+3
-12
@@ -975,8 +975,7 @@ void FixedHyperClockTable::Erase(const UniqueId64x2& hashed_key) {
|
||||
// Could be multiple entries in rare cases. Erase them all.
|
||||
// Optimistically increment acquire counter
|
||||
auto add_acquire = AcquireCounter::PlusTransformPromiseNoOverflow(1);
|
||||
SlotMeta old_meta;
|
||||
SlotMeta meta;
|
||||
SlotMeta old_meta, meta;
|
||||
h->meta.Apply(add_acquire, &old_meta, &meta);
|
||||
// Check if it's an entry visible to lookups
|
||||
if (meta.IsVisible()) {
|
||||
@@ -1739,8 +1738,7 @@ inline bool MatchAndRef(const UniqueId64x2* hashed_key, const ClockHandle& h,
|
||||
// Must be at least something to match
|
||||
assert(hashed_key || shift > 0);
|
||||
|
||||
SlotMeta old_meta;
|
||||
SlotMeta new_meta;
|
||||
SlotMeta old_meta, new_meta;
|
||||
// (Optimistically) increment acquire counter.
|
||||
auto add_acquire = AcquireCounter::PlusTransformPromiseNoOverflow(1);
|
||||
h.meta.Apply(add_acquire, &old_meta, &new_meta);
|
||||
@@ -1858,12 +1856,6 @@ class AutoHyperClockTable::ChainRewriteLock {
|
||||
assert(saved_head_.IsLocked());
|
||||
}
|
||||
|
||||
// No copying allowed
|
||||
ChainRewriteLock(const ChainRewriteLock&) = delete;
|
||||
ChainRewriteLock& operator=(const ChainRewriteLock&) = delete;
|
||||
ChainRewriteLock(ChainRewriteLock&&) = delete;
|
||||
ChainRewriteLock& operator=(ChainRewriteLock&&) = delete;
|
||||
|
||||
~ChainRewriteLock() {
|
||||
if (!IsEnd()) {
|
||||
// Release lock
|
||||
@@ -3130,8 +3122,7 @@ AutoHyperClockTable::HandleImpl* AutoHyperClockTable::Lookup(
|
||||
if (probably_equal) {
|
||||
// Increment acquire counter for definitive check
|
||||
auto add_acquire = AcquireCounter::PlusTransformPromiseNoOverflow(1);
|
||||
SlotMeta old_meta;
|
||||
SlotMeta new_meta;
|
||||
SlotMeta old_meta, new_meta;
|
||||
h->meta.Apply(add_acquire, &old_meta, &new_meta);
|
||||
// Check if it's a referencable (sharable) entry
|
||||
if (LIKELY(old_meta.IsShareable())) {
|
||||
|
||||
Vendored
-4
@@ -29,10 +29,6 @@ class CompressedSecondaryCacheResultHandle : public SecondaryCacheResultHandle {
|
||||
const CompressedSecondaryCacheResultHandle&) = delete;
|
||||
CompressedSecondaryCacheResultHandle& operator=(
|
||||
const CompressedSecondaryCacheResultHandle&) = delete;
|
||||
CompressedSecondaryCacheResultHandle(CompressedSecondaryCacheResultHandle&&) =
|
||||
delete;
|
||||
CompressedSecondaryCacheResultHandle& operator=(
|
||||
CompressedSecondaryCacheResultHandle&&) = delete;
|
||||
|
||||
bool IsReady() override { return true; }
|
||||
|
||||
|
||||
+1
-2
@@ -508,8 +508,7 @@ class CompressedSecondaryCacheTestBase : public testing::Test,
|
||||
std::string str1 = rnd.RandomString(1001);
|
||||
auto item1 = std::make_unique<TestItem>(str1.data(), str1.length());
|
||||
ASSERT_OK(cache->Insert(key1, item1.get(), GetHelper(), str1.length()));
|
||||
// Appease clang-analyze "potential memory leak"
|
||||
[[maybe_unused]] TestItem* released_item1 = item1.release();
|
||||
item1.release(); // Appease clang-analyze "potential memory leak"
|
||||
|
||||
Cache::Handle* handle;
|
||||
handle = cache->Lookup(key2, nullptr, this, Cache::Priority::LOW);
|
||||
|
||||
Vendored
+1
-1
@@ -574,7 +574,7 @@ LRUHandle* LRUCacheShard::CreateStandalone(const Slice& key, uint32_t hash,
|
||||
|
||||
if (strict_capacity_limit_ && (usage_ + e->total_charge) > capacity_) {
|
||||
if (allow_uncharged) {
|
||||
e->total_charge = LRUHandle::kUnchargedStandaloneTotalCharge;
|
||||
e->total_charge = 0;
|
||||
} else {
|
||||
free(e);
|
||||
e = nullptr;
|
||||
|
||||
Vendored
-8
@@ -87,10 +87,6 @@ struct LRUHandle : public Cache::Handle {
|
||||
IM_IS_STANDALONE = (1 << 2),
|
||||
};
|
||||
|
||||
// total_charge sentinel for a standalone entry that added nothing to usage_
|
||||
// (strict cache full, created with allow_uncharged).
|
||||
static constexpr size_t kUnchargedStandaloneTotalCharge = 0;
|
||||
|
||||
// Beginning of the key (MUST BE THE LAST FIELD IN THIS STRUCT!)
|
||||
char key_data[1];
|
||||
|
||||
@@ -200,10 +196,6 @@ struct LRUHandle : public Cache::Handle {
|
||||
|
||||
inline size_t GetCharge(
|
||||
CacheMetadataChargePolicy metadata_charge_policy) const {
|
||||
if (IsStandalone() && total_charge == kUnchargedStandaloneTotalCharge) {
|
||||
// Documented to report 0; no metadata was charged.
|
||||
return 0;
|
||||
}
|
||||
size_t meta_charge = CalcuMetaCharge(metadata_charge_policy);
|
||||
assert(total_charge >= meta_charge);
|
||||
return total_charge - meta_charge;
|
||||
|
||||
Vendored
+58
-72
@@ -1366,8 +1366,7 @@ TEST_P(BasicSecondaryCacheTest, BasicFailTest) {
|
||||
// str1.length()).IsInvalidArgument());
|
||||
ASSERT_OK(
|
||||
cache->Insert(k1.AsSlice(), item1.get(), GetHelper(), str1.length()));
|
||||
// Appease clang-analyze "potential memory leak"
|
||||
[[maybe_unused]] TestItem* released_item1 = item1.release();
|
||||
item1.release(); // Appease clang-analyze "potential memory leak"
|
||||
|
||||
Cache::Handle* handle;
|
||||
handle = cache->Lookup(k2.AsSlice(), nullptr, /*context*/ this,
|
||||
@@ -1474,81 +1473,68 @@ TEST_P(BasicSecondaryCacheTest, CreateFailTest) {
|
||||
}
|
||||
|
||||
TEST_P(BasicSecondaryCacheTest, FullCapacityTest) {
|
||||
const size_t kValueSize = 700;
|
||||
estimated_value_size_ = kValueSize;
|
||||
for (CacheMetadataChargePolicy charge_policy :
|
||||
{kDontChargeCacheMetadata, kFullChargeCacheMetadata}) {
|
||||
SCOPED_TRACE(charge_policy);
|
||||
for (bool strict_capacity_limit : {false, true}) {
|
||||
SCOPED_TRACE(strict_capacity_limit);
|
||||
std::shared_ptr<TestSecondaryCache> secondary_cache =
|
||||
std::make_shared<TestSecondaryCache>(2048, true);
|
||||
std::shared_ptr<Cache> cache =
|
||||
NewCache(1024, [&](ShardedCacheOptions& opts) {
|
||||
opts.num_shard_bits = 0;
|
||||
opts.strict_capacity_limit = strict_capacity_limit;
|
||||
opts.metadata_charge_policy = charge_policy;
|
||||
opts.secondary_cache = secondary_cache;
|
||||
});
|
||||
CacheKey k1 = CacheKey::CreateUniqueForCacheLifetime(cache.get());
|
||||
CacheKey k2 = CacheKey::CreateUniqueForCacheLifetime(cache.get());
|
||||
for (bool strict_capacity_limit : {false, true}) {
|
||||
std::shared_ptr<TestSecondaryCache> secondary_cache =
|
||||
std::make_shared<TestSecondaryCache>(2048, true);
|
||||
std::shared_ptr<Cache> cache =
|
||||
NewCache(1024 /* capacity */, 0 /* num_shard_bits */,
|
||||
strict_capacity_limit, secondary_cache);
|
||||
CacheKey k1 = CacheKey::CreateUniqueForCacheLifetime(cache.get());
|
||||
CacheKey k2 = CacheKey::CreateUniqueForCacheLifetime(cache.get());
|
||||
|
||||
Random rnd(301);
|
||||
std::string str1 = rnd.RandomString(kValueSize);
|
||||
TestItem* item1 = new TestItem(str1.data(), str1.length());
|
||||
ASSERT_OK(cache->Insert(k1.AsSlice(), item1, GetHelper(), str1.length()));
|
||||
std::string str2 = rnd.RandomString(kValueSize);
|
||||
TestItem* item2 = new TestItem(str2.data(), str2.length());
|
||||
// k1 should be demoted to NVM
|
||||
ASSERT_OK(cache->Insert(k2.AsSlice(), item2, GetHelper(), str2.length()));
|
||||
Random rnd(301);
|
||||
std::string str1 = rnd.RandomString(1020);
|
||||
TestItem* item1 = new TestItem(str1.data(), str1.length());
|
||||
ASSERT_OK(cache->Insert(k1.AsSlice(), item1, GetHelper(), str1.length()));
|
||||
std::string str2 = rnd.RandomString(1020);
|
||||
TestItem* item2 = new TestItem(str2.data(), str2.length());
|
||||
// k1 should be demoted to NVM
|
||||
ASSERT_OK(cache->Insert(k2.AsSlice(), item2, GetHelper(), str2.length()));
|
||||
|
||||
Cache::Handle* handle2;
|
||||
handle2 = cache->Lookup(k2.AsSlice(), GetHelper(),
|
||||
/*context*/ this, Cache::Priority::LOW);
|
||||
Cache::Handle* handle2;
|
||||
handle2 = cache->Lookup(k2.AsSlice(), GetHelper(),
|
||||
/*context*/ this, Cache::Priority::LOW);
|
||||
ASSERT_NE(handle2, nullptr);
|
||||
// k1 lookup fails without secondary cache support
|
||||
Cache::Handle* handle1;
|
||||
handle1 = cache->Lookup(
|
||||
k1.AsSlice(),
|
||||
GetHelper(CacheEntryRole::kDataBlock, /*secondary_compatible=*/false),
|
||||
/*context*/ this, Cache::Priority::LOW);
|
||||
ASSERT_EQ(handle1, nullptr);
|
||||
|
||||
// k1 promotion can fail with strict_capacity_limit=true, but Lookup still
|
||||
// succeeds using a standalone handle
|
||||
handle1 = cache->Lookup(k1.AsSlice(), GetHelper(),
|
||||
/*context*/ this, Cache::Priority::LOW);
|
||||
ASSERT_NE(handle1, nullptr);
|
||||
|
||||
ASSERT_EQ(secondary_cache->num_inserts(), 1u);
|
||||
ASSERT_EQ(secondary_cache->num_lookups(), 1u);
|
||||
|
||||
// Releasing k2's handle first, k2 is evicted from primary iff k1 promotion
|
||||
// was charged to the cache (except HCC doesn't erase in Release() over
|
||||
// capacity)
|
||||
// FIXME: Insert to secondary from Release disabled
|
||||
cache->Release(handle2);
|
||||
cache->Release(handle1);
|
||||
handle2 = cache->Lookup(
|
||||
k2.AsSlice(),
|
||||
GetHelper(CacheEntryRole::kDataBlock, /*secondary_compatible=*/false),
|
||||
/*context*/ this, Cache::Priority::LOW);
|
||||
if (strict_capacity_limit || IsHyperClock()) {
|
||||
ASSERT_NE(handle2, nullptr);
|
||||
// k1 lookup fails without secondary cache support
|
||||
Cache::Handle* handle1;
|
||||
handle1 = cache->Lookup(
|
||||
k1.AsSlice(),
|
||||
GetHelper(CacheEntryRole::kDataBlock, /*secondary_compatible=*/false),
|
||||
/*context*/ this, Cache::Priority::LOW);
|
||||
ASSERT_EQ(handle1, nullptr);
|
||||
|
||||
// k1 promotion can fail with strict_capacity_limit=true, but Lookup still
|
||||
// succeeds using a standalone handle
|
||||
handle1 = cache->Lookup(k1.AsSlice(), GetHelper(),
|
||||
/*context*/ this, Cache::Priority::LOW);
|
||||
ASSERT_NE(handle1, nullptr);
|
||||
ASSERT_EQ(strict_capacity_limit ? 0 : str1.size(),
|
||||
cache->GetUsage(handle1));
|
||||
|
||||
ASSERT_EQ(secondary_cache->num_inserts(), 1u);
|
||||
ASSERT_EQ(secondary_cache->num_lookups(), 1u);
|
||||
|
||||
// Releasing k2's handle first, k2 is evicted from primary iff k1
|
||||
// promotion was charged to the cache (except HCC doesn't erase in
|
||||
// Release() over capacity)
|
||||
// FIXME: Insert to secondary from Release disabled
|
||||
cache->Release(handle2);
|
||||
cache->Release(handle1);
|
||||
handle2 = cache->Lookup(
|
||||
k2.AsSlice(),
|
||||
GetHelper(CacheEntryRole::kDataBlock, /*secondary_compatible=*/false),
|
||||
/*context*/ this, Cache::Priority::LOW);
|
||||
if (strict_capacity_limit || IsHyperClock()) {
|
||||
ASSERT_NE(handle2, nullptr);
|
||||
cache->Release(handle2);
|
||||
ASSERT_EQ(secondary_cache->num_inserts(), 1u);
|
||||
} else {
|
||||
ASSERT_EQ(handle2, nullptr);
|
||||
// FIXME: Insert to secondary from Release disabled
|
||||
// ASSERT_EQ(secondary_cache->num_inserts(), 2u);
|
||||
ASSERT_EQ(secondary_cache->num_inserts(), 1u);
|
||||
}
|
||||
|
||||
cache.reset();
|
||||
secondary_cache.reset();
|
||||
ASSERT_EQ(secondary_cache->num_inserts(), 1u);
|
||||
} else {
|
||||
ASSERT_EQ(handle2, nullptr);
|
||||
// FIXME: Insert to secondary from Release disabled
|
||||
// ASSERT_EQ(secondary_cache->num_inserts(), 2u);
|
||||
ASSERT_EQ(secondary_cache->num_inserts(), 1u);
|
||||
}
|
||||
|
||||
cache.reset();
|
||||
secondary_cache.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-8
@@ -90,7 +90,7 @@ class CacheShardBase {
|
||||
class ShardedCacheBase : public Cache {
|
||||
public:
|
||||
explicit ShardedCacheBase(const ShardedCacheOptions& opts);
|
||||
~ShardedCacheBase() override = default;
|
||||
virtual ~ShardedCacheBase() = default;
|
||||
|
||||
int GetNumShardBits() const;
|
||||
uint32_t GetNumShards() const;
|
||||
@@ -143,13 +143,7 @@ class ShardedCache : public ShardedCacheBase {
|
||||
sizeof(CacheShard) * GetNumShards()))),
|
||||
destroy_shards_in_dtor_(false) {}
|
||||
|
||||
// No copying allowed
|
||||
ShardedCache(const ShardedCache&) = delete;
|
||||
ShardedCache& operator=(const ShardedCache&) = delete;
|
||||
ShardedCache(ShardedCache&&) = delete;
|
||||
ShardedCache& operator=(ShardedCache&&) = delete;
|
||||
|
||||
~ShardedCache() override {
|
||||
virtual ~ShardedCache() {
|
||||
if (destroy_shards_in_dtor_) {
|
||||
ForEachShard([](CacheShard* cs) { cs->~CacheShard(); });
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -36,7 +36,7 @@ class TieredSecondaryCache : public SecondaryCacheWrapper {
|
||||
#endif
|
||||
}
|
||||
|
||||
~TieredSecondaryCache() override = default;
|
||||
~TieredSecondaryCache() override {}
|
||||
|
||||
const char* Name() const override { return "TieredSecondaryCache"; }
|
||||
|
||||
@@ -75,7 +75,7 @@ class TieredSecondaryCache : public SecondaryCacheWrapper {
|
||||
|
||||
class ResultHandle : public SecondaryCacheResultHandle {
|
||||
public:
|
||||
~ResultHandle() override = default;
|
||||
~ResultHandle() override {}
|
||||
|
||||
bool IsReady() override {
|
||||
if (inner_handle_ && inner_handle_->IsReady()) {
|
||||
|
||||
Vendored
+1
-1
@@ -951,7 +951,7 @@ TEST_F(DBTieredSecondaryCacheTest, FSBufferTest) {
|
||||
IODebugContext* dbg) override {
|
||||
for (size_t i = 0; i < num_reqs; ++i) {
|
||||
FSReadRequest& req = reqs[i];
|
||||
// See https://github.com/meta/rocksdb/pull/13195 for why we
|
||||
// See https://github.com/facebook/rocksdb/pull/13195 for why we
|
||||
// want to set up our test implementation for FSAllocationPtr this
|
||||
// way.
|
||||
char* internalData = new char[req.len];
|
||||
|
||||
Vendored
+1
-1
@@ -241,7 +241,7 @@ class FullTypedCacheHelperFns : public BasicTypedCacheHelperFns<TValue> {
|
||||
if (source != CacheTier::kVolatileTier) {
|
||||
return Status::InvalidArgument();
|
||||
}
|
||||
if constexpr (!std::is_empty_v<TCreateContext>) {
|
||||
if constexpr (sizeof(TCreateContext) > 0) {
|
||||
TCreateContext* tcontext = static_cast<TCreateContext*>(context);
|
||||
tcontext->Create(&value, out_charge, data, type, allocator);
|
||||
} else {
|
||||
|
||||
@@ -87,15 +87,15 @@ to scan.
|
||||
|
||||
## Reference Pull Request Summaries
|
||||
|
||||
- [PR #15216](https://github.com/meta/rocksdb/pull/15216) is a strong
|
||||
- [PR #15216](https://github.com/facebook/rocksdb/pull/15216) is a strong
|
||||
focused bug-fix example. It traces stale iterator state to readahead behavior
|
||||
and dropped keys, identifies the exact prerequisites and unaffected mmap
|
||||
case, gives before/after measurements, and explains how the regression test
|
||||
fails when the fix is reverted.
|
||||
- [PR #15218](https://github.com/meta/rocksdb/pull/15218) is a concise
|
||||
- [PR #15218](https://github.com/facebook/rocksdb/pull/15218) is a concise
|
||||
example of explicit `Why`, `Previous behavior`, `New behavior`,
|
||||
`Implementation`, and `Safety boundaries and unsupported cases` sections.
|
||||
- Peter Dillinger's [PR #15231](https://github.com/meta/rocksdb/pull/15231)
|
||||
- Peter Dillinger's [PR #15231](https://github.com/facebook/rocksdb/pull/15231)
|
||||
is a strong recent multi-part example. Its `Fix`/`Add`/`Change` bullets
|
||||
separate the behaviors, its compatibility sentence explains how old files
|
||||
read back, and its test plan maps each new persisted property to concrete
|
||||
|
||||
@@ -42,13 +42,6 @@ class ArenaWrappedDBIter : public Iterator {
|
||||
std::unique_ptr<ColumnFamilyData, ColumnFamilyDataUnrefDeleter>;
|
||||
|
||||
public:
|
||||
ArenaWrappedDBIter() = default;
|
||||
// No copying allowed
|
||||
ArenaWrappedDBIter(const ArenaWrappedDBIter&) = delete;
|
||||
ArenaWrappedDBIter& operator=(const ArenaWrappedDBIter&) = delete;
|
||||
ArenaWrappedDBIter(ArenaWrappedDBIter&&) = delete;
|
||||
ArenaWrappedDBIter& operator=(ArenaWrappedDBIter&&) = delete;
|
||||
|
||||
~ArenaWrappedDBIter() override {
|
||||
if (db_iter_ != nullptr) {
|
||||
DestroyDBIter();
|
||||
|
||||
@@ -24,8 +24,6 @@ class AttributeGroupIteratorImpl : public AttributeGroupIterator {
|
||||
AttributeGroupIteratorImpl(const AttributeGroupIteratorImpl&) = delete;
|
||||
AttributeGroupIteratorImpl& operator=(const AttributeGroupIteratorImpl&) =
|
||||
delete;
|
||||
AttributeGroupIteratorImpl(AttributeGroupIteratorImpl&&) = delete;
|
||||
AttributeGroupIteratorImpl& operator=(AttributeGroupIteratorImpl&&) = delete;
|
||||
|
||||
bool Valid() const override { return impl_.Valid(); }
|
||||
void SeekToFirst() override { impl_.SeekToFirst(); }
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <optional>
|
||||
|
||||
#include "db/blob/blob_garbage_meter.h"
|
||||
#include "rocksdb/rocksdb_namespace.h"
|
||||
@@ -22,14 +21,10 @@ namespace ROCKSDB_NAMESPACE {
|
||||
class BlobCountingIterator : public InternalIterator {
|
||||
public:
|
||||
BlobCountingIterator(InternalIterator* iter,
|
||||
BlobGarbageMeter* blob_garbage_meter,
|
||||
bool track_current_key_inflow)
|
||||
BlobGarbageMeter* blob_garbage_meter)
|
||||
: iter_(iter), blob_garbage_meter_(blob_garbage_meter) {
|
||||
assert(iter_);
|
||||
assert(blob_garbage_meter_);
|
||||
if (track_current_key_inflow) {
|
||||
current_key_inflow_.emplace();
|
||||
}
|
||||
|
||||
UpdateAndCountBlobIfNeeded();
|
||||
}
|
||||
@@ -132,47 +127,23 @@ class BlobCountingIterator : public InternalIterator {
|
||||
return iter_->IsDeleteRangeSentinelKey();
|
||||
}
|
||||
|
||||
const BlobGarbageMeter& GetCurrentKeyInflow() const {
|
||||
assert(current_key_inflow_.has_value());
|
||||
return *current_key_inflow_;
|
||||
}
|
||||
|
||||
bool TracksCurrentKeyInflow() const {
|
||||
return current_key_inflow_.has_value();
|
||||
}
|
||||
|
||||
private:
|
||||
void UpdateAndCountBlobIfNeeded() {
|
||||
assert(!iter_->Valid() || iter_->status().ok());
|
||||
|
||||
if (!iter_->Valid()) {
|
||||
status_ = iter_->status();
|
||||
if (current_key_inflow_.has_value()) {
|
||||
current_key_inflow_->Clear();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
TEST_SYNC_POINT(
|
||||
"BlobCountingIterator::UpdateAndCountBlobIfNeeded:ProcessInFlow");
|
||||
|
||||
if (current_key_inflow_.has_value()) {
|
||||
current_key_inflow_->Clear();
|
||||
TEST_SYNC_POINT(
|
||||
"BlobCountingIterator::UpdateAndCountBlobIfNeeded:CurrentKeyInflow");
|
||||
status_ = current_key_inflow_->ProcessInFlow(key(), value());
|
||||
if (!status_.ok()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
TEST_SYNC_POINT(
|
||||
"BlobCountingIterator::UpdateAndCountBlobIfNeeded:AggregateInflow");
|
||||
status_ = blob_garbage_meter_->ProcessInFlow(key(), value());
|
||||
}
|
||||
|
||||
InternalIterator* iter_;
|
||||
BlobGarbageMeter* blob_garbage_meter_;
|
||||
std::optional<BlobGarbageMeter> current_key_inflow_;
|
||||
Status status_;
|
||||
};
|
||||
|
||||
|
||||
@@ -71,8 +71,7 @@ TEST(BlobCountingIteratorTest, CountBlobs) {
|
||||
VectorIterator input(keys, values);
|
||||
BlobGarbageMeter blob_garbage_meter;
|
||||
|
||||
BlobCountingIterator blob_counter(&input, &blob_garbage_meter,
|
||||
/*track_current_key_inflow=*/false);
|
||||
BlobCountingIterator blob_counter(&input, &blob_garbage_meter);
|
||||
|
||||
constexpr uint64_t first_expected_bytes =
|
||||
first_size +
|
||||
@@ -302,58 +301,6 @@ TEST(BlobCountingIteratorTest, CountBlobs) {
|
||||
5 * second_expected_bytes);
|
||||
}
|
||||
|
||||
TEST(BlobCountingIteratorTest, TracksCurrentKeyOnlyForResumableCompaction) {
|
||||
constexpr size_t kNumEntries = 1000;
|
||||
std::vector<std::string> keys;
|
||||
std::vector<std::string> values;
|
||||
keys.reserve(kNumEntries);
|
||||
values.reserve(kNumEntries);
|
||||
for (size_t i = 0; i < kNumEntries; ++i) {
|
||||
keys.push_back(
|
||||
test::KeyStr("key" + std::to_string(i), i + 1, kTypeBlobIndex));
|
||||
BlobIndex::EncodeBlob(&values.emplace_back(), /*file_number=*/7,
|
||||
/*offset=*/i * 100, /*size=*/100, kNoCompression);
|
||||
}
|
||||
|
||||
for (const bool track_current_key : {false, true}) {
|
||||
VectorIterator input(keys, values);
|
||||
BlobGarbageMeter blob_garbage_meter;
|
||||
size_t aggregate_parse_count = 0;
|
||||
size_t current_key_parse_count = 0;
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"BlobCountingIterator::UpdateAndCountBlobIfNeeded:AggregateInflow",
|
||||
[&](void*) { ++aggregate_parse_count; });
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"BlobCountingIterator::UpdateAndCountBlobIfNeeded:CurrentKeyInflow",
|
||||
[&](void*) { ++current_key_parse_count; });
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
|
||||
BlobCountingIterator blob_counter(&input, &blob_garbage_meter,
|
||||
track_current_key);
|
||||
EXPECT_EQ(blob_counter.TracksCurrentKeyInflow(), track_current_key);
|
||||
const BlobGarbageMeter* current_key_meter =
|
||||
track_current_key ? &blob_counter.GetCurrentKeyInflow() : nullptr;
|
||||
for (blob_counter.SeekToFirst(); blob_counter.Valid();
|
||||
blob_counter.Next()) {
|
||||
if (track_current_key) {
|
||||
// This checks reuse of the optional meter object, not allocations made
|
||||
// by its internal map while processing each key.
|
||||
EXPECT_EQ(&blob_counter.GetCurrentKeyInflow(), current_key_meter);
|
||||
}
|
||||
}
|
||||
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
|
||||
ASSERT_OK(blob_counter.status());
|
||||
EXPECT_EQ(aggregate_parse_count, kNumEntries);
|
||||
EXPECT_EQ(current_key_parse_count, track_current_key ? kNumEntries : 0);
|
||||
const auto flow = blob_garbage_meter.flows().find(7);
|
||||
ASSERT_NE(flow, blob_garbage_meter.flows().end());
|
||||
EXPECT_EQ(flow->second.GetInFlow().GetCount(), kNumEntries);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(BlobCountingIteratorTest, CorruptBlobIndex) {
|
||||
const std::vector<std::string> keys{
|
||||
test::KeyStr("user_key", 1, kTypeBlobIndex)};
|
||||
@@ -364,8 +311,7 @@ TEST(BlobCountingIteratorTest, CorruptBlobIndex) {
|
||||
VectorIterator input(keys, values);
|
||||
BlobGarbageMeter blob_garbage_meter;
|
||||
|
||||
BlobCountingIterator blob_counter(&input, &blob_garbage_meter,
|
||||
/*track_current_key_inflow=*/false);
|
||||
BlobCountingIterator blob_counter(&input, &blob_garbage_meter);
|
||||
|
||||
blob_counter.SeekToFirst();
|
||||
ASSERT_FALSE(blob_counter.Valid());
|
||||
|
||||
@@ -40,16 +40,15 @@ BlobFileBuilder::BlobFileBuilder(
|
||||
const std::string& column_family_name, Env::WriteLifeTimeHint write_hint,
|
||||
const std::shared_ptr<IOTracer>& io_tracer,
|
||||
BlobFileCompletionCallback* blob_callback,
|
||||
BlobFileCreationReason creation_reason, std::string blob_output_path,
|
||||
BlobFileCreationReason creation_reason,
|
||||
std::vector<std::string>* output_file_paths,
|
||||
std::vector<BlobFileAddition>* blob_file_additions)
|
||||
: BlobFileBuilder([versions]() { return versions->NewFileNumber(); }, fs,
|
||||
immutable_options, mutable_cf_options, file_options,
|
||||
write_options, std::move(db_id), std::move(db_session_id),
|
||||
job_id, column_family_id, column_family_name, write_hint,
|
||||
write_options, db_id, db_session_id, job_id,
|
||||
column_family_id, column_family_name, write_hint,
|
||||
io_tracer, blob_callback, creation_reason,
|
||||
std::move(blob_output_path), output_file_paths,
|
||||
blob_file_additions) {}
|
||||
output_file_paths, blob_file_additions) {}
|
||||
|
||||
BlobFileBuilder::BlobFileBuilder(
|
||||
std::function<uint64_t()> file_number_generator, FileSystem* fs,
|
||||
@@ -60,7 +59,7 @@ BlobFileBuilder::BlobFileBuilder(
|
||||
const std::string& column_family_name, Env::WriteLifeTimeHint write_hint,
|
||||
const std::shared_ptr<IOTracer>& io_tracer,
|
||||
BlobFileCompletionCallback* blob_callback,
|
||||
BlobFileCreationReason creation_reason, std::string blob_output_path,
|
||||
BlobFileCreationReason creation_reason,
|
||||
std::vector<std::string>* output_file_paths,
|
||||
std::vector<BlobFileAddition>* blob_file_additions)
|
||||
: file_number_generator_(std::move(file_number_generator)),
|
||||
@@ -91,7 +90,6 @@ BlobFileBuilder::BlobFileBuilder(
|
||||
io_tracer_(io_tracer),
|
||||
blob_callback_(blob_callback),
|
||||
creation_reason_(creation_reason),
|
||||
blob_output_path_(std::move(blob_output_path)),
|
||||
output_file_paths_(output_file_paths),
|
||||
blob_file_additions_(blob_file_additions),
|
||||
blob_count_(0),
|
||||
@@ -104,14 +102,16 @@ BlobFileBuilder::BlobFileBuilder(
|
||||
assert(output_file_paths_);
|
||||
assert(output_file_paths_->empty());
|
||||
assert(blob_file_additions_);
|
||||
// Resumable compactions restore finalized additions before creating a new
|
||||
// builder. Any newly generated blob files are appended to that state.
|
||||
assert(blob_file_additions_->empty());
|
||||
}
|
||||
|
||||
BlobFileBuilder::~BlobFileBuilder() = default;
|
||||
|
||||
std::string BlobFileBuilder::GetBlobFilePath(uint64_t blob_file_number) const {
|
||||
return BlobFileName(blob_output_path_, blob_file_number);
|
||||
assert(immutable_options_);
|
||||
assert(!immutable_options_->cf_paths.empty());
|
||||
return BlobFileName(immutable_options_->cf_paths.front().path,
|
||||
blob_file_number);
|
||||
}
|
||||
|
||||
Status BlobFileBuilder::Add(const Slice& key, const Slice& value,
|
||||
@@ -194,9 +194,6 @@ Status BlobFileBuilder::OpenBlobFileIfNeeded() {
|
||||
|
||||
assert(file_number_generator_);
|
||||
const uint64_t blob_file_number = file_number_generator_();
|
||||
if (blob_file_number == kInvalidBlobFileNumber) {
|
||||
return Status::Incomplete("Blob file number range exhausted");
|
||||
}
|
||||
|
||||
std::string blob_file_path = GetBlobFilePath(blob_file_number);
|
||||
|
||||
@@ -356,7 +353,7 @@ Status BlobFileBuilder::CloseBlobFile() {
|
||||
s = blob_callback_->OnBlobFileCompleted(
|
||||
GetBlobFilePath(blob_file_number), column_family_name_, job_id_,
|
||||
blob_file_number, creation_reason_, s, checksum_value, checksum_method,
|
||||
blob_count_, blob_bytes_, /*set_bg_error_on_space_limit=*/true);
|
||||
blob_count_, blob_bytes_);
|
||||
}
|
||||
|
||||
assert(blob_file_additions_);
|
||||
@@ -403,7 +400,7 @@ void BlobFileBuilder::Abandon(const Status& s) {
|
||||
->OnBlobFileCompleted(GetBlobFilePath(blob_file_number),
|
||||
column_family_name_, job_id_, blob_file_number,
|
||||
creation_reason_, s, "", "", blob_count_,
|
||||
blob_bytes_, /*set_bg_error_on_space_limit=*/true)
|
||||
blob_bytes_)
|
||||
.PermitUncheckedError();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@ class BlobFileBuilder {
|
||||
const std::shared_ptr<IOTracer>& io_tracer,
|
||||
BlobFileCompletionCallback* blob_callback,
|
||||
BlobFileCreationReason creation_reason,
|
||||
std::string blob_output_path,
|
||||
std::vector<std::string>* output_file_paths,
|
||||
std::vector<BlobFileAddition>* blob_file_additions);
|
||||
|
||||
@@ -64,14 +63,11 @@ class BlobFileBuilder {
|
||||
const std::shared_ptr<IOTracer>& io_tracer,
|
||||
BlobFileCompletionCallback* blob_callback,
|
||||
BlobFileCreationReason creation_reason,
|
||||
std::string blob_output_path,
|
||||
std::vector<std::string>* output_file_paths,
|
||||
std::vector<BlobFileAddition>* blob_file_additions);
|
||||
|
||||
BlobFileBuilder(const BlobFileBuilder&) = delete;
|
||||
BlobFileBuilder& operator=(const BlobFileBuilder&) = delete;
|
||||
BlobFileBuilder(BlobFileBuilder&&) = delete;
|
||||
BlobFileBuilder& operator=(BlobFileBuilder&&) = delete;
|
||||
|
||||
~BlobFileBuilder();
|
||||
|
||||
@@ -114,7 +110,6 @@ class BlobFileBuilder {
|
||||
std::shared_ptr<IOTracer> io_tracer_;
|
||||
BlobFileCompletionCallback* blob_callback_;
|
||||
BlobFileCreationReason creation_reason_;
|
||||
const std::string blob_output_path_;
|
||||
std::vector<std::string>* output_file_paths_;
|
||||
std::vector<BlobFileAddition>* blob_file_additions_;
|
||||
std::unique_ptr<BlobLogWriter> writer_;
|
||||
|
||||
@@ -148,8 +148,7 @@ TEST_F(BlobFileBuilderTest, BuildAndCheckOneFile) {
|
||||
&file_options_, &write_options_, "" /*db_id*/, "" /*db_session_id*/,
|
||||
job_id, column_family_id, column_family_name, write_hint,
|
||||
nullptr /*IOTracer*/, nullptr /*BlobFileCompletionCallback*/,
|
||||
BlobFileCreationReason::kFlush, immutable_options.cf_paths.front().path,
|
||||
&blob_file_paths, &blob_file_additions);
|
||||
BlobFileCreationReason::kFlush, &blob_file_paths, &blob_file_additions);
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> expected_key_value_pairs(
|
||||
number_of_blobs);
|
||||
@@ -233,8 +232,7 @@ TEST_F(BlobFileBuilderTest, BuildAndCheckMultipleFiles) {
|
||||
&file_options_, &write_options_, "" /*db_id*/, "" /*db_session_id*/,
|
||||
job_id, column_family_id, column_family_name, write_hint,
|
||||
nullptr /*IOTracer*/, nullptr /*BlobFileCompletionCallback*/,
|
||||
BlobFileCreationReason::kFlush, immutable_options.cf_paths.front().path,
|
||||
&blob_file_paths, &blob_file_additions);
|
||||
BlobFileCreationReason::kFlush, &blob_file_paths, &blob_file_additions);
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> expected_key_value_pairs(
|
||||
number_of_blobs);
|
||||
@@ -321,8 +319,7 @@ TEST_F(BlobFileBuilderTest, InlinedValues) {
|
||||
&file_options_, &write_options_, "" /*db_id*/, "" /*db_session_id*/,
|
||||
job_id, column_family_id, column_family_name, write_hint,
|
||||
nullptr /*IOTracer*/, nullptr /*BlobFileCompletionCallback*/,
|
||||
BlobFileCreationReason::kFlush, immutable_options.cf_paths.front().path,
|
||||
&blob_file_paths, &blob_file_additions);
|
||||
BlobFileCreationReason::kFlush, &blob_file_paths, &blob_file_additions);
|
||||
|
||||
for (size_t i = 0; i < number_of_blobs; ++i) {
|
||||
const std::string key = std::to_string(i);
|
||||
@@ -376,8 +373,7 @@ TEST_F(BlobFileBuilderTest, Compression) {
|
||||
&file_options_, &write_options_, "" /*db_id*/, "" /*db_session_id*/,
|
||||
job_id, column_family_id, column_family_name, write_hint,
|
||||
nullptr /*IOTracer*/, nullptr /*BlobFileCompletionCallback*/,
|
||||
BlobFileCreationReason::kFlush, immutable_options.cf_paths.front().path,
|
||||
&blob_file_paths, &blob_file_additions);
|
||||
BlobFileCreationReason::kFlush, &blob_file_paths, &blob_file_additions);
|
||||
|
||||
const std::string key("1");
|
||||
const std::string uncompressed_value(value_size, 'x');
|
||||
@@ -456,8 +452,7 @@ TEST_F(BlobFileBuilderTest, CompressionError) {
|
||||
&file_options_, &write_options_, "" /*db_id*/, "" /*db_session_id*/,
|
||||
job_id, column_family_id, column_family_name, write_hint,
|
||||
nullptr /*IOTracer*/, nullptr /*BlobFileCompletionCallback*/,
|
||||
BlobFileCreationReason::kFlush, immutable_options.cf_paths.front().path,
|
||||
&blob_file_paths, &blob_file_additions);
|
||||
BlobFileCreationReason::kFlush, &blob_file_paths, &blob_file_additions);
|
||||
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"LegacyForceBuiltinCompression:TamperWithStatus", [](void* arg) {
|
||||
@@ -537,8 +532,7 @@ TEST_F(BlobFileBuilderTest, Checksum) {
|
||||
&file_options_, &write_options_, "" /*db_id*/, "" /*db_session_id*/,
|
||||
job_id, column_family_id, column_family_name, write_hint,
|
||||
nullptr /*IOTracer*/, nullptr /*BlobFileCompletionCallback*/,
|
||||
BlobFileCreationReason::kFlush, immutable_options.cf_paths.front().path,
|
||||
&blob_file_paths, &blob_file_additions);
|
||||
BlobFileCreationReason::kFlush, &blob_file_paths, &blob_file_additions);
|
||||
|
||||
const std::string key("1");
|
||||
const std::string value("deadbeef");
|
||||
@@ -637,8 +631,7 @@ TEST_P(BlobFileBuilderIOErrorTest, IOError) {
|
||||
&file_options_, &write_options_, "" /*db_id*/, "" /*db_session_id*/,
|
||||
job_id, column_family_id, column_family_name, write_hint,
|
||||
nullptr /*IOTracer*/, nullptr /*BlobFileCompletionCallback*/,
|
||||
BlobFileCreationReason::kFlush, immutable_options.cf_paths.front().path,
|
||||
&blob_file_paths, &blob_file_additions);
|
||||
BlobFileCreationReason::kFlush, &blob_file_paths, &blob_file_additions);
|
||||
|
||||
SyncPoint::GetInstance()->SetCallBack(sync_point_, [this](void* arg) {
|
||||
Status* const s = static_cast<Status*>(arg);
|
||||
|
||||
@@ -98,7 +98,7 @@ Status BlobFileCache::GetBlobFileReader(
|
||||
}
|
||||
}
|
||||
|
||||
[[maybe_unused]] BlobFileReader* released_reader = reader.release();
|
||||
reader.release();
|
||||
|
||||
*blob_file_reader = cache_.Guard(handle);
|
||||
|
||||
|
||||
@@ -34,10 +34,6 @@ class BlobFileCache {
|
||||
|
||||
BlobFileCache(const BlobFileCache&) = delete;
|
||||
BlobFileCache& operator=(const BlobFileCache&) = delete;
|
||||
BlobFileCache(BlobFileCache&&) = delete;
|
||||
BlobFileCache& operator=(BlobFileCache&&) = delete;
|
||||
|
||||
~BlobFileCache() = default;
|
||||
|
||||
// Returns a cached reader for `blob_file`, opening and caching it on miss.
|
||||
// Checksum metadata is forwarded to the FileSystem through FileOptions when
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "db/event_helpers.h"
|
||||
#include "file/sst_file_manager_impl.h"
|
||||
#include "rocksdb/status.h"
|
||||
#include "util/cast_util.h"
|
||||
|
||||
namespace ROCKSDB_NAMESPACE {
|
||||
|
||||
@@ -39,12 +38,14 @@ class BlobFileCompletionCallback {
|
||||
job_id, creation_reason);
|
||||
}
|
||||
|
||||
Status OnBlobFileCompleted(
|
||||
const std::string& file_name, const std::string& column_family_name,
|
||||
int job_id, uint64_t file_number, BlobFileCreationReason creation_reason,
|
||||
const Status& report_status, const std::string& checksum_value,
|
||||
const std::string& checksum_method, uint64_t blob_count,
|
||||
uint64_t blob_bytes, bool set_bg_error_on_space_limit) {
|
||||
Status OnBlobFileCompleted(const std::string& file_name,
|
||||
const std::string& column_family_name, int job_id,
|
||||
uint64_t file_number,
|
||||
BlobFileCreationReason creation_reason,
|
||||
const Status& report_status,
|
||||
const std::string& checksum_value,
|
||||
const std::string& checksum_method,
|
||||
uint64_t blob_count, uint64_t blob_bytes) {
|
||||
Status s;
|
||||
|
||||
auto sfm = static_cast<SstFileManagerImpl*>(sst_file_manager_);
|
||||
@@ -55,72 +56,24 @@ class BlobFileCompletionCallback {
|
||||
s = Status::SpaceLimit("Max allowed space was reached");
|
||||
TEST_SYNC_POINT(
|
||||
"BlobFileCompletionCallback::CallBack::MaxAllowedSpaceReached");
|
||||
if (set_bg_error_on_space_limit) {
|
||||
// This callback historically reports space limits as flush errors.
|
||||
SetBGError(s);
|
||||
}
|
||||
InstrumentedMutexLock l(mutex_);
|
||||
error_handler_->SetBGError(s, BackgroundErrorReason::kFlush);
|
||||
}
|
||||
}
|
||||
|
||||
NotifyCreationFinished(
|
||||
file_name, column_family_name, job_id, file_number, creation_reason,
|
||||
(!report_status.ok() ? report_status : s), checksum_value,
|
||||
checksum_method, blob_count, blob_bytes);
|
||||
return s;
|
||||
}
|
||||
|
||||
// For a complete blob file that is kept even when the space limit is
|
||||
// reached. The file is registered with the SstFileManager at `file_size`,
|
||||
// which cannot fail, and its creation is reported as successful. Returns
|
||||
// whether the max allowed space is reached; the caller sets the background
|
||||
// error, because this does not acquire the DB mutex.
|
||||
bool OnKeptBlobFileCompleted(
|
||||
const std::string& file_name, const std::string& column_family_name,
|
||||
int job_id, uint64_t file_number, BlobFileCreationReason creation_reason,
|
||||
const std::string& checksum_value, const std::string& checksum_method,
|
||||
uint64_t blob_count, uint64_t blob_bytes, uint64_t file_size) {
|
||||
bool space_limit_reached = false;
|
||||
|
||||
SstFileManagerImpl* sfm =
|
||||
static_cast_with_check<SstFileManagerImpl>(sst_file_manager_);
|
||||
if (sfm) {
|
||||
sfm->OnAddFile(file_name, file_size).PermitUncheckedError();
|
||||
space_limit_reached = sfm->IsMaxAllowedSpaceReached();
|
||||
if (space_limit_reached) {
|
||||
TEST_SYNC_POINT(
|
||||
"BlobFileCompletionCallback::CallBack::MaxAllowedSpaceReached");
|
||||
}
|
||||
}
|
||||
|
||||
NotifyCreationFinished(file_name, column_family_name, job_id, file_number,
|
||||
creation_reason, Status::OK(), checksum_value,
|
||||
checksum_method, blob_count, blob_bytes);
|
||||
return space_limit_reached;
|
||||
}
|
||||
|
||||
void SetBGError(const Status& s) {
|
||||
InstrumentedMutexLock l(mutex_);
|
||||
error_handler_->SetBGError(s, BackgroundErrorReason::kFlush);
|
||||
}
|
||||
|
||||
private:
|
||||
void NotifyCreationFinished(const std::string& file_name,
|
||||
const std::string& column_family_name, int job_id,
|
||||
uint64_t file_number,
|
||||
BlobFileCreationReason creation_reason,
|
||||
const Status& status,
|
||||
const std::string& checksum_value,
|
||||
const std::string& checksum_method,
|
||||
uint64_t blob_count, uint64_t blob_bytes) {
|
||||
// Notify the listeners.
|
||||
EventHelpers::LogAndNotifyBlobFileCreationFinished(
|
||||
event_logger_, listeners_, dbname_, column_family_name, file_name,
|
||||
job_id, file_number, creation_reason, status,
|
||||
job_id, file_number, creation_reason,
|
||||
(!report_status.ok() ? report_status : s),
|
||||
(checksum_value.empty() ? kUnknownFileChecksum : checksum_value),
|
||||
(checksum_method.empty() ? kUnknownFileChecksumFuncName
|
||||
: checksum_method),
|
||||
blob_count, blob_bytes);
|
||||
return s;
|
||||
}
|
||||
|
||||
private:
|
||||
SstFileManager* sst_file_manager_;
|
||||
InstrumentedMutex* mutex_;
|
||||
ErrorHandler* error_handler_;
|
||||
|
||||
@@ -52,8 +52,6 @@ class SharedBlobFileMetaData {
|
||||
SharedBlobFileMetaData(SharedBlobFileMetaData&&) = delete;
|
||||
SharedBlobFileMetaData& operator=(SharedBlobFileMetaData&&) = delete;
|
||||
|
||||
~SharedBlobFileMetaData() = default;
|
||||
|
||||
uint64_t GetBlobFileSize() const;
|
||||
uint64_t GetBlobFileNumber() const { return blob_file_number_; }
|
||||
uint64_t GetTotalBlobCount() const { return total_blob_count_; }
|
||||
@@ -112,8 +110,6 @@ class BlobFileMetaData {
|
||||
BlobFileMetaData(BlobFileMetaData&&) = delete;
|
||||
BlobFileMetaData& operator=(BlobFileMetaData&&) = delete;
|
||||
|
||||
~BlobFileMetaData() = default;
|
||||
|
||||
const std::shared_ptr<SharedBlobFileMetaData>& GetSharedMeta() const {
|
||||
return shared_meta_;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "rocksdb/file_system.h"
|
||||
#include "util/aligned_buffer.h"
|
||||
#include "util/compression.h"
|
||||
#include "util/defer.h"
|
||||
#include "util/mutexlock.h"
|
||||
|
||||
namespace ROCKSDB_NAMESPACE {
|
||||
@@ -159,12 +158,6 @@ BlobFilePartitionManager::~BlobFilePartitionManager() {
|
||||
}
|
||||
}
|
||||
|
||||
BlobFilePartitionManager::DeferredFile::~DeferredFile() {
|
||||
// Only a later flush of the generation reads `seal_status`, and the DB may
|
||||
// close before one runs.
|
||||
seal_status.PermitUncheckedError();
|
||||
}
|
||||
|
||||
void BlobFilePartitionManager::ResetPartitionState(Partition* partition) {
|
||||
partition->writer.reset();
|
||||
partition->file_number = 0;
|
||||
@@ -178,19 +171,6 @@ void BlobFilePartitionManager::ResetPartitionState(Partition* partition) {
|
||||
partition->sync_required = false;
|
||||
}
|
||||
|
||||
BlobFilePartitionManager::DeferredFile
|
||||
BlobFilePartitionManager::DetachPartitionFile(Partition* partition) {
|
||||
DeferredFile deferred;
|
||||
deferred.writer = std::move(partition->writer);
|
||||
deferred.file_number = partition->file_number;
|
||||
deferred.blob_count = partition->blob_count;
|
||||
deferred.total_blob_bytes = partition->total_blob_bytes;
|
||||
deferred.garbage_blob_count = partition->garbage_blob_count;
|
||||
deferred.garbage_blob_bytes = partition->garbage_blob_bytes;
|
||||
ResetPartitionState(partition);
|
||||
return deferred;
|
||||
}
|
||||
|
||||
void BlobFilePartitionManager::AddFilePartitionMapping(uint64_t file_number,
|
||||
uint32_t partition_idx) {
|
||||
WriteLock lock(&file_partition_mutex_);
|
||||
@@ -275,7 +255,7 @@ Status BlobFilePartitionManager::OpenNewBlobFile(Partition* partition,
|
||||
|
||||
Status BlobFilePartitionManager::SealActiveBlobFile(
|
||||
const WriteOptions& write_options, Partition* partition,
|
||||
SealedFile* sealed_file, bool* space_limit_reached) {
|
||||
SealedFile* sealed_file) {
|
||||
assert(partition != nullptr);
|
||||
assert(partition->writer);
|
||||
assert(sealed_file != nullptr);
|
||||
@@ -284,8 +264,10 @@ Status BlobFilePartitionManager::SealActiveBlobFile(
|
||||
Status s =
|
||||
FinalizeBlobFile(write_options, partition->writer.get(), file_number,
|
||||
partition->blob_count, partition->total_blob_bytes,
|
||||
&sealed_file->addition, space_limit_reached);
|
||||
&sealed_file->addition);
|
||||
if (!s.ok()) {
|
||||
RemoveFilePartitionMapping(file_number);
|
||||
ResetPartitionState(partition);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -302,15 +284,11 @@ Status BlobFilePartitionManager::SealDeferredFile(
|
||||
assert(deferred->writer);
|
||||
assert(sealed_file != nullptr);
|
||||
|
||||
// As for its SST file, the flush sets a reached space limit as the
|
||||
// background error after it commits. An error set earlier would make the
|
||||
// flush roll back instead.
|
||||
bool space_limit_reached = false;
|
||||
Status s = FinalizeBlobFile(write_options, deferred->writer.get(),
|
||||
deferred->file_number, deferred->blob_count,
|
||||
deferred->total_blob_bytes,
|
||||
&sealed_file->addition, &space_limit_reached);
|
||||
Status s = FinalizeBlobFile(
|
||||
write_options, deferred->writer.get(), deferred->file_number,
|
||||
deferred->blob_count, deferred->total_blob_bytes, &sealed_file->addition);
|
||||
if (!s.ok()) {
|
||||
RemoveFilePartitionMapping(deferred->file_number);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -323,10 +301,9 @@ Status BlobFilePartitionManager::SealDeferredFile(
|
||||
Status BlobFilePartitionManager::FinalizeBlobFile(
|
||||
const WriteOptions& write_options, BlobLogWriter* writer,
|
||||
uint64_t file_number, uint64_t blob_count, uint64_t total_blob_bytes,
|
||||
BlobFileAddition* addition, bool* space_limit_reached) {
|
||||
BlobFileAddition* addition) {
|
||||
assert(writer != nullptr);
|
||||
assert(addition != nullptr);
|
||||
assert(space_limit_reached != nullptr);
|
||||
|
||||
BlobLogFooter footer;
|
||||
footer.blob_count = blob_count;
|
||||
@@ -340,13 +317,13 @@ Status BlobFilePartitionManager::FinalizeBlobFile(
|
||||
}
|
||||
|
||||
if (blob_callback_ != nullptr) {
|
||||
// `mutex_` is held, and the DB mutex must not be acquired under it.
|
||||
const std::string blob_file_path = BlobFileName(db_path_, file_number);
|
||||
if (blob_callback_->OnKeptBlobFileCompleted(
|
||||
blob_file_path, column_family_name_, /*job_id=*/0, file_number,
|
||||
BlobFileCreationReason::kFlush, checksum_value, checksum_method,
|
||||
blob_count, total_blob_bytes, writer->get_file_size())) {
|
||||
*space_limit_reached = true;
|
||||
s = blob_callback_->OnBlobFileCompleted(
|
||||
blob_file_path, column_family_name_, /*job_id=*/0, file_number,
|
||||
BlobFileCreationReason::kFlush, s, checksum_value, checksum_method,
|
||||
blob_count, total_blob_bytes);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,15 +477,6 @@ Status BlobFilePartitionManager::WriteBlob(
|
||||
value) %
|
||||
num_partitions_);
|
||||
|
||||
bool space_limit_reached = false;
|
||||
// Setting the background error takes the DB mutex, so it must run after
|
||||
// `mutex_` is released.
|
||||
Defer set_space_limit_error([&]() {
|
||||
if (space_limit_reached) {
|
||||
blob_callback_->SetBGError(
|
||||
Status::SpaceLimit("Max allowed space was reached"));
|
||||
}
|
||||
});
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
Partition* partition = partitions_[selected_partition_idx].get();
|
||||
@@ -518,16 +486,11 @@ Status BlobFilePartitionManager::WriteBlob(
|
||||
return Status::OK();
|
||||
}
|
||||
SealedFile sealed_file;
|
||||
Status s = SealActiveBlobFile(write_options, partition, &sealed_file,
|
||||
&space_limit_reached);
|
||||
if (!s.ok()) {
|
||||
DeferredFile failed = DetachPartitionFile(partition);
|
||||
failed.seal_status = s;
|
||||
current_generation_failed_files_.push_back(std::move(failed));
|
||||
return s;
|
||||
Status s = SealActiveBlobFile(write_options, partition, &sealed_file);
|
||||
if (s.ok()) {
|
||||
current_generation_sealed_files_.push_back(std::move(sealed_file));
|
||||
}
|
||||
current_generation_sealed_files_.push_back(std::move(sealed_file));
|
||||
return Status::OK();
|
||||
return s;
|
||||
};
|
||||
|
||||
const uint64_t record_size =
|
||||
@@ -580,41 +543,34 @@ Status BlobFilePartitionManager::WriteBlob(
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
void BlobFilePartitionManager::RotateCurrentGeneration(uint64_t memtable_id) {
|
||||
void BlobFilePartitionManager::RotateCurrentGeneration() {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
GenerationBatch batch;
|
||||
batch.memtable_id = memtable_id;
|
||||
batch.sealed_files = std::move(current_generation_sealed_files_);
|
||||
current_generation_sealed_files_.clear();
|
||||
for (auto& failed : current_generation_failed_files_) {
|
||||
batch.deferred_files.emplace_back(std::move(failed));
|
||||
}
|
||||
current_generation_failed_files_.clear();
|
||||
|
||||
for (auto& partition : partitions_) {
|
||||
if (!partition->writer) {
|
||||
continue;
|
||||
}
|
||||
batch.deferred_files.emplace_back(DetachPartitionFile(partition.get()));
|
||||
|
||||
DeferredFile deferred;
|
||||
deferred.writer = std::move(partition->writer);
|
||||
deferred.file_number = partition->file_number;
|
||||
deferred.blob_count = partition->blob_count;
|
||||
deferred.total_blob_bytes = partition->total_blob_bytes;
|
||||
deferred.garbage_blob_count = partition->garbage_blob_count;
|
||||
deferred.garbage_blob_bytes = partition->garbage_blob_bytes;
|
||||
ResetPartitionState(partition.get());
|
||||
batch.deferred_files.emplace_back(std::move(deferred));
|
||||
}
|
||||
|
||||
pending_generations_.emplace_back(std::move(batch));
|
||||
}
|
||||
|
||||
BlobFilePartitionManager::GenerationBatch*
|
||||
BlobFilePartitionManager::FindPendingGeneration(uint64_t memtable_id) {
|
||||
for (auto& batch : pending_generations_) {
|
||||
if (batch.memtable_id == memtable_id) {
|
||||
return &batch;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Status BlobFilePartitionManager::PrepareFlushAdditions(
|
||||
const WriteOptions& write_options,
|
||||
const std::vector<uint64_t>& memtable_ids,
|
||||
const WriteOptions& write_options, size_t num_generations,
|
||||
std::vector<BlobFileAddition>* additions,
|
||||
std::vector<BlobFileGarbage>* garbages,
|
||||
std::vector<std::vector<uint64_t>>* generation_blob_file_numbers) {
|
||||
@@ -627,26 +583,22 @@ Status BlobFilePartitionManager::PrepareFlushAdditions(
|
||||
}
|
||||
|
||||
MutexLock lock(&mutex_);
|
||||
for (const uint64_t memtable_id : memtable_ids) {
|
||||
GenerationBatch* const batch_ptr = FindPendingGeneration(memtable_id);
|
||||
if (batch_ptr == nullptr) {
|
||||
return Status::Corruption(
|
||||
"Missing blob direct write generation metadata for flush");
|
||||
}
|
||||
GenerationBatch& batch = *batch_ptr;
|
||||
if (num_generations > pending_generations_.size()) {
|
||||
return Status::Corruption(
|
||||
"Missing blob direct write generation metadata for flush");
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < num_generations; ++i) {
|
||||
GenerationBatch& batch = pending_generations_[i];
|
||||
while (!batch.deferred_files.empty()) {
|
||||
DeferredFile& deferred = batch.deferred_files.front();
|
||||
if (!deferred.seal_status.ok()) {
|
||||
return deferred.seal_status;
|
||||
}
|
||||
DeferredFile deferred = std::move(batch.deferred_files.front());
|
||||
batch.deferred_files.pop_front();
|
||||
|
||||
SealedFile sealed_file;
|
||||
Status s = SealDeferredFile(write_options, &deferred, &sealed_file);
|
||||
if (!s.ok()) {
|
||||
deferred.seal_status = s;
|
||||
return s;
|
||||
}
|
||||
batch.deferred_files.pop_front();
|
||||
// Keep each successfully sealed file attached to the generation
|
||||
// immediately. If a later seal or the flush job itself fails, retry must
|
||||
// reuse these exact on-disk files instead of finalizing replacements.
|
||||
@@ -694,12 +646,6 @@ Status BlobFilePartitionManager::MarkBlobWriteAsGarbage(uint64_t file_number,
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
for (auto& failed : current_generation_failed_files_) {
|
||||
if (MarkDeferredFileGarbage(&failed, file_number, blob_count, blob_bytes)) {
|
||||
return Status::OK();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& batch : pending_generations_) {
|
||||
for (auto& deferred : batch.deferred_files) {
|
||||
if (MarkDeferredFileGarbage(&deferred, file_number, blob_count,
|
||||
@@ -722,22 +668,12 @@ Status BlobFilePartitionManager::MarkBlobWriteAsGarbage(uint64_t file_number,
|
||||
return Status::Corruption(message);
|
||||
}
|
||||
|
||||
void BlobFilePartitionManager::CommitFlushedGenerations(
|
||||
uint64_t earliest_unflushed_memtable_id) {
|
||||
std::vector<uint64_t> sealed_file_numbers;
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
while (!pending_generations_.empty() &&
|
||||
pending_generations_.front().memtable_id <
|
||||
earliest_unflushed_memtable_id) {
|
||||
for (const auto& sealed_file :
|
||||
pending_generations_.front().sealed_files) {
|
||||
sealed_file_numbers.push_back(sealed_file.addition.GetBlobFileNumber());
|
||||
}
|
||||
pending_generations_.pop_front();
|
||||
}
|
||||
void BlobFilePartitionManager::CommitPreparedGenerations(
|
||||
size_t num_generations) {
|
||||
MutexLock lock(&mutex_);
|
||||
while (num_generations-- > 0 && !pending_generations_.empty()) {
|
||||
pending_generations_.pop_front();
|
||||
}
|
||||
RemoveFilePartitionMappings(sealed_file_numbers);
|
||||
}
|
||||
|
||||
Status BlobFilePartitionManager::SyncAllOpenFiles(
|
||||
|
||||
@@ -88,31 +88,27 @@ class BlobFilePartitionManager {
|
||||
const Slice& key,
|
||||
const WideColumns& columns) const;
|
||||
|
||||
// Move the current active partition files into the generation of the
|
||||
// memtable `memtable_id`, which just became immutable. Called from
|
||||
// SwitchMemtable() while DB mutex is held. No I/O is performed here.
|
||||
void RotateCurrentGeneration(uint64_t memtable_id);
|
||||
// Move the current active partition files into the next immutable
|
||||
// memtable-generation batch. Called from SwitchMemtable() while DB mutex is
|
||||
// held. No I/O is performed here.
|
||||
void RotateCurrentGeneration();
|
||||
|
||||
// Seal the queued generations of the memtables `memtable_ids` and return all
|
||||
// blob additions and initial-garbage updates that must be registered with
|
||||
// the flush of those memtables. Concurrent flushes pick different
|
||||
// memtables, so generations are matched by memtable ID, not by queue
|
||||
// position. Generations stay queued until CommitFlushedGenerations() removes
|
||||
// them. If `generation_blob_file_numbers` is non-null, it receives the
|
||||
// sealed blob file numbers for each memtable, in `memtable_ids` order.
|
||||
// Seal the first `num_generations` queued immutable generations and return
|
||||
// all blob additions and initial-garbage updates that must be registered
|
||||
// with the matching flush. Generations stay queued until
|
||||
// CommitPreparedGenerations() is called. If `generation_blob_file_numbers`
|
||||
// is non-null, it receives the sealed blob file numbers for each prepared
|
||||
// generation in the same FIFO order.
|
||||
Status PrepareFlushAdditions(const WriteOptions& write_options,
|
||||
const std::vector<uint64_t>& memtable_ids,
|
||||
size_t num_generations,
|
||||
std::vector<BlobFileAddition>* additions,
|
||||
std::vector<BlobFileGarbage>* garbages,
|
||||
std::vector<std::vector<uint64_t>>*
|
||||
generation_blob_file_numbers = nullptr);
|
||||
|
||||
// Remove the generations of the memtables older than
|
||||
// `earliest_unflushed_memtable_id`, whose flush results are installed, and
|
||||
// stop tracking their sealed files as manager-owned. A flush that finishes
|
||||
// before an older one is installed with it, or rolled back if it fails, so
|
||||
// the flush that prepared a generation cannot remove it on its own.
|
||||
void CommitFlushedGenerations(uint64_t earliest_unflushed_memtable_id);
|
||||
// Remove the first `num_generations` prepared immutable generations after
|
||||
// their blob-file additions and garbage edits were committed to MANIFEST.
|
||||
void CommitPreparedGenerations(size_t num_generations);
|
||||
|
||||
// In v1 flush-on-write mode each AddRecord flushes to the OS immediately, so
|
||||
// there is nothing extra to do for the non-sync write path.
|
||||
@@ -183,11 +179,6 @@ class BlobFilePartitionManager {
|
||||
};
|
||||
|
||||
struct DeferredFile {
|
||||
DeferredFile() = default;
|
||||
DeferredFile(DeferredFile&&) = default;
|
||||
DeferredFile& operator=(DeferredFile&&) = default;
|
||||
~DeferredFile();
|
||||
|
||||
// Blob writer moved out of an active partition at memtable rotation.
|
||||
std::unique_ptr<BlobLogWriter> writer;
|
||||
// Metadata preserved until flush preparation seals the file.
|
||||
@@ -197,10 +188,6 @@ class BlobFilePartitionManager {
|
||||
// Failed transformed writes already appended before the file is sealed.
|
||||
uint64_t garbage_blob_count = 0;
|
||||
uint64_t garbage_blob_bytes = 0;
|
||||
// Set once sealing fails. The writer cannot be finalized again, and
|
||||
// memtables still reference the file, so every flush of its generation
|
||||
// fails with this status.
|
||||
Status seal_status;
|
||||
};
|
||||
|
||||
struct SealedFile {
|
||||
@@ -213,8 +200,6 @@ class BlobFilePartitionManager {
|
||||
};
|
||||
|
||||
struct GenerationBatch {
|
||||
// The memtable that became immutable when this generation was rotated.
|
||||
uint64_t memtable_id = 0;
|
||||
// Files that were still open when the memtable became immutable.
|
||||
std::deque<DeferredFile> deferred_files;
|
||||
// Files already sealed for this memtable generation.
|
||||
@@ -223,24 +208,17 @@ class BlobFilePartitionManager {
|
||||
|
||||
// Clears all active-file bookkeeping from a partition after sealing.
|
||||
void ResetPartitionState(Partition* partition);
|
||||
// Returns the queued generation of `memtable_id`, or null.
|
||||
GenerationBatch* FindPendingGeneration(uint64_t memtable_id);
|
||||
// Moves a partition's open file out of the partition and resets it.
|
||||
DeferredFile DetachPartitionFile(Partition* partition);
|
||||
// Marks a blob file as manager-owned until it is committed or abandoned.
|
||||
void AddFilePartitionMapping(uint64_t file_number, uint32_t partition_idx);
|
||||
// Stops tracking a blob file after open failure.
|
||||
// Stops tracking a blob file after open/seal failure.
|
||||
void RemoveFilePartitionMapping(uint64_t file_number);
|
||||
|
||||
// Opens a new active blob file for one partition.
|
||||
Status OpenNewBlobFile(Partition* partition, uint32_t column_family_id,
|
||||
CompressionType compression, uint32_t partition_idx);
|
||||
// Finalizes one active partition file and returns the MANIFEST addition.
|
||||
// Sets `*space_limit_reached` if the SstFileManager's max allowed space is
|
||||
// reached; the seal still succeeds.
|
||||
Status SealActiveBlobFile(const WriteOptions& write_options,
|
||||
Partition* partition, SealedFile* sealed_file,
|
||||
bool* space_limit_reached);
|
||||
Partition* partition, SealedFile* sealed_file);
|
||||
// Finalizes one deferred file that was carried over to flush preparation.
|
||||
Status SealDeferredFile(const WriteOptions& write_options,
|
||||
DeferredFile* deferred, SealedFile* sealed_file);
|
||||
@@ -249,8 +227,7 @@ class BlobFilePartitionManager {
|
||||
Status FinalizeBlobFile(const WriteOptions& write_options,
|
||||
BlobLogWriter* writer, uint64_t file_number,
|
||||
uint64_t blob_count, uint64_t total_blob_bytes,
|
||||
BlobFileAddition* addition,
|
||||
bool* space_limit_reached);
|
||||
BlobFileAddition* addition);
|
||||
// Appends one initial-garbage record to the flush output if any failed
|
||||
// transformed writes targeted the sealed blob file.
|
||||
static void AddSealedFileGarbage(const SealedFile& sealed_file,
|
||||
@@ -309,8 +286,6 @@ class BlobFilePartitionManager {
|
||||
mutable port::Mutex mutex_;
|
||||
// Files already sealed while the current mutable memtable was active.
|
||||
std::vector<SealedFile> current_generation_sealed_files_;
|
||||
// Files whose seal failed while the current mutable memtable was active.
|
||||
std::vector<DeferredFile> current_generation_failed_files_;
|
||||
// FIFO immutable memtable generations waiting to be flushed.
|
||||
std::deque<GenerationBatch> pending_generations_;
|
||||
|
||||
|
||||
@@ -53,8 +53,6 @@ class BlobFileReader {
|
||||
|
||||
BlobFileReader(const BlobFileReader&) = delete;
|
||||
BlobFileReader& operator=(const BlobFileReader&) = delete;
|
||||
BlobFileReader(BlobFileReader&&) = delete;
|
||||
BlobFileReader& operator=(BlobFileReader&&) = delete;
|
||||
|
||||
~BlobFileReader();
|
||||
|
||||
|
||||
@@ -59,14 +59,6 @@ class BlobGarbageMeter {
|
||||
out_flow_.Add(bytes);
|
||||
assert(IsValid());
|
||||
}
|
||||
void AddOutFlow(uint64_t count, uint64_t bytes) {
|
||||
out_flow_.Add(count, bytes);
|
||||
assert(IsValid());
|
||||
}
|
||||
void AddGarbage(uint64_t count, uint64_t bytes) {
|
||||
in_flow_.Add(count, bytes);
|
||||
assert(IsValid());
|
||||
}
|
||||
|
||||
const BlobStats& GetInFlow() const { return in_flow_; }
|
||||
const BlobStats& GetOutFlow() const { return out_flow_; }
|
||||
@@ -98,21 +90,6 @@ class BlobGarbageMeter {
|
||||
Status ProcessInFlow(const Slice& key, const Slice& value);
|
||||
Status ProcessOutFlow(const Slice& key, const Slice& value);
|
||||
|
||||
void ProcessOutFlow(const BlobGarbageMeter& inflow) {
|
||||
for (const auto& [file_number, flow] : inflow.flows()) {
|
||||
const BlobStats& stats = flow.GetInFlow();
|
||||
flows_[file_number].AddOutFlow(stats.GetCount(), stats.GetBytes());
|
||||
}
|
||||
}
|
||||
|
||||
// Imports a garbage delta computed by another compaction process.
|
||||
void AddGarbage(uint64_t blob_file_number, uint64_t count, uint64_t bytes) {
|
||||
// A garbage delta is equivalent to inflow with no matching outflow.
|
||||
flows_[blob_file_number].AddGarbage(count, bytes);
|
||||
}
|
||||
|
||||
void Clear() { flows_.clear(); }
|
||||
|
||||
const std::unordered_map<uint64_t, BlobInOutFlow>& flows() const {
|
||||
return flows_;
|
||||
}
|
||||
|
||||
@@ -55,10 +55,6 @@ class BlobIndex {
|
||||
|
||||
BlobIndex(const BlobIndex&) = default;
|
||||
BlobIndex& operator=(const BlobIndex&) = default;
|
||||
BlobIndex(BlobIndex&&) = default;
|
||||
BlobIndex& operator=(BlobIndex&&) = default;
|
||||
|
||||
~BlobIndex() = default;
|
||||
|
||||
bool IsInlined() const { return type_ == Type::kInlinedTTL; }
|
||||
|
||||
@@ -106,9 +102,7 @@ class BlobIndex {
|
||||
|
||||
Status DecodeFrom(Slice slice) {
|
||||
const char* kErrorMessage = "Error while decoding blob index";
|
||||
if (slice.empty()) {
|
||||
return Status::Corruption(kErrorMessage, "Empty blob index");
|
||||
}
|
||||
assert(slice.size() > 0);
|
||||
type_ = static_cast<Type>(*slice.data());
|
||||
if (type_ >= Type::kUnknown) {
|
||||
return Status::Corruption(kErrorMessage,
|
||||
|
||||
@@ -43,8 +43,6 @@ class BlobLogSequentialReader {
|
||||
// No copying allowed
|
||||
BlobLogSequentialReader(const BlobLogSequentialReader&) = delete;
|
||||
BlobLogSequentialReader& operator=(const BlobLogSequentialReader&) = delete;
|
||||
BlobLogSequentialReader(BlobLogSequentialReader&&) = delete;
|
||||
BlobLogSequentialReader& operator=(BlobLogSequentialReader&&) = delete;
|
||||
|
||||
~BlobLogSequentialReader();
|
||||
|
||||
|
||||
@@ -37,8 +37,6 @@ class BlobLogWriter {
|
||||
// No copying allowed
|
||||
BlobLogWriter(const BlobLogWriter&) = delete;
|
||||
BlobLogWriter& operator=(const BlobLogWriter&) = delete;
|
||||
BlobLogWriter(BlobLogWriter&&) = delete;
|
||||
BlobLogWriter& operator=(BlobLogWriter&&) = delete;
|
||||
|
||||
~BlobLogWriter();
|
||||
|
||||
@@ -70,8 +68,6 @@ class BlobLogWriter {
|
||||
|
||||
uint64_t get_log_number() const { return log_number_; }
|
||||
|
||||
uint64_t get_file_size() const { return block_offset_; }
|
||||
|
||||
Status Sync(const WriteOptions& write_options);
|
||||
|
||||
private:
|
||||
|
||||
@@ -60,9 +60,6 @@ struct BlobReadRequest {
|
||||
BlobReadRequest() = default;
|
||||
BlobReadRequest(const BlobReadRequest& other) = default;
|
||||
BlobReadRequest& operator=(const BlobReadRequest& other) = default;
|
||||
BlobReadRequest(BlobReadRequest&& other) = default;
|
||||
BlobReadRequest& operator=(BlobReadRequest&& other) = default;
|
||||
~BlobReadRequest() = default;
|
||||
};
|
||||
|
||||
using BlobFileReadRequests =
|
||||
|
||||
@@ -202,7 +202,7 @@ Status BlobSource::PutBlobIntoCache(
|
||||
const Status s = InsertEntryIntoCache(cache_key, blob->get(), &cache_handle,
|
||||
Cache::Priority::BOTTOM);
|
||||
if (s.ok()) {
|
||||
[[maybe_unused]] BlobContents* released_blob = blob->release();
|
||||
blob->release();
|
||||
|
||||
assert(cache_handle != nullptr);
|
||||
*cached_blob =
|
||||
|
||||
@@ -67,8 +67,6 @@ class BlobSource {
|
||||
|
||||
BlobSource(const BlobSource&) = delete;
|
||||
BlobSource& operator=(const BlobSource&) = delete;
|
||||
BlobSource(BlobSource&&) = delete;
|
||||
BlobSource& operator=(BlobSource&&) = delete;
|
||||
|
||||
~BlobSource();
|
||||
|
||||
|
||||
@@ -41,73 +41,6 @@ class DBBlobBasicTest : public DBTestBase {
|
||||
protected:
|
||||
DBBlobBasicTest()
|
||||
: DBTestBase("db_blob_basic_test", /* env_do_fsync */ false) {}
|
||||
|
||||
Options MissingBlobRepairOptions() {
|
||||
Options options = GetDefaultOptions();
|
||||
options.create_if_missing = true;
|
||||
options.enable_blob_files = true;
|
||||
options.min_blob_size = 0;
|
||||
options.enable_blob_garbage_collection = false;
|
||||
options.disable_auto_compactions = true;
|
||||
options.num_levels = 3;
|
||||
options.level_compaction_dynamic_level_bytes = false;
|
||||
return options;
|
||||
}
|
||||
|
||||
void AssertBlobReference(const Slice& key, uint64_t blob_file_number) {
|
||||
PinnableSlice value;
|
||||
bool is_blob_index = false;
|
||||
DBImpl::GetImplOptions get_options;
|
||||
get_options.column_family = db_->DefaultColumnFamily();
|
||||
get_options.value = &value;
|
||||
get_options.is_blob_index = &is_blob_index;
|
||||
ASSERT_OK(dbfull()->GetImpl(ReadOptions(), key, get_options));
|
||||
ASSERT_TRUE(is_blob_index);
|
||||
BlobIndex blob_index;
|
||||
ASSERT_OK(blob_index.DecodeFrom(value));
|
||||
ASSERT_EQ(blob_index.file_number(), blob_file_number);
|
||||
}
|
||||
|
||||
void RecoverMissingNonOldestBlob(const Options& options,
|
||||
bool preserve_older_value,
|
||||
uint64_t* missing_blob_file) {
|
||||
DestroyAndReopen(options);
|
||||
ASSERT_OK(Put("a", "va"));
|
||||
ASSERT_OK(Put("c", "vc"));
|
||||
if (preserve_older_value) {
|
||||
ASSERT_OK(Put("b", "old"));
|
||||
}
|
||||
ASSERT_OK(Flush());
|
||||
const Snapshot* snapshot =
|
||||
preserve_older_value ? db_->GetSnapshot() : nullptr;
|
||||
{
|
||||
Defer release_snapshot([this, snapshot]() {
|
||||
if (snapshot) {
|
||||
db_->ReleaseSnapshot(snapshot);
|
||||
}
|
||||
});
|
||||
ASSERT_OK(Put("b", "vb"));
|
||||
ASSERT_OK(Put("d", "vd"));
|
||||
ASSERT_OK(Flush());
|
||||
const std::vector<uint64_t> blob_files = GetBlobFileNumbers();
|
||||
ASSERT_EQ(blob_files.size(), 2);
|
||||
*missing_blob_file = blob_files.back();
|
||||
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
|
||||
ASSERT_EQ(TotalTableFiles(), 1);
|
||||
}
|
||||
|
||||
Close();
|
||||
ASSERT_OK(env_->DeleteFile(BlobFileName(dbname_, *missing_blob_file)));
|
||||
Options recovery_options = options;
|
||||
recovery_options.best_efforts_recovery = true;
|
||||
Reopen(recovery_options);
|
||||
const std::vector<uint64_t> live_blob_files = GetBlobFileNumbers();
|
||||
ASSERT_EQ(live_blob_files.size(), 1);
|
||||
ASSERT_NE(live_blob_files.front(), *missing_blob_file);
|
||||
ASSERT_EQ(TotalTableFiles(), 1);
|
||||
ASSERT_NO_FATAL_FAILURE(AssertBlobReference("b", *missing_blob_file));
|
||||
ASSERT_NO_FATAL_FAILURE(AssertBlobReference("d", *missing_blob_file));
|
||||
}
|
||||
};
|
||||
|
||||
class BlobFileChecksumCapturingFS : public FileSystemWrapper {
|
||||
@@ -1550,335 +1483,6 @@ TEST_F(DBBlobBasicTest, BestEffortsRecovery_MissingNewestBlobFile) {
|
||||
ASSERT_EQ("value" + std::to_string(kNumTableFiles - 2), value);
|
||||
}
|
||||
|
||||
TEST_F(DBBlobBasicTest, RepairMissingNonOldestBlobAfterBestEffortsRecovery) {
|
||||
Options options = MissingBlobRepairOptions();
|
||||
options.statistics = CreateDBStatistics();
|
||||
uint64_t missing_blob_file = 0;
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
RecoverMissingNonOldestBlob(options, false, &missing_blob_file));
|
||||
const std::vector<uint64_t> healthy_blob_files = GetBlobFileNumbers();
|
||||
ColumnFamilyMetaData before;
|
||||
db_->GetColumnFamilyMetaData(db_->DefaultColumnFamily(), &before);
|
||||
|
||||
CompactRangeOptions repair;
|
||||
repair.skip_missing_blob_files = true;
|
||||
repair.bottommost_level_compaction = BottommostLevelCompaction::kSkip;
|
||||
repair.max_subcompactions = 2;
|
||||
repair.blob_garbage_collection_policy = BlobGarbageCollectionPolicy::kDisable;
|
||||
ASSERT_OK(options.statistics->Reset());
|
||||
ASSERT_OK(db_->CompactRange(repair, nullptr, nullptr));
|
||||
ASSERT_GT(options.statistics->getTickerCount(COMPACT_READ_BYTES), 0);
|
||||
ASSERT_EQ(options.statistics->getTickerCount(BLOB_DB_BLOB_FILE_BYTES_READ),
|
||||
0);
|
||||
|
||||
ColumnFamilyMetaData after;
|
||||
db_->GetColumnFamilyMetaData(db_->DefaultColumnFamily(), &after);
|
||||
std::set<std::string> input_files;
|
||||
for (const LevelMetaData& before_level : before.levels) {
|
||||
for (const SstFileMetaData& input : before_level.files) {
|
||||
input_files.insert(input.name);
|
||||
}
|
||||
}
|
||||
for (const LevelMetaData& after_level : after.levels) {
|
||||
for (const SstFileMetaData& output : after_level.files) {
|
||||
ASSERT_EQ(input_files.count(output.name), 0);
|
||||
}
|
||||
}
|
||||
ASSERT_EQ(GetBlobFileNumbers(), healthy_blob_files);
|
||||
ASSERT_EQ(Get("a"), "va");
|
||||
ASSERT_EQ(Get("c"), "vc");
|
||||
std::string value;
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "b", &value).code(), Status::kNotFound);
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "d", &value).code(), Status::kNotFound);
|
||||
|
||||
Reopen(options);
|
||||
ASSERT_EQ(Get("a"), "va");
|
||||
ASSERT_EQ(Get("c"), "vc");
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "b", &value).code(), Status::kNotFound);
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "d", &value).code(), Status::kNotFound);
|
||||
}
|
||||
|
||||
TEST_F(DBBlobBasicTest, MissingBlobRepairIsScopedToCompactRange) {
|
||||
Options options = MissingBlobRepairOptions();
|
||||
options.paranoid_checks = false;
|
||||
uint64_t missing_blob_file = 0;
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
RecoverMissingNonOldestBlob(options, false, &missing_blob_file));
|
||||
ASSERT_OK(Put("b", "replacement"));
|
||||
ASSERT_OK(Flush());
|
||||
|
||||
const Status normal_compaction =
|
||||
db_->CompactRange(CompactRangeOptions(), nullptr, nullptr);
|
||||
ASSERT_EQ(normal_compaction.code(), Status::kCorruption);
|
||||
ASSERT_NE(normal_compaction.ToString().find("unknown blob file"),
|
||||
std::string::npos);
|
||||
|
||||
CompactRangeOptions repair;
|
||||
repair.skip_missing_blob_files = true;
|
||||
ASSERT_OK(db_->CompactRange(repair, nullptr, nullptr));
|
||||
ASSERT_EQ(Get("b"), "replacement");
|
||||
ASSERT_EQ(Get("a"), "va");
|
||||
std::string value;
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "d", &value).code(), Status::kNotFound);
|
||||
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
|
||||
Reopen(options);
|
||||
ASSERT_EQ(Get("b"), "replacement");
|
||||
|
||||
const uint64_t later_missing_blob = GetBlobFileNumbers().back();
|
||||
Close();
|
||||
ASSERT_OK(env_->DeleteFile(BlobFileName(dbname_, later_missing_blob)));
|
||||
Reopen(options);
|
||||
const Status later_corruption = db_->Get(ReadOptions(), "b", &value);
|
||||
ASSERT_FALSE(later_corruption.ok());
|
||||
ASSERT_TRUE(later_corruption.IsCorruption() || later_corruption.IsIOError() ||
|
||||
later_corruption.IsNotFound())
|
||||
<< later_corruption.ToString();
|
||||
}
|
||||
|
||||
TEST_F(DBBlobBasicTest, RepairMissingBlobsAcrossSubcompactions) {
|
||||
Options options = MissingBlobRepairOptions();
|
||||
options.statistics = CreateDBStatistics();
|
||||
options.compression = kNoCompression;
|
||||
options.target_file_size_base = 1024 * 1024;
|
||||
BlockBasedTableOptions table_options;
|
||||
table_options.block_size = 256;
|
||||
options.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
||||
DestroyAndReopen(options);
|
||||
constexpr int kNumKeys = 512;
|
||||
for (int key = 0; key < kNumKeys; key += 2) {
|
||||
ASSERT_OK(Put(Key(key), "healthy"));
|
||||
}
|
||||
ASSERT_OK(Flush());
|
||||
const uint64_t healthy_blob_file = GetBlobFileNumbers().back();
|
||||
for (int key = 1; key < kNumKeys; key += 2) {
|
||||
ASSERT_OK(Put(Key(key), "lost"));
|
||||
}
|
||||
ASSERT_OK(Flush());
|
||||
const uint64_t missing_blob_file = GetBlobFileNumbers().back();
|
||||
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
|
||||
ASSERT_EQ(TotalTableFiles(), 1);
|
||||
Close();
|
||||
ASSERT_OK(env_->DeleteFile(BlobFileName(dbname_, missing_blob_file)));
|
||||
Options recovery_options = options;
|
||||
recovery_options.best_efforts_recovery = true;
|
||||
Reopen(recovery_options);
|
||||
ASSERT_EQ(GetBlobFileNumbers(), std::vector<uint64_t>{healthy_blob_file});
|
||||
ASSERT_NO_FATAL_FAILURE(AssertBlobReference(Key(1), missing_blob_file));
|
||||
ASSERT_OK(db_->SetOptions({{"target_file_size_base", "1024"}}));
|
||||
|
||||
CompactRangeOptions repair;
|
||||
repair.skip_missing_blob_files = true;
|
||||
repair.max_subcompactions = 4;
|
||||
ASSERT_OK(options.statistics->Reset());
|
||||
ASSERT_OK(db_->CompactRange(repair, nullptr, nullptr));
|
||||
HistogramData subcompactions;
|
||||
options.statistics->histogramData(NUM_SUBCOMPACTIONS_SCHEDULED,
|
||||
&subcompactions);
|
||||
ASSERT_GT(subcompactions.max, 1);
|
||||
ASSERT_EQ(options.statistics->getTickerCount(BLOB_DB_BLOB_FILE_BYTES_READ),
|
||||
0);
|
||||
std::string value;
|
||||
for (int key = 0; key < kNumKeys; ++key) {
|
||||
if (key % 2 == 0) {
|
||||
ASSERT_OK(db_->Get(ReadOptions(), Key(key), &value));
|
||||
ASSERT_EQ(value, "healthy");
|
||||
} else {
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), Key(key), &value).code(),
|
||||
Status::kNotFound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DBBlobBasicTest, RepairPropagatesKnownBlobFileIoFailureDuringGc) {
|
||||
Options options = MissingBlobRepairOptions();
|
||||
DestroyAndReopen(options);
|
||||
ASSERT_OK(Put("key", "value"));
|
||||
ASSERT_OK(Flush());
|
||||
const std::vector<uint64_t> blob_files = GetBlobFileNumbers();
|
||||
ASSERT_EQ(blob_files.size(), 1);
|
||||
Close();
|
||||
ASSERT_OK(env_->DeleteFile(BlobFileName(dbname_, blob_files.front())));
|
||||
Reopen(options);
|
||||
ASSERT_EQ(GetBlobFileNumbers(), blob_files);
|
||||
ASSERT_NO_FATAL_FAILURE(AssertBlobReference("key", blob_files.front()));
|
||||
|
||||
std::atomic<size_t> blob_file_opens{0};
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"BlobFileReader::OpenFile:NewRandomAccessFile",
|
||||
[&blob_file_opens](void*) { ++blob_file_opens; });
|
||||
Defer clear_sync_points([]() {
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
CompactRangeOptions repair;
|
||||
repair.skip_missing_blob_files = true;
|
||||
repair.blob_garbage_collection_policy = BlobGarbageCollectionPolicy::kForce;
|
||||
repair.blob_garbage_collection_age_cutoff = 1.0;
|
||||
const Status status = db_->CompactRange(repair, nullptr, nullptr);
|
||||
ASSERT_FALSE(status.ok());
|
||||
ASSERT_TRUE(status.IsIOError() || status.IsCorruption() ||
|
||||
status.IsNotFound())
|
||||
<< status.ToString();
|
||||
ASSERT_GT(blob_file_opens.load(), 0);
|
||||
ASSERT_EQ(GetBlobFileNumbers(), blob_files);
|
||||
ASSERT_NO_FATAL_FAILURE(AssertBlobReference("key", blob_files.front()));
|
||||
}
|
||||
|
||||
TEST_F(DBBlobBasicTest, RepairMissingBlobPreservesSnapshotDeletionSemantics) {
|
||||
for (const bool use_merge : {false, true}) {
|
||||
SCOPED_TRACE("use_merge=" + std::to_string(use_merge));
|
||||
Options options = MissingBlobRepairOptions();
|
||||
if (use_merge) {
|
||||
options.merge_operator = MergeOperators::CreateStringAppendOperator();
|
||||
}
|
||||
uint64_t missing_blob_file = 0;
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
RecoverMissingNonOldestBlob(options, true, &missing_blob_file));
|
||||
{
|
||||
const Snapshot* snapshot = db_->GetSnapshot();
|
||||
Defer release_snapshot(
|
||||
[this, snapshot]() { db_->ReleaseSnapshot(snapshot); });
|
||||
if (use_merge) {
|
||||
ASSERT_OK(Merge("b", "replacement"));
|
||||
} else {
|
||||
ASSERT_OK(Put("b", "replacement"));
|
||||
}
|
||||
ASSERT_OK(Flush());
|
||||
|
||||
CompactRangeOptions repair;
|
||||
repair.skip_missing_blob_files = true;
|
||||
ASSERT_OK(db_->CompactRange(repair, nullptr, nullptr));
|
||||
ASSERT_EQ(Get("b"), "replacement");
|
||||
ReadOptions read;
|
||||
read.snapshot = snapshot;
|
||||
std::string value;
|
||||
ASSERT_EQ(db_->Get(read, "b", &value).code(), Status::kNotFound);
|
||||
ASSERT_OK(db_->Get(read, "a", &value));
|
||||
ASSERT_EQ(value, "va");
|
||||
}
|
||||
Reopen(options);
|
||||
ASSERT_EQ(Get("b"), "replacement");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DBBlobBasicTest, RepairMissingBlobPairedWithSingleDelete) {
|
||||
Options options = MissingBlobRepairOptions();
|
||||
uint64_t missing_blob_file = 0;
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
RecoverMissingNonOldestBlob(options, false, &missing_blob_file));
|
||||
{
|
||||
const Snapshot* snapshot = db_->GetSnapshot();
|
||||
Defer release_snapshot(
|
||||
[this, snapshot]() { db_->ReleaseSnapshot(snapshot); });
|
||||
ASSERT_OK(SingleDelete("b"));
|
||||
ASSERT_OK(Flush());
|
||||
|
||||
CompactRangeOptions repair;
|
||||
repair.skip_missing_blob_files = true;
|
||||
ASSERT_OK(db_->CompactRange(repair, nullptr, nullptr));
|
||||
std::string value;
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "b", &value).code(), Status::kNotFound);
|
||||
ReadOptions read;
|
||||
read.snapshot = snapshot;
|
||||
ASSERT_EQ(db_->Get(read, "b", &value).code(), Status::kNotFound);
|
||||
ASSERT_OK(db_->Get(read, "a", &value));
|
||||
ASSERT_EQ(value, "va");
|
||||
}
|
||||
|
||||
CompactRangeOptions normal;
|
||||
normal.bottommost_level_compaction = BottommostLevelCompaction::kForce;
|
||||
ASSERT_OK(db_->CompactRange(normal, nullptr, nullptr));
|
||||
Reopen(options);
|
||||
std::string value;
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "b", &value).code(), Status::kNotFound);
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "d", &value).code(), Status::kNotFound);
|
||||
ASSERT_EQ(Get("a"), "va");
|
||||
ASSERT_EQ(Get("c"), "vc");
|
||||
}
|
||||
|
||||
TEST_F(DBBlobBasicTest, RepairMissingBlobWithNoLiveBlobMetadata) {
|
||||
Options options = MissingBlobRepairOptions();
|
||||
uint64_t missing_blob_file = 0;
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
RecoverMissingNonOldestBlob(options, false, &missing_blob_file));
|
||||
ASSERT_OK(Delete("a"));
|
||||
ASSERT_OK(Delete("c"));
|
||||
ASSERT_OK(Flush());
|
||||
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
|
||||
ASSERT_TRUE(GetBlobFileNumbers().empty());
|
||||
ASSERT_NO_FATAL_FAILURE(AssertBlobReference("b", missing_blob_file));
|
||||
ASSERT_NO_FATAL_FAILURE(AssertBlobReference("d", missing_blob_file));
|
||||
std::string value;
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "b", &value).code(), Status::kCorruption);
|
||||
|
||||
CompactRangeOptions repair;
|
||||
repair.skip_missing_blob_files = true;
|
||||
ASSERT_OK(db_->CompactRange(repair, nullptr, nullptr));
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "b", &value).code(), Status::kNotFound);
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "d", &value).code(), Status::kNotFound);
|
||||
Reopen(options);
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "b", &value).code(), Status::kNotFound);
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "d", &value).code(), Status::kNotFound);
|
||||
}
|
||||
|
||||
TEST_F(DBBlobBasicTest, RepairRetainsHealthyBlobsReferencedByUntouchedSsts) {
|
||||
Options options = MissingBlobRepairOptions();
|
||||
options.sst_partitioner_factory = NewSstPartitionerFixedPrefixFactory(1);
|
||||
DestroyAndReopen(options);
|
||||
ASSERT_OK(Put("a_anchor", "anchor"));
|
||||
ASSERT_OK(Put("z_anchor", "anchor"));
|
||||
ASSERT_OK(Flush());
|
||||
ASSERT_OK(Put("a_lost", "lost"));
|
||||
ASSERT_OK(Flush());
|
||||
const uint64_t missing_blob_file = GetBlobFileNumbers().back();
|
||||
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
|
||||
ASSERT_EQ(TotalTableFiles(), 2);
|
||||
Close();
|
||||
ASSERT_OK(env_->DeleteFile(BlobFileName(dbname_, missing_blob_file)));
|
||||
Options recovery_options = options;
|
||||
recovery_options.best_efforts_recovery = true;
|
||||
Reopen(recovery_options);
|
||||
|
||||
ASSERT_OK(Put("a_live", "healthy"));
|
||||
ASSERT_OK(Flush());
|
||||
const uint64_t healthy_blob_file = GetBlobFileNumbers().back();
|
||||
ASSERT_OK(Delete("a_anchor"));
|
||||
ASSERT_OK(Flush());
|
||||
const Slice a_begin("a");
|
||||
const Slice a_end("b");
|
||||
CompactRangeOptions rewrite;
|
||||
rewrite.bottommost_level_compaction = BottommostLevelCompaction::kForce;
|
||||
ASSERT_OK(db_->CompactRange(rewrite, &a_begin, &a_end));
|
||||
ASSERT_EQ(Get("a_live"), "healthy");
|
||||
|
||||
ASSERT_OK(Delete("z_anchor"));
|
||||
ASSERT_OK(Flush());
|
||||
const Slice z_begin("z");
|
||||
CompactRangeOptions repair;
|
||||
repair.skip_missing_blob_files = true;
|
||||
ASSERT_OK(db_->CompactRange(repair, &z_begin, nullptr));
|
||||
ASSERT_NO_FATAL_FAILURE(AssertBlobReference("a_lost", missing_blob_file));
|
||||
ASSERT_NO_FATAL_FAILURE(AssertBlobReference("a_live", healthy_blob_file));
|
||||
ASSERT_EQ(Get("a_live"), "healthy");
|
||||
const std::vector<uint64_t> retained_blob_files = GetBlobFileNumbers();
|
||||
ASSERT_NE(std::find(retained_blob_files.begin(), retained_blob_files.end(),
|
||||
healthy_blob_file),
|
||||
retained_blob_files.end());
|
||||
std::string value;
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "a_lost", &value).code(),
|
||||
Status::kCorruption);
|
||||
|
||||
ASSERT_OK(db_->CompactRange(repair, &a_begin, &a_end));
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "a_lost", &value).code(),
|
||||
Status::kNotFound);
|
||||
ASSERT_EQ(Get("a_live"), "healthy");
|
||||
Reopen(options);
|
||||
ASSERT_EQ(db_->Get(ReadOptions(), "a_lost", &value).code(),
|
||||
Status::kNotFound);
|
||||
ASSERT_EQ(Get("a_live"), "healthy");
|
||||
}
|
||||
|
||||
TEST_F(DBBlobBasicTest, GetMergeBlobWithPut) {
|
||||
Options options = GetDefaultOptions();
|
||||
options.merge_operator = MergeOperators::CreateStringAppendOperator();
|
||||
@@ -2125,13 +1729,11 @@ TEST_F(DBBlobBasicTest, PropertiesMultiVersion) {
|
||||
|
||||
class DBBlobBasicIOErrorTest : public DBBlobBasicTest,
|
||||
public testing::WithParamInterface<std::string> {
|
||||
public:
|
||||
~DBBlobBasicIOErrorTest() override { Close(); }
|
||||
|
||||
protected:
|
||||
DBBlobBasicIOErrorTest() : sync_point_(GetParam()) {
|
||||
fault_injection_env_.reset(new FaultInjectionTestEnv(env_));
|
||||
}
|
||||
~DBBlobBasicIOErrorTest() { Close(); }
|
||||
|
||||
std::unique_ptr<FaultInjectionTestEnv> fault_injection_env_;
|
||||
std::string sync_point_;
|
||||
@@ -2711,179 +2313,6 @@ class DBBlobWithTimestampTest : public DBBasicTestWithTimestampBase {
|
||||
: DBBasicTestWithTimestampBase("db_blob_with_timestamp_test") {}
|
||||
};
|
||||
|
||||
TEST_F(DBBlobWithTimestampTest, RepairPreservesTimestampHistoryAfterRecovery) {
|
||||
Options options = GetDefaultOptions();
|
||||
options.create_if_missing = true;
|
||||
options.enable_blob_files = true;
|
||||
options.min_blob_size = 0;
|
||||
options.enable_blob_garbage_collection = false;
|
||||
options.disable_auto_compactions = true;
|
||||
options.num_levels = 3;
|
||||
options.level_compaction_dynamic_level_bytes = false;
|
||||
TestComparator test_cmp(Timestamp(0, 0).size());
|
||||
options.comparator = &test_cmp;
|
||||
DestroyAndReopen(options);
|
||||
Defer close_db([this]() { Close(); });
|
||||
const std::string old_timestamp = Timestamp(1, 0);
|
||||
const std::string middle_timestamp = Timestamp(2, 0);
|
||||
const std::string lost_timestamp = Timestamp(3, 0);
|
||||
const std::string latest_timestamp = Timestamp(4, 0);
|
||||
const Slice old_ts(old_timestamp);
|
||||
const Slice middle_ts(middle_timestamp);
|
||||
const Slice lost_ts(lost_timestamp);
|
||||
const Slice latest_ts(latest_timestamp);
|
||||
ReadOptions healthy_read;
|
||||
healthy_read.verify_checksums = true;
|
||||
healthy_read.timestamp = &latest_ts;
|
||||
std::string healthy_value;
|
||||
ASSERT_OK(db_->Put(WriteOptions(), "a", old_ts, "healthy"));
|
||||
ASSERT_OK(db_->Put(WriteOptions(), "b", old_ts, "older"));
|
||||
const SequenceNumber older_sequence = db_->GetLatestSequenceNumber();
|
||||
ASSERT_OK(Flush());
|
||||
const uint64_t healthy_blob_file = GetBlobFileNumbers().back();
|
||||
ASSERT_OK(db_->Get(healthy_read, "a", &healthy_value));
|
||||
ASSERT_EQ(healthy_value, "healthy");
|
||||
ASSERT_OK(db_->Put(WriteOptions(), "b", lost_ts, "lost"));
|
||||
const SequenceNumber lost_sequence = db_->GetLatestSequenceNumber();
|
||||
ASSERT_OK(db_->Put(WriteOptions(), "d", lost_ts, "lost"));
|
||||
const SequenceNumber other_lost_sequence = db_->GetLatestSequenceNumber();
|
||||
ASSERT_OK(Flush());
|
||||
const uint64_t missing_blob_file = GetBlobFileNumbers().back();
|
||||
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
|
||||
ASSERT_EQ(TotalTableFiles(), 1);
|
||||
Close();
|
||||
ASSERT_OK(env_->DeleteFile(BlobFileName(dbname_, missing_blob_file)));
|
||||
Options recovery_options = options;
|
||||
recovery_options.best_efforts_recovery = true;
|
||||
Reopen(recovery_options);
|
||||
ASSERT_EQ(TotalTableFiles(), 1);
|
||||
ASSERT_EQ(GetBlobFileNumbers(), std::vector<uint64_t>{healthy_blob_file});
|
||||
ASSERT_OK(db_->Get(healthy_read, "a", &healthy_value));
|
||||
ASSERT_EQ(healthy_value, "healthy");
|
||||
{
|
||||
ReadOptions read;
|
||||
read.timestamp = &lost_ts;
|
||||
PinnableSlice value;
|
||||
bool is_blob_index = false;
|
||||
DBImpl::GetImplOptions get_options;
|
||||
get_options.column_family = db_->DefaultColumnFamily();
|
||||
get_options.value = &value;
|
||||
get_options.is_blob_index = &is_blob_index;
|
||||
ASSERT_OK(dbfull()->GetImpl(read, "b", get_options));
|
||||
ASSERT_TRUE(is_blob_index);
|
||||
BlobIndex blob_index;
|
||||
ASSERT_OK(blob_index.DecodeFrom(value));
|
||||
ASSERT_EQ(blob_index.file_number(), missing_blob_file);
|
||||
}
|
||||
|
||||
CompactRangeOptions repair;
|
||||
repair.skip_missing_blob_files = true;
|
||||
repair.full_history_ts_low = &old_ts;
|
||||
ASSERT_OK(db_->CompactRange(repair, nullptr, nullptr));
|
||||
for (int reopen = 0; reopen < 2; ++reopen) {
|
||||
SCOPED_TRACE(reopen);
|
||||
if (reopen != 0) {
|
||||
Reopen(options);
|
||||
}
|
||||
std::string full_history_ts_low;
|
||||
ASSERT_OK(db_->GetFullHistoryTsLow(db_->DefaultColumnFamily(),
|
||||
&full_history_ts_low));
|
||||
ASSERT_EQ(full_history_ts_low, old_timestamp);
|
||||
ReadOptions read;
|
||||
read.verify_checksums = true;
|
||||
std::string value;
|
||||
read.timestamp = &old_ts;
|
||||
ASSERT_OK(db_->Get(read, "b", &value));
|
||||
ASSERT_EQ(value, "older");
|
||||
read.timestamp = &middle_ts;
|
||||
ASSERT_OK(db_->Get(read, "b", &value));
|
||||
ASSERT_EQ(value, "older");
|
||||
read.timestamp = &lost_ts;
|
||||
ASSERT_EQ(db_->Get(read, "b", &value).code(), Status::kNotFound);
|
||||
ASSERT_EQ(db_->Get(read, "d", &value).code(), Status::kNotFound);
|
||||
read.timestamp = &latest_ts;
|
||||
ASSERT_EQ(db_->Get(read, "b", &value).code(), Status::kNotFound);
|
||||
ASSERT_OK(db_->Get(read, "a", &value));
|
||||
ASSERT_EQ(value, "healthy");
|
||||
|
||||
read.iter_start_ts = &old_ts;
|
||||
std::unique_ptr<Iterator> history(db_->NewIterator(read));
|
||||
history->Seek("b");
|
||||
ASSERT_NO_FATAL_FAILURE(CheckIterEntry(history.get(), "b", lost_sequence,
|
||||
kTypeDeletionWithTimestamp, Slice(),
|
||||
lost_ts));
|
||||
history->Next();
|
||||
ASSERT_NO_FATAL_FAILURE(CheckIterEntry(history.get(), "b", older_sequence,
|
||||
kTypeBlobIndex, "older", old_ts));
|
||||
ASSERT_EQ(history->value(), "older");
|
||||
history->Next();
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
CheckIterEntry(history.get(), "d", other_lost_sequence,
|
||||
kTypeDeletionWithTimestamp, Slice(), lost_ts));
|
||||
history->Next();
|
||||
ASSERT_FALSE(history->Valid());
|
||||
ASSERT_OK(history->status());
|
||||
}
|
||||
|
||||
CompactRangeOptions normal;
|
||||
normal.bottommost_level_compaction = BottommostLevelCompaction::kForce;
|
||||
normal.full_history_ts_low = &latest_ts;
|
||||
ASSERT_OK(db_->Get(healthy_read, "a", &healthy_value));
|
||||
ASSERT_EQ(healthy_value, "healthy");
|
||||
ASSERT_OK(db_->CompactRange(normal, nullptr, nullptr));
|
||||
ASSERT_OK(db_->Get(healthy_read, "a", &healthy_value));
|
||||
ASSERT_EQ(healthy_value, "healthy");
|
||||
Reopen(options);
|
||||
ReadOptions read;
|
||||
read.verify_checksums = true;
|
||||
read.timestamp = &latest_ts;
|
||||
std::string value;
|
||||
ASSERT_EQ(db_->Get(read, "b", &value).code(), Status::kNotFound);
|
||||
ASSERT_EQ(db_->Get(read, "d", &value).code(), Status::kNotFound);
|
||||
ASSERT_OK(db_->Get(read, "a", &value));
|
||||
ASSERT_EQ(value, "healthy");
|
||||
read.timestamp = &old_ts;
|
||||
ASSERT_EQ(db_->Get(read, "b", &value).code(), Status::kInvalidArgument);
|
||||
}
|
||||
|
||||
TEST_F(DBBlobWithTimestampTest, HistoryCompactionPreservesHealthyBlobKey) {
|
||||
Options options = GetDefaultOptions();
|
||||
options.create_if_missing = true;
|
||||
options.enable_blob_files = true;
|
||||
options.min_blob_size = 0;
|
||||
options.enable_blob_garbage_collection = false;
|
||||
options.disable_auto_compactions = true;
|
||||
options.num_levels = 3;
|
||||
options.level_compaction_dynamic_level_bytes = false;
|
||||
TestComparator test_cmp(Timestamp(0, 0).size());
|
||||
options.comparator = &test_cmp;
|
||||
DestroyAndReopen(options);
|
||||
Defer close_db([this]() { Close(); });
|
||||
const std::string old_timestamp = Timestamp(1, 0);
|
||||
const std::string history_floor = Timestamp(4, 0);
|
||||
const Slice old_ts(old_timestamp);
|
||||
const Slice history_floor_ts(history_floor);
|
||||
ASSERT_OK(db_->Put(WriteOptions(), "a", old_ts, "healthy"));
|
||||
ASSERT_OK(Flush());
|
||||
ASSERT_EQ(GetBlobFileNumbers().size(), 1);
|
||||
|
||||
ReadOptions read;
|
||||
read.verify_checksums = true;
|
||||
read.timestamp = &history_floor_ts;
|
||||
std::string value;
|
||||
ASSERT_OK(db_->Get(read, "a", &value));
|
||||
ASSERT_EQ(value, "healthy");
|
||||
CompactRangeOptions normal;
|
||||
normal.bottommost_level_compaction = BottommostLevelCompaction::kForce;
|
||||
normal.full_history_ts_low = &history_floor_ts;
|
||||
ASSERT_OK(db_->CompactRange(normal, nullptr, nullptr));
|
||||
ASSERT_OK(db_->Get(read, "a", &value));
|
||||
ASSERT_EQ(value, "healthy");
|
||||
Reopen(options);
|
||||
ASSERT_OK(db_->Get(read, "a", &value));
|
||||
ASSERT_EQ(value, "healthy");
|
||||
}
|
||||
|
||||
TEST_F(DBBlobWithTimestampTest, GetBlob) {
|
||||
Options options = GetDefaultOptions();
|
||||
options.create_if_missing = true;
|
||||
|
||||
@@ -10,15 +10,12 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <limits>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -38,7 +35,6 @@
|
||||
#include "port/stack_trace.h"
|
||||
#include "rocksdb/convenience.h"
|
||||
#include "rocksdb/file_system.h"
|
||||
#include "rocksdb/sst_file_manager.h"
|
||||
#include "rocksdb/trace_reader_writer.h"
|
||||
#include "rocksdb/trace_record.h"
|
||||
#include "rocksdb/utilities/replayer.h"
|
||||
@@ -1464,9 +1460,7 @@ TEST_F(DBBlobDirectWriteTest,
|
||||
std::vector<BlobFileGarbage> garbages1;
|
||||
// Simulate a flush retry: prepare once, skip commit, then prepare the same
|
||||
// generation again and verify it reuses the already sealed blob file.
|
||||
const std::vector<uint64_t> memtable_ids = {
|
||||
cfh->cfd()->imm()->GetEarliestMemTableID()};
|
||||
ASSERT_OK(mgr->PrepareFlushAdditions(WriteOptions(), memtable_ids,
|
||||
ASSERT_OK(mgr->PrepareFlushAdditions(WriteOptions(), /*num_generations=*/1,
|
||||
&additions1, &garbages1));
|
||||
ASSERT_EQ(additions1.size(), 1U);
|
||||
ASSERT_TRUE(garbages1.empty());
|
||||
@@ -1475,7 +1469,7 @@ TEST_F(DBBlobDirectWriteTest,
|
||||
|
||||
std::vector<BlobFileAddition> additions2;
|
||||
std::vector<BlobFileGarbage> garbages2;
|
||||
ASSERT_OK(mgr->PrepareFlushAdditions(WriteOptions(), memtable_ids,
|
||||
ASSERT_OK(mgr->PrepareFlushAdditions(WriteOptions(), /*num_generations=*/1,
|
||||
&additions2, &garbages2));
|
||||
ASSERT_EQ(additions2.size(), 1U);
|
||||
ASSERT_TRUE(garbages2.empty());
|
||||
@@ -1881,528 +1875,6 @@ TEST_F(DBBlobDirectWriteTest,
|
||||
AssertOrderedTraceStoresLogicalPut(options, /*expect_blob_files=*/false);
|
||||
}
|
||||
|
||||
TEST_F(DBBlobDirectWriteTest, OverlappingFlushesPublishTheirOwnBlobFiles) {
|
||||
for (bool atomic_flush : {false, true}) {
|
||||
SCOPED_TRACE("atomic_flush=" + std::to_string(atomic_flush));
|
||||
Options options = GetDirectWriteOptions();
|
||||
options.atomic_flush = atomic_flush;
|
||||
options.max_background_jobs = 8;
|
||||
options.max_write_buffer_number = 4;
|
||||
options.disable_auto_compactions = true;
|
||||
DestroyAndReopen(options);
|
||||
const std::string value(1024, 'v');
|
||||
|
||||
// The flush of the memtable holding "key1" waits while it writes its
|
||||
// table file, until a second flush, of the memtable holding "key2", has
|
||||
// finished its own table file.
|
||||
std::atomic<int> table_writes{0};
|
||||
std::atomic<bool> released{false};
|
||||
std::promise<void> first_flush_writing;
|
||||
std::promise<void> release_first_flush;
|
||||
std::shared_future<void> release_first_flush_future =
|
||||
release_first_flush.get_future().share();
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"FlushJob::WriteLevel0Table:num_memtables", [&](void*) {
|
||||
if (table_writes.fetch_add(1) == 0) {
|
||||
first_flush_writing.set_value();
|
||||
release_first_flush_future.wait();
|
||||
}
|
||||
});
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
atomic_flush ? "DBImpl::AtomicFlushMemTablesToOutputFiles:WaitCV"
|
||||
: "DBImpl::FlushMemTableToOutputFile:Finish",
|
||||
[&](void*) {
|
||||
if (!released.exchange(true)) {
|
||||
release_first_flush.set_value();
|
||||
}
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
|
||||
FlushOptions no_wait;
|
||||
no_wait.wait = false;
|
||||
no_wait.allow_write_stall = true;
|
||||
ASSERT_OK(Put("key1", value));
|
||||
ASSERT_OK(db_->Flush(no_wait));
|
||||
first_flush_writing.get_future().wait();
|
||||
ASSERT_OK(Put("key2", value));
|
||||
ASSERT_OK(db_->Flush(no_wait));
|
||||
|
||||
ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
ASSERT_OK(dbfull()->TEST_GetBGError());
|
||||
ASSERT_EQ(2, NumTableFilesAtLevel(0));
|
||||
|
||||
Reopen(options);
|
||||
ASSERT_EQ(value, Get("key1"));
|
||||
ASSERT_EQ(value, Get("key2"));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DBBlobDirectWriteTest, RetryAfterOlderOverlappingFlushFails) {
|
||||
Options options = GetDirectWriteOptions();
|
||||
options.max_background_jobs = 8;
|
||||
options.max_write_buffer_number = 4;
|
||||
options.disable_auto_compactions = true;
|
||||
options.max_bgerror_resume_count = 0;
|
||||
DestroyAndReopen(options);
|
||||
const std::string value(1024, 'v');
|
||||
|
||||
// The flush of the memtable holding "key2" finishes while the older flush,
|
||||
// of the memtable holding "key1", is still writing its table file. The
|
||||
// newer flush's results wait to be installed after the older one's, but the
|
||||
// older flush fails, which rolls the newer memtable back too.
|
||||
std::atomic<int> table_writes{0};
|
||||
std::atomic<bool> released{false};
|
||||
std::atomic<bool> failed{false};
|
||||
std::promise<void> first_flush_writing;
|
||||
std::promise<void> release_first_flush;
|
||||
std::shared_future<void> release_first_flush_future =
|
||||
release_first_flush.get_future().share();
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"FlushJob::WriteLevel0Table:num_memtables", [&](void*) {
|
||||
if (table_writes.fetch_add(1) == 0) {
|
||||
first_flush_writing.set_value();
|
||||
release_first_flush_future.wait();
|
||||
}
|
||||
});
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"DBImpl::FlushMemTableToOutputFile:Finish", [&](void*) {
|
||||
if (!released.exchange(true)) {
|
||||
release_first_flush.set_value();
|
||||
}
|
||||
});
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"FlushJob::WriteLevel0Table:s", [&](void* arg) {
|
||||
if (released.load() && !failed.exchange(true)) {
|
||||
IOStatus injected = IOStatus::IOError("injected");
|
||||
injected.SetRetryable(true);
|
||||
*static_cast<Status*>(arg) = injected;
|
||||
}
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
|
||||
FlushOptions no_wait;
|
||||
no_wait.wait = false;
|
||||
no_wait.allow_write_stall = true;
|
||||
ASSERT_OK(Put("key1", value));
|
||||
ASSERT_OK(db_->Flush(no_wait));
|
||||
first_flush_writing.get_future().wait();
|
||||
ASSERT_OK(Put("key2", value));
|
||||
ASSERT_OK(db_->Flush(no_wait));
|
||||
|
||||
ASSERT_NOK(dbfull()->TEST_WaitForFlushMemTable());
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
ASSERT_TRUE(failed.load());
|
||||
|
||||
// Retrying the flush must still find the blob files of both memtables.
|
||||
ASSERT_OK(dbfull()->Resume());
|
||||
ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
|
||||
ASSERT_OK(dbfull()->TEST_GetBGError());
|
||||
|
||||
Reopen(options);
|
||||
ASSERT_EQ(value, Get("key1"));
|
||||
ASSERT_EQ(value, Get("key2"));
|
||||
}
|
||||
|
||||
class BlobFileCreationStatusListener : public EventListener {
|
||||
public:
|
||||
void OnBlobFileCreated(const BlobFileCreationInfo& info) override {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
statuses_.push_back(info.status.ToString());
|
||||
}
|
||||
|
||||
void OnErrorRecoveryBegin(BackgroundErrorReason /*reason*/, Status bg_error,
|
||||
bool* /*auto_recovery*/) override {
|
||||
bg_error.PermitUncheckedError();
|
||||
}
|
||||
|
||||
std::vector<std::string> GetStatuses() {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
return statuses_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::vector<std::string> statuses_;
|
||||
};
|
||||
|
||||
TEST_F(DBBlobDirectWriteTest, SpaceLimitWhileSealingKeepsBlobFile) {
|
||||
Options options = GetDirectWriteOptions();
|
||||
std::shared_ptr<SstFileManager> sst_file_manager(NewSstFileManager(env_));
|
||||
options.sst_file_manager = sst_file_manager;
|
||||
auto listener = std::make_shared<BlobFileCreationStatusListener>();
|
||||
options.listeners.emplace_back(listener);
|
||||
DestroyAndReopen(options);
|
||||
const std::string value(1024, 'v');
|
||||
ASSERT_OK(Put("key", value));
|
||||
|
||||
// The flush seals the blob file holding "key" and reaches the space limit.
|
||||
// It still commits the file, and then writes stop. As for an SST file,
|
||||
// Flush() returns the background error set after the commit.
|
||||
sst_file_manager->SetMaxAllowedSpaceUsage(1);
|
||||
ASSERT_EQ(Status::kSpaceLimit, Flush().subcode());
|
||||
ASSERT_EQ(Status::kSpaceLimit, dbfull()->TEST_GetBGError().subcode());
|
||||
ASSERT_NOK(Put("key2", "x"));
|
||||
|
||||
ColumnFamilyMetaData cf_meta;
|
||||
db_->GetColumnFamilyMetaData(&cf_meta);
|
||||
ASSERT_EQ(1U, cf_meta.blob_files.size());
|
||||
ASSERT_EQ(value, Get("key"));
|
||||
ASSERT_EQ(std::vector<std::string>{"OK"}, listener->GetStatuses());
|
||||
}
|
||||
|
||||
TEST_F(DBBlobDirectWriteTest,
|
||||
SpaceLimitWhileSealingDoesNotBlockMemtableSwitch) {
|
||||
Options options = GetDirectWriteOptions();
|
||||
options.max_write_buffer_number = 4;
|
||||
std::shared_ptr<SstFileManager> sst_file_manager(NewSstFileManager(env_));
|
||||
options.sst_file_manager = sst_file_manager;
|
||||
DestroyAndReopen(options);
|
||||
const std::string value(1024, 'v');
|
||||
ASSERT_OK(Put("key1", value));
|
||||
|
||||
// While the flush reports the space limit for the blob file holding "key1",
|
||||
// a concurrent memtable switch holds the DB mutex and rotates the blob
|
||||
// generation.
|
||||
port::Thread switch_thread;
|
||||
std::atomic<bool> switch_started{false};
|
||||
std::promise<void> switch_holds_db_mutex;
|
||||
SyncPoint::GetInstance()->LoadDependency(
|
||||
{{"DBBlobDirectWriteTest::SpaceLimitWhileSealing:SecondPut",
|
||||
"DBImpl::BackgroundCallFlush:start"}});
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"DBImpl::SwitchMemtable:BeforeRotateBlobGeneration", [&](void*) {
|
||||
if (switch_started.exchange(false)) {
|
||||
switch_holds_db_mutex.set_value();
|
||||
}
|
||||
});
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"BlobFileCompletionCallback::CallBack::MaxAllowedSpaceReached",
|
||||
[&](void*) {
|
||||
if (switch_thread.joinable()) {
|
||||
return;
|
||||
}
|
||||
switch_started = true;
|
||||
switch_thread = port::Thread([&]() {
|
||||
FlushOptions no_wait;
|
||||
no_wait.wait = false;
|
||||
no_wait.allow_write_stall = true;
|
||||
db_->Flush(no_wait).PermitUncheckedError();
|
||||
});
|
||||
switch_holds_db_mutex.get_future().wait();
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
|
||||
sst_file_manager->SetMaxAllowedSpaceUsage(1);
|
||||
FlushOptions no_wait;
|
||||
no_wait.wait = false;
|
||||
ASSERT_OK(db_->Flush(no_wait));
|
||||
ASSERT_OK(Put("key2", value));
|
||||
TEST_SYNC_POINT("DBBlobDirectWriteTest::SpaceLimitWhileSealing:SecondPut");
|
||||
|
||||
dbfull()->TEST_WaitForBackgroundWork().PermitUncheckedError();
|
||||
ASSERT_TRUE(switch_thread.joinable());
|
||||
switch_thread.join();
|
||||
dbfull()->TEST_WaitForBackgroundWork().PermitUncheckedError();
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
|
||||
ASSERT_EQ(value, Get("key1"));
|
||||
ASSERT_EQ(value, Get("key2"));
|
||||
}
|
||||
|
||||
class IgnoreFlushNoWALErrorListener : public EventListener {
|
||||
public:
|
||||
void OnBackgroundError(BackgroundErrorReason reason,
|
||||
Status* bg_error) override {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
reasons_.push_back(reason);
|
||||
if (reason == BackgroundErrorReason::kFlushNoWAL) {
|
||||
*bg_error = Status::OK();
|
||||
}
|
||||
}
|
||||
|
||||
void OnErrorRecoveryBegin(BackgroundErrorReason /*reason*/, Status bg_error,
|
||||
bool* /*auto_recovery*/) override {
|
||||
bg_error.PermitUncheckedError();
|
||||
}
|
||||
|
||||
std::vector<BackgroundErrorReason> GetReasons() {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
return reasons_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::vector<BackgroundErrorReason> reasons_;
|
||||
};
|
||||
|
||||
TEST_F(DBBlobDirectWriteTest, SpaceLimitWhileSealingStopsWrites) {
|
||||
Options options = GetDirectWriteOptions();
|
||||
std::shared_ptr<SstFileManager> sst_file_manager(NewSstFileManager(env_));
|
||||
options.sst_file_manager = sst_file_manager;
|
||||
auto listener = std::make_shared<IgnoreFlushNoWALErrorListener>();
|
||||
options.listeners.emplace_back(listener);
|
||||
DestroyAndReopen(options);
|
||||
const std::string value(1024, 'v');
|
||||
ASSERT_OK(Put("key1", value));
|
||||
|
||||
// The space limit is reported for the blob file the flush seals, with the
|
||||
// reason kFlush, so a listener that ignores kFlushNoWAL errors still stops
|
||||
// writes.
|
||||
sst_file_manager->SetMaxAllowedSpaceUsage(1);
|
||||
FlushOptions no_wait;
|
||||
no_wait.wait = false;
|
||||
ASSERT_OK(db_->Flush(no_wait));
|
||||
dbfull()->TEST_WaitForBackgroundWork().PermitUncheckedError();
|
||||
const std::vector<BackgroundErrorReason> reasons = listener->GetReasons();
|
||||
ASSERT_GT(
|
||||
std::count(reasons.begin(), reasons.end(), BackgroundErrorReason::kFlush),
|
||||
0);
|
||||
ASSERT_NOK(Put("key2", value));
|
||||
}
|
||||
|
||||
TEST_F(DBBlobDirectWriteTest, SpaceLimitWhileWriteSealsBlobFile) {
|
||||
Options options = GetDirectWriteOptions();
|
||||
options.blob_file_size = 2048;
|
||||
std::shared_ptr<SstFileManager> sst_file_manager(NewSstFileManager(env_));
|
||||
options.sst_file_manager = sst_file_manager;
|
||||
auto listener = std::make_shared<BlobFileCreationStatusListener>();
|
||||
options.listeners.emplace_back(listener);
|
||||
DestroyAndReopen(options);
|
||||
const std::string value(1024, 'v');
|
||||
ASSERT_OK(Put("key1", value));
|
||||
|
||||
// "key2" does not fit in the blob file holding "key1", so the write seals
|
||||
// that file and reaches the space limit. The write still succeeds, and then
|
||||
// writes stop.
|
||||
sst_file_manager->SetMaxAllowedSpaceUsage(1);
|
||||
ASSERT_OK(Put("key2", value));
|
||||
ASSERT_EQ(Status::kSpaceLimit, dbfull()->TEST_GetBGError().subcode());
|
||||
ASSERT_NOK(Put("key3", "x"));
|
||||
|
||||
dbfull()->TEST_DeleteObsoleteFiles();
|
||||
ASSERT_EQ(2U, CountBlobFiles());
|
||||
ASSERT_EQ(value, Get("key1"));
|
||||
ASSERT_EQ(value, Get("key2"));
|
||||
ASSERT_EQ(std::vector<std::string>{"OK"}, listener->GetStatuses());
|
||||
}
|
||||
|
||||
class FailNthBlobFileOpenFileSystem : public FileSystemWrapper {
|
||||
public:
|
||||
FailNthBlobFileOpenFileSystem(const std::shared_ptr<FileSystem>& fs,
|
||||
int failing_open)
|
||||
: FileSystemWrapper(fs), failing_open_(failing_open) {}
|
||||
|
||||
static const char* kClassName() { return "FailNthBlobFileOpenFileSystem"; }
|
||||
const char* Name() const override { return kClassName(); }
|
||||
|
||||
IOStatus NewWritableFile(const std::string& fname,
|
||||
const FileOptions& file_opts,
|
||||
std::unique_ptr<FSWritableFile>* result,
|
||||
IODebugContext* dbg) override {
|
||||
if (IsBlobFilePath(fname) && ++blob_file_opens_ == failing_open_) {
|
||||
return IOStatus::IOError("Injected blob file open error");
|
||||
}
|
||||
return target()->NewWritableFile(fname, file_opts, result, dbg);
|
||||
}
|
||||
|
||||
private:
|
||||
const int failing_open_;
|
||||
std::atomic<int> blob_file_opens_{0};
|
||||
};
|
||||
|
||||
TEST_F(DBBlobDirectWriteTest, FailedBatchAfterSealCountsGarbageInSealedFile) {
|
||||
auto fs = std::make_shared<FailNthBlobFileOpenFileSystem>(
|
||||
env_->GetFileSystem(), /*failing_open=*/3);
|
||||
std::unique_ptr<Env> env(new CompositeEnvWrapper(env_, fs));
|
||||
Options options = GetDirectWriteOptions();
|
||||
options.env = env.get();
|
||||
options.blob_file_size = 2048;
|
||||
Defer close_db([this]() { Close(); });
|
||||
DestroyAndReopen(options);
|
||||
const std::string value(1024, 'v');
|
||||
|
||||
// An SST refers to the first blob file, so a later blob file that no SST
|
||||
// refers to is dropped only once all its blobs are garbage.
|
||||
ASSERT_OK(Put("x", value));
|
||||
ASSERT_OK(Flush());
|
||||
|
||||
// "b" does not fit in the blob file holding "a" from the same batch, so the
|
||||
// batch seals that file and then fails to open the next one. "a" is garbage
|
||||
// in the sealed file, so the flush drops that file.
|
||||
WriteBatch batch;
|
||||
ASSERT_OK(batch.Put("a", value));
|
||||
ASSERT_OK(batch.Put("b", value));
|
||||
ASSERT_TRUE(db_->Write(WriteOptions(), &batch).IsIOError());
|
||||
|
||||
ASSERT_OK(Put("c", value));
|
||||
ASSERT_OK(Flush());
|
||||
ColumnFamilyMetaData cf_meta;
|
||||
db_->GetColumnFamilyMetaData(&cf_meta);
|
||||
ASSERT_EQ(2U, cf_meta.blob_files.size());
|
||||
ASSERT_EQ("NOT_FOUND", Get("a"));
|
||||
ASSERT_EQ(value, Get("x"));
|
||||
ASSERT_EQ(value, Get("c"));
|
||||
}
|
||||
|
||||
class FailBlobFileSizeFileSystem : public FileSystemWrapper {
|
||||
public:
|
||||
explicit FailBlobFileSizeFileSystem(const std::shared_ptr<FileSystem>& fs)
|
||||
: FileSystemWrapper(fs) {}
|
||||
|
||||
static const char* kClassName() { return "FailBlobFileSizeFileSystem"; }
|
||||
const char* Name() const override { return kClassName(); }
|
||||
|
||||
IOStatus GetFileSize(const std::string& fname, const IOOptions& options,
|
||||
uint64_t* file_size, IODebugContext* dbg) override {
|
||||
if (IsBlobFilePath(fname)) {
|
||||
return IOStatus::IOError("Injected blob file size error");
|
||||
}
|
||||
return target()->GetFileSize(fname, options, file_size, dbg);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(DBBlobDirectWriteTest, SealedBlobFilesTrackedWhenSizeLookupFails) {
|
||||
Options options = GetDirectWriteOptions();
|
||||
options.blob_file_size = 2048;
|
||||
// Only the SstFileManager fails to look up blob file sizes.
|
||||
std::shared_ptr<SstFileManager> sst_file_manager(NewSstFileManager(
|
||||
env_,
|
||||
std::make_shared<FailBlobFileSizeFileSystem>(env_->GetFileSystem())));
|
||||
options.sst_file_manager = sst_file_manager;
|
||||
DestroyAndReopen(options);
|
||||
const std::string value(1024, 'v');
|
||||
|
||||
// "key2" does not fit in the blob file holding "key1", so the write seals
|
||||
// that file, and the flush seals the one holding "key2".
|
||||
ASSERT_OK(Put("key1", value));
|
||||
ASSERT_OK(Put("key2", value));
|
||||
ASSERT_OK(Flush());
|
||||
ASSERT_EQ(2U, CountBlobFiles());
|
||||
|
||||
std::unordered_map<std::string, uint64_t> blob_file_sizes;
|
||||
std::vector<std::string> files;
|
||||
ASSERT_OK(env_->GetChildren(dbname_, &files));
|
||||
for (const auto& file : files) {
|
||||
const std::string path = dbname_ + "/" + file;
|
||||
if (IsBlobFilePath(path)) {
|
||||
ASSERT_OK(env_->GetFileSize(path, &blob_file_sizes[path]));
|
||||
}
|
||||
}
|
||||
std::unordered_map<std::string, uint64_t> tracked_blob_file_sizes;
|
||||
for (const auto& [path, size] : sst_file_manager->GetTrackedFiles()) {
|
||||
if (IsBlobFilePath(path)) {
|
||||
tracked_blob_file_sizes[path] = size;
|
||||
}
|
||||
}
|
||||
ASSERT_EQ(blob_file_sizes, tracked_blob_file_sizes);
|
||||
|
||||
Reopen(options);
|
||||
ASSERT_EQ(value, Get("key1"));
|
||||
ASSERT_EQ(value, Get("key2"));
|
||||
}
|
||||
|
||||
class DisableAutoRecoveryListener : public EventListener {
|
||||
public:
|
||||
void OnErrorRecoveryBegin(BackgroundErrorReason /*reason*/, Status bg_error,
|
||||
bool* auto_recovery) override {
|
||||
bg_error.PermitUncheckedError();
|
||||
*auto_recovery = false;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(DBBlobDirectWriteTest, FailedBlobSealLeavesMemtableFlushable) {
|
||||
std::unique_ptr<FaultInjectionTestEnv> fault_env(
|
||||
new FaultInjectionTestEnv(env_));
|
||||
Options options = GetDirectWriteOptions();
|
||||
options.env = fault_env.get();
|
||||
options.listeners.emplace_back(
|
||||
std::make_shared<DisableAutoRecoveryListener>());
|
||||
for (bool atomic_flush : {false, true}) {
|
||||
SCOPED_TRACE("atomic_flush=" + std::to_string(atomic_flush));
|
||||
options.atomic_flush = atomic_flush;
|
||||
DestroyAndReopen(options);
|
||||
Defer close_db([this]() { Close(); });
|
||||
const std::string value(1024, 'v');
|
||||
ASSERT_OK(Put("key", value));
|
||||
|
||||
// The flush fails to sync the footer of the blob file holding "key".
|
||||
SyncPoint::GetInstance()->SetCallBack("BlobLogWriter::Sync", [&](void*) {
|
||||
fault_env->SetFilesystemActive(false, Status::NoSpace("injected"));
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
ASSERT_NOK(Flush());
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
fault_env->SetFilesystemActive(true);
|
||||
|
||||
uint64_t flush_pending = 0;
|
||||
ASSERT_TRUE(db_->GetIntProperty(DB::Properties::kMemTableFlushPending,
|
||||
&flush_pending));
|
||||
ASSERT_EQ(1U, flush_pending);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DBBlobDirectWriteTest, FailedBlobFooterSyncFailsRetriedFlush) {
|
||||
std::unique_ptr<FaultInjectionTestEnv> fault_env(
|
||||
new FaultInjectionTestEnv(env_));
|
||||
Options options = GetDirectWriteOptions();
|
||||
options.env = fault_env.get();
|
||||
options.listeners.emplace_back(
|
||||
std::make_shared<DisableAutoRecoveryListener>());
|
||||
DestroyAndReopen(options);
|
||||
Defer close_db([this]() { Close(); });
|
||||
const std::string value(1024, 'v');
|
||||
ASSERT_OK(Put("key", value));
|
||||
|
||||
// The flush fails to sync the footer of the blob file holding "key".
|
||||
SyncPoint::GetInstance()->SetCallBack("BlobLogWriter::Sync", [&](void*) {
|
||||
fault_env->SetFilesystemActive(false, Status::NoSpace("injected"));
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
ASSERT_NOK(Flush());
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
fault_env->SetFilesystemActive(true);
|
||||
|
||||
// That blob file can no longer be sealed, so retrying the flush must fail
|
||||
// rather than install a table file that references it.
|
||||
ASSERT_NOK(dbfull()->Resume());
|
||||
ASSERT_EQ(0, NumTableFilesAtLevel(0));
|
||||
ASSERT_EQ(value, Get("key"));
|
||||
}
|
||||
|
||||
TEST_F(DBBlobDirectWriteTest, CloseAfterFailedBlobSeal) {
|
||||
std::unique_ptr<FaultInjectionTestEnv> fault_env(
|
||||
new FaultInjectionTestEnv(env_));
|
||||
Options options = GetDirectWriteOptions();
|
||||
options.env = fault_env.get();
|
||||
options.blob_file_size = 2048;
|
||||
options.listeners.emplace_back(
|
||||
std::make_shared<DisableAutoRecoveryListener>());
|
||||
for (bool seal_on_write : {false, true}) {
|
||||
SCOPED_TRACE("seal_on_write=" + std::to_string(seal_on_write));
|
||||
DestroyAndReopen(options);
|
||||
Defer close_db([this]() { Close(); });
|
||||
const std::string value(1024, 'v');
|
||||
ASSERT_OK(Put("key1", value));
|
||||
|
||||
// Sealing the blob file holding "key1" fails, either in the write that
|
||||
// does not fit in it or in the flush. The DB closes without retrying.
|
||||
SyncPoint::GetInstance()->SetCallBack("BlobLogWriter::Sync", [&](void*) {
|
||||
fault_env->SetFilesystemActive(false, Status::NoSpace("injected"));
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
ASSERT_NOK(seal_on_write ? Put("key2", value) : Flush());
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
fault_env->SetFilesystemActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
class DBBlobDirectWriteWithTimestampTest : public DBBasicTestWithTimestampBase {
|
||||
protected:
|
||||
DBBlobDirectWriteWithTimestampTest()
|
||||
|
||||
@@ -57,11 +57,6 @@ TEST(BlobIndexTest, SameFileBlobIndex) {
|
||||
EXPECT_NE(blob_index.DebugString(false).find("file:same"), std::string::npos);
|
||||
}
|
||||
|
||||
TEST(BlobIndexTest, EmptyBlobIndexIsCorruption) {
|
||||
BlobIndex blob_index;
|
||||
ASSERT_EQ(blob_index.DecodeFrom(Slice()).code(), Status::Code::kCorruption);
|
||||
}
|
||||
|
||||
// kTypeBlobIndex is a value type used by BlobDB only. The base rocksdb
|
||||
// should accept the value type on write, and report not supported value
|
||||
// for reads, unless caller request for it explicitly. The base rocksdb
|
||||
|
||||
@@ -1,284 +0,0 @@
|
||||
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
// This source code is licensed under both the GPLv2 (found in the
|
||||
// COPYING file in the root directory) and Apache 2.0 License
|
||||
// (found in the LICENSE.Apache file in the root directory).
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "db/blob/blob_index.h"
|
||||
#include "db/version_set.h"
|
||||
#include "db/wide/wide_column_serialization.h"
|
||||
#include "table/internal_iterator.h"
|
||||
|
||||
namespace ROCKSDB_NAMESPACE {
|
||||
|
||||
// Replaces references absent from an immutable input Version with deletions
|
||||
// or entities containing the surviving columns. Input values must already be
|
||||
// prepared, as they are for compaction input. Neither input is owned.
|
||||
class MissingBlobRepairIterator : public InternalIterator {
|
||||
public:
|
||||
MissingBlobRepairIterator(InternalIterator* input,
|
||||
const VersionStorageInfo* input_storage,
|
||||
size_t timestamp_size)
|
||||
: input_(input),
|
||||
input_storage_(input_storage),
|
||||
timestamp_size_(timestamp_size) {
|
||||
assert(input_);
|
||||
assert(input_storage_);
|
||||
Update();
|
||||
}
|
||||
|
||||
bool Valid() const override { return input_->Valid() && status_.ok(); }
|
||||
|
||||
void SeekToFirst() override {
|
||||
input_->SeekToFirst();
|
||||
Update();
|
||||
}
|
||||
|
||||
void SeekToLast() override {
|
||||
input_->SeekToLast();
|
||||
Update();
|
||||
}
|
||||
|
||||
void Seek(const Slice& target) override {
|
||||
// A rewritten type can sort after its original type at the same sequence.
|
||||
const std::string target_copy = target.ToString();
|
||||
ParsedInternalKey parsed;
|
||||
status_ = ParseInternalKey(target_copy, &parsed, false);
|
||||
if (!status_.ok()) {
|
||||
return;
|
||||
}
|
||||
InternalKey seek_key(parsed.user_key, parsed.sequence, kValueTypeForSeek);
|
||||
input_->Seek(seek_key.Encode());
|
||||
Update();
|
||||
while (Valid() && input_storage_->InternalComparator()->Compare(
|
||||
key(), target_copy) < 0) {
|
||||
Next();
|
||||
}
|
||||
}
|
||||
|
||||
void SeekForPrev(const Slice& target) override {
|
||||
const std::string target_copy = target.ToString();
|
||||
input_->SeekForPrev(target_copy);
|
||||
Update();
|
||||
while (Valid() && input_storage_->InternalComparator()->Compare(
|
||||
key(), target_copy) > 0) {
|
||||
Prev();
|
||||
}
|
||||
}
|
||||
|
||||
void Next() override {
|
||||
assert(Valid());
|
||||
input_->Next();
|
||||
Update();
|
||||
}
|
||||
|
||||
void Prev() override {
|
||||
assert(Valid());
|
||||
input_->Prev();
|
||||
Update();
|
||||
}
|
||||
|
||||
Slice key() const override {
|
||||
assert(Valid());
|
||||
return repaired_key_.empty() ? input_->key() : Slice(repaired_key_);
|
||||
}
|
||||
|
||||
Slice value() const override {
|
||||
assert(Valid());
|
||||
return value_rewritten_ ? Slice(repaired_value_) : input_->value();
|
||||
}
|
||||
|
||||
uint64_t write_unix_time() const override {
|
||||
return input_->write_unix_time();
|
||||
}
|
||||
|
||||
Status status() const override { return status_; }
|
||||
|
||||
bool PrepareValue() override {
|
||||
assert(Valid());
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetPinnedItersMgr(PinnedIteratorsManager* manager) override {
|
||||
input_->SetPinnedItersMgr(manager);
|
||||
}
|
||||
|
||||
bool IsKeyPinned() const override {
|
||||
return repaired_key_.empty() && input_->IsKeyPinned();
|
||||
}
|
||||
|
||||
bool IsValuePinned() const override {
|
||||
return !value_rewritten_ && input_->IsValuePinned();
|
||||
}
|
||||
|
||||
bool IsSafeToDropWhilePinned() const override {
|
||||
return !value_rewritten_ && input_->IsSafeToDropWhilePinned();
|
||||
}
|
||||
|
||||
bool IsDeleteRangeSentinelKey() const override {
|
||||
return input_->IsDeleteRangeSentinelKey();
|
||||
}
|
||||
|
||||
bool MayBeOutOfLowerBound() override {
|
||||
return input_->MayBeOutOfLowerBound();
|
||||
}
|
||||
|
||||
IterBoundCheck UpperBoundCheckResult() override {
|
||||
return input_->UpperBoundCheckResult();
|
||||
}
|
||||
|
||||
void SetRangeDelReadSeqno(SequenceNumber sequence) override {
|
||||
input_->SetRangeDelReadSeqno(sequence);
|
||||
}
|
||||
|
||||
void GetReadaheadState(ReadaheadFileInfo* state) override {
|
||||
input_->GetReadaheadState(state);
|
||||
}
|
||||
|
||||
void SetReadaheadState(ReadaheadFileInfo* state) override {
|
||||
input_->SetReadaheadState(state);
|
||||
}
|
||||
|
||||
Status GetProperty(std::string name, std::string* value) override {
|
||||
return input_->GetProperty(std::move(name), value);
|
||||
}
|
||||
|
||||
bool IsRepairDeletion() const { return repair_deletion_; }
|
||||
|
||||
private:
|
||||
// Only external, non-TTL indexes use the input Version's blob file set.
|
||||
// Absence is checked in metadata; inline, same-file and legacy TTL indexes
|
||||
// retain their existing resolution rules.
|
||||
bool IsMissing(const BlobIndex& index) const {
|
||||
if (index.IsInlined() || index.HasTTL() || index.IsSameFile()) {
|
||||
return false;
|
||||
}
|
||||
const VersionStorageInfo::BlobFiles::const_iterator it =
|
||||
input_storage_->GetBlobFileMetaDataLB(index.file_number());
|
||||
return it == input_storage_->GetBlobFiles().end() ||
|
||||
(*it)->GetBlobFileNumber() != index.file_number();
|
||||
}
|
||||
|
||||
// Preserve the sequence and user-key timestamp so the lost value continues
|
||||
// to hide older versions, including versions retained for snapshots.
|
||||
void SetDeletion(const ParsedInternalKey& parsed) {
|
||||
repaired_key_ = input_->key().ToString();
|
||||
const ValueType type =
|
||||
timestamp_size_ == 0 ? kTypeDeletion : kTypeDeletionWithTimestamp;
|
||||
UpdateInternalKey(&repaired_key_, parsed.sequence, type);
|
||||
value_rewritten_ = true;
|
||||
repair_deletion_ = true;
|
||||
}
|
||||
|
||||
// Inspect column indexes without resolving blob payloads. Removing columns
|
||||
// changes the positions of surviving blob indexes, so rebuild those positions
|
||||
// before serialization. Only loss of every column becomes a deletion.
|
||||
Status RepairEntity(const ParsedInternalKey& parsed) {
|
||||
columns_.clear();
|
||||
blob_columns_.clear();
|
||||
Status s = WideColumnSerialization::Deserialize(input_->value(), columns_,
|
||||
&blob_columns_);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
|
||||
bool has_missing = false;
|
||||
for (const std::pair<size_t, BlobIndex>& column : blob_columns_) {
|
||||
has_missing |= IsMissing(column.second);
|
||||
}
|
||||
if (!has_missing) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
surviving_columns_.clear();
|
||||
surviving_blobs_.clear();
|
||||
size_t blob_position = 0;
|
||||
for (size_t i = 0; i < columns_.size(); ++i) {
|
||||
const BlobIndex* index = nullptr;
|
||||
if (blob_position < blob_columns_.size() &&
|
||||
blob_columns_[blob_position].first == i) {
|
||||
index = &blob_columns_[blob_position++].second;
|
||||
}
|
||||
if (index && IsMissing(*index)) {
|
||||
continue;
|
||||
}
|
||||
if (index) {
|
||||
surviving_blobs_.emplace_back(surviving_columns_.size(), *index);
|
||||
}
|
||||
surviving_columns_.push_back(columns_[i]);
|
||||
}
|
||||
if (surviving_columns_.empty()) {
|
||||
SetDeletion(parsed);
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
s = surviving_blobs_.empty()
|
||||
? WideColumnSerialization::Serialize(surviving_columns_,
|
||||
repaired_value_)
|
||||
: WideColumnSerialization::SerializeV2(
|
||||
surviving_columns_, surviving_blobs_, repaired_value_);
|
||||
if (s.ok()) {
|
||||
value_rewritten_ = true;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
// Reset rewritten buffers on every movement. Preserve input errors and range
|
||||
// deletion sentinels before decoding point values; malformed indexes fail.
|
||||
void Update() {
|
||||
repaired_key_.clear();
|
||||
repaired_value_.clear();
|
||||
value_rewritten_ = false;
|
||||
repair_deletion_ = false;
|
||||
status_ = input_->status();
|
||||
if (!status_.ok() || !input_->Valid() ||
|
||||
input_->IsDeleteRangeSentinelKey()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ParsedInternalKey parsed;
|
||||
status_ = ParseInternalKey(input_->key(), &parsed, false);
|
||||
if (!status_.ok() || (parsed.type != kTypeBlobIndex &&
|
||||
parsed.type != kTypeWideColumnEntity)) {
|
||||
return;
|
||||
}
|
||||
BlobIndex index;
|
||||
if (parsed.user_key.size() < timestamp_size_) {
|
||||
status_ =
|
||||
Status::Corruption("Blob reference key has an invalid timestamp");
|
||||
} else if (parsed.type == kTypeWideColumnEntity) {
|
||||
status_ = RepairEntity(parsed);
|
||||
} else {
|
||||
status_ = index.DecodeFrom(input_->value());
|
||||
}
|
||||
if (!status_.ok()) {
|
||||
return;
|
||||
}
|
||||
if (parsed.type == kTypeBlobIndex && IsMissing(index)) {
|
||||
SetDeletion(parsed);
|
||||
}
|
||||
}
|
||||
|
||||
InternalIterator* input_;
|
||||
const VersionStorageInfo* input_storage_;
|
||||
size_t timestamp_size_;
|
||||
std::string repaired_key_;
|
||||
std::string repaired_value_;
|
||||
WideColumns columns_;
|
||||
std::vector<std::pair<size_t, BlobIndex>> blob_columns_;
|
||||
WideColumns surviving_columns_;
|
||||
std::vector<std::pair<size_t, BlobIndex>> surviving_blobs_;
|
||||
Status status_;
|
||||
bool value_rewritten_ = false;
|
||||
bool repair_deletion_ = false;
|
||||
};
|
||||
|
||||
} // namespace ROCKSDB_NAMESPACE
|
||||
+4
-14
@@ -116,8 +116,7 @@ Status BuildTable(
|
||||
// compaction path so the manifest learns about the new garbage.
|
||||
blob_garbage_meter.reset(new BlobGarbageMeter());
|
||||
blob_counting_iter.reset(
|
||||
new BlobCountingIterator(iter, blob_garbage_meter.get(),
|
||||
/*track_current_key_inflow=*/false));
|
||||
new BlobCountingIterator(iter, blob_garbage_meter.get()));
|
||||
input = blob_counting_iter.get();
|
||||
}
|
||||
|
||||
@@ -162,13 +161,6 @@ Status BuildTable(
|
||||
context.reason = tboptions.reason;
|
||||
compaction_filter =
|
||||
ioptions.compaction_filter_factory->CreateCompactionFilter(context);
|
||||
CompactionFilter::MergeOrder order;
|
||||
s = GetCompactionFilterMergeOrder(
|
||||
compaction_filter.get(), ioptions.compaction_filter_factory.get(),
|
||||
tboptions.reason, &order);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
if (compaction_filter != nullptr &&
|
||||
!compaction_filter->IgnoreSnapshots()) {
|
||||
s.PermitUncheckedError();
|
||||
@@ -224,8 +216,7 @@ Status BuildTable(
|
||||
auto ucmp = tboptions.internal_comparator.user_comparator();
|
||||
MergeHelper merge(
|
||||
env, ucmp, ioptions.merge_operator.get(), compaction_filter.get(),
|
||||
CompactionFilter::MergeOrder::kFilterBeforeMerge, ioptions.logger,
|
||||
true /* internal key corruption is not ok */,
|
||||
ioptions.logger, true /* internal key corruption is not ok */,
|
||||
snapshots.empty() ? 0 : snapshots.back(), snapshot_checker);
|
||||
|
||||
std::unique_ptr<BlobFileBuilder> blob_file_builder(
|
||||
@@ -238,8 +229,7 @@ Status BuildTable(
|
||||
&(tboptions.write_options), tboptions.db_id,
|
||||
tboptions.db_session_id, job_id, tboptions.column_family_id,
|
||||
tboptions.column_family_name, write_hint, io_tracer,
|
||||
blob_callback, blob_creation_reason,
|
||||
ioptions.cf_paths.front().path, &blob_file_paths,
|
||||
blob_callback, blob_creation_reason, &blob_file_paths,
|
||||
blob_file_additions)
|
||||
: nullptr);
|
||||
|
||||
@@ -400,7 +390,7 @@ Status BuildTable(
|
||||
std::min(meta->fd.smallest_seqno, smallest_preferred_seqno),
|
||||
meta->fd.largest_seqno);
|
||||
relevant_mapping.SetCapacity(kMaxSeqnoTimePairsPerSST);
|
||||
relevant_mapping.Enforce(meta->file_creation_time);
|
||||
relevant_mapping.Enforce(tboptions.file_creation_time);
|
||||
}
|
||||
builder->SetSeqnoTimeTableProperties(
|
||||
relevant_mapping,
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
#include "rocksdb/wal_filter.h"
|
||||
#include "rocksdb/write_batch.h"
|
||||
#include "rocksdb/write_buffer_manager.h"
|
||||
#include "util/cast_util.h"
|
||||
#include "util/stderr_logger.h"
|
||||
#include "utilities/merge_operators.h"
|
||||
|
||||
@@ -420,13 +419,6 @@ struct rocksdb_readoptions_t {
|
||||
std::function<bool(const TableProperties&)> table_filter_func;
|
||||
std::shared_ptr<UserDefinedIndexFactory> table_index_factory;
|
||||
|
||||
rocksdb_readoptions_t() = default;
|
||||
// No copying allowed
|
||||
rocksdb_readoptions_t(const rocksdb_readoptions_t&) = delete;
|
||||
rocksdb_readoptions_t& operator=(const rocksdb_readoptions_t&) = delete;
|
||||
rocksdb_readoptions_t(rocksdb_readoptions_t&&) = delete;
|
||||
rocksdb_readoptions_t& operator=(rocksdb_readoptions_t&&) = delete;
|
||||
|
||||
~rocksdb_readoptions_t() { ClearTableFilter(); }
|
||||
|
||||
void ClearTableFilter() {
|
||||
@@ -475,23 +467,6 @@ struct rocksdb_compactoptions_t {
|
||||
struct rocksdb_block_based_table_options_t {
|
||||
BlockBasedTableOptions rep;
|
||||
std::shared_ptr<UserDefinedIndexFactory> user_defined_index_factory;
|
||||
bool use_udi_as_primary_index = false;
|
||||
bool fail_if_no_udi_on_open = false;
|
||||
// Set once rocksdb_block_based_options_set_index_mode() has been called.
|
||||
// Mirrors the C++ precedence rule in GetEffectiveIndexMode(): an explicit
|
||||
// index_mode wins over the deprecated bools, so a stale
|
||||
// use_udi_as_primary_index cannot silently escalate a rollback back into a
|
||||
// custom-index mode.
|
||||
bool index_mode_explicit = false;
|
||||
|
||||
void SyncIndexModeFromLegacyUdiOptions() {
|
||||
if (index_mode_explicit) {
|
||||
return;
|
||||
}
|
||||
rep.index_mode = BlockBasedTableOptions::IndexMode::kStandardDefault;
|
||||
rep.use_udi_as_primary_index = use_udi_as_primary_index;
|
||||
rep.fail_if_no_udi_on_open = fail_if_no_udi_on_open;
|
||||
}
|
||||
};
|
||||
struct rocksdb_block_cache_trace_options_t {
|
||||
BlockCacheTraceOptions rep;
|
||||
@@ -830,22 +805,14 @@ struct rocksdb_open_and_compact_options_t {
|
||||
};
|
||||
|
||||
struct rocksdb_compactionfilter_t : public CompactionFilter {
|
||||
void* state_ = nullptr;
|
||||
void (*destructor_)(void*) = nullptr;
|
||||
void* state_;
|
||||
void (*destructor_)(void*);
|
||||
unsigned char (*filter_)(void*, int level, const char* key, size_t key_length,
|
||||
const char* existing_value, size_t value_length,
|
||||
char** new_value, size_t* new_value_length,
|
||||
unsigned char* value_changed) = nullptr;
|
||||
const char* (*name_)(void*) = nullptr;
|
||||
unsigned char ignore_snapshots_ = true;
|
||||
|
||||
rocksdb_compactionfilter_t() = default;
|
||||
// No copying allowed
|
||||
rocksdb_compactionfilter_t(const rocksdb_compactionfilter_t&) = delete;
|
||||
rocksdb_compactionfilter_t& operator=(const rocksdb_compactionfilter_t&) =
|
||||
delete;
|
||||
rocksdb_compactionfilter_t(rocksdb_compactionfilter_t&&) = delete;
|
||||
rocksdb_compactionfilter_t& operator=(rocksdb_compactionfilter_t&&) = delete;
|
||||
unsigned char* value_changed);
|
||||
const char* (*name_)(void*);
|
||||
unsigned char ignore_snapshots_;
|
||||
|
||||
~rocksdb_compactionfilter_t() override { (*destructor_)(state_); }
|
||||
|
||||
@@ -871,22 +838,11 @@ struct rocksdb_compactionfilter_t : public CompactionFilter {
|
||||
};
|
||||
|
||||
struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory {
|
||||
void* state_ = nullptr;
|
||||
void (*destructor_)(void*) = nullptr;
|
||||
void* state_;
|
||||
void (*destructor_)(void*);
|
||||
rocksdb_compactionfilter_t* (*create_compaction_filter_)(
|
||||
void*, rocksdb_compactionfiltercontext_t* context) = nullptr;
|
||||
const char* (*name_)(void*) = nullptr;
|
||||
|
||||
rocksdb_compactionfilterfactory_t() = default;
|
||||
// No copying allowed
|
||||
rocksdb_compactionfilterfactory_t(const rocksdb_compactionfilterfactory_t&) =
|
||||
delete;
|
||||
rocksdb_compactionfilterfactory_t& operator=(
|
||||
const rocksdb_compactionfilterfactory_t&) = delete;
|
||||
rocksdb_compactionfilterfactory_t(rocksdb_compactionfilterfactory_t&&) =
|
||||
delete;
|
||||
rocksdb_compactionfilterfactory_t& operator=(
|
||||
rocksdb_compactionfilterfactory_t&&) = delete;
|
||||
void*, rocksdb_compactionfiltercontext_t* context);
|
||||
const char* (*name_)(void*);
|
||||
|
||||
~rocksdb_compactionfilterfactory_t() override { (*destructor_)(state_); }
|
||||
|
||||
@@ -917,12 +873,6 @@ struct rocksdb_comparator_t : public Comparator {
|
||||
|
||||
rocksdb_comparator_t(size_t ts_size) : Comparator(ts_size) {}
|
||||
|
||||
// No copying allowed
|
||||
rocksdb_comparator_t(const rocksdb_comparator_t&) = delete;
|
||||
rocksdb_comparator_t& operator=(const rocksdb_comparator_t&) = delete;
|
||||
rocksdb_comparator_t(rocksdb_comparator_t&&) = delete;
|
||||
rocksdb_comparator_t& operator=(rocksdb_comparator_t&&) = delete;
|
||||
|
||||
~rocksdb_comparator_t() override { (*destructor_)(state_); }
|
||||
|
||||
int Compare(const Slice& a, const Slice& b) const override {
|
||||
@@ -954,16 +904,9 @@ struct rocksdb_comparator_t : public Comparator {
|
||||
};
|
||||
|
||||
struct rocksdb_filterpolicy_t : public FilterPolicy {
|
||||
void* state_ = nullptr;
|
||||
void (*destructor_)(void*) = nullptr;
|
||||
const char* (*name_)(void*) = nullptr;
|
||||
|
||||
rocksdb_filterpolicy_t() = default;
|
||||
// No copying allowed
|
||||
rocksdb_filterpolicy_t(const rocksdb_filterpolicy_t&) = delete;
|
||||
rocksdb_filterpolicy_t& operator=(const rocksdb_filterpolicy_t&) = delete;
|
||||
rocksdb_filterpolicy_t(rocksdb_filterpolicy_t&&) = delete;
|
||||
rocksdb_filterpolicy_t& operator=(rocksdb_filterpolicy_t&&) = delete;
|
||||
void* state_;
|
||||
void (*destructor_)(void*);
|
||||
const char* (*name_)(void*);
|
||||
|
||||
~rocksdb_filterpolicy_t() override { (*destructor_)(state_); }
|
||||
|
||||
@@ -971,29 +914,19 @@ struct rocksdb_filterpolicy_t : public FilterPolicy {
|
||||
};
|
||||
|
||||
struct rocksdb_mergeoperator_t : public MergeOperator {
|
||||
void* state_ = nullptr;
|
||||
void (*destructor_)(void*) = nullptr;
|
||||
const char* (*name_)(void*) = nullptr;
|
||||
void* state_;
|
||||
void (*destructor_)(void*);
|
||||
const char* (*name_)(void*);
|
||||
char* (*full_merge_)(void*, const char* key, size_t key_length,
|
||||
const char* existing_value, size_t existing_value_length,
|
||||
const char* const* operands_list,
|
||||
const size_t* operands_list_length, int num_operands,
|
||||
unsigned char* success,
|
||||
size_t* new_value_length) = nullptr;
|
||||
unsigned char* success, size_t* new_value_length);
|
||||
char* (*partial_merge_)(void*, const char* key, size_t key_length,
|
||||
const char* const* operands_list,
|
||||
const size_t* operands_list_length, int num_operands,
|
||||
unsigned char* success,
|
||||
size_t* new_value_length) = nullptr;
|
||||
void (*delete_value_)(void*, const char* value,
|
||||
size_t value_length) = nullptr;
|
||||
|
||||
rocksdb_mergeoperator_t() = default;
|
||||
// No copying allowed
|
||||
rocksdb_mergeoperator_t(const rocksdb_mergeoperator_t&) = delete;
|
||||
rocksdb_mergeoperator_t& operator=(const rocksdb_mergeoperator_t&) = delete;
|
||||
rocksdb_mergeoperator_t(rocksdb_mergeoperator_t&&) = delete;
|
||||
rocksdb_mergeoperator_t& operator=(rocksdb_mergeoperator_t&&) = delete;
|
||||
unsigned char* success, size_t* new_value_length);
|
||||
void (*delete_value_)(void*, const char* value, size_t value_length);
|
||||
|
||||
~rocksdb_mergeoperator_t() override { (*destructor_)(state_); }
|
||||
|
||||
@@ -1075,19 +1008,12 @@ struct rocksdb_env_t {
|
||||
};
|
||||
|
||||
struct rocksdb_slicetransform_t : public SliceTransform {
|
||||
void* state_ = nullptr;
|
||||
void (*destructor_)(void*) = nullptr;
|
||||
const char* (*name_)(void*) = nullptr;
|
||||
void* state_;
|
||||
void (*destructor_)(void*);
|
||||
const char* (*name_)(void*);
|
||||
char* (*transform_)(void*, const char* key, size_t length,
|
||||
size_t* dst_length) = nullptr;
|
||||
unsigned char (*in_domain_)(void*, const char* key, size_t length) = nullptr;
|
||||
|
||||
rocksdb_slicetransform_t() = default;
|
||||
// No copying allowed
|
||||
rocksdb_slicetransform_t(const rocksdb_slicetransform_t&) = delete;
|
||||
rocksdb_slicetransform_t& operator=(const rocksdb_slicetransform_t&) = delete;
|
||||
rocksdb_slicetransform_t(rocksdb_slicetransform_t&&) = delete;
|
||||
rocksdb_slicetransform_t& operator=(rocksdb_slicetransform_t&&) = delete;
|
||||
size_t* dst_length);
|
||||
unsigned char (*in_domain_)(void*, const char* key, size_t length);
|
||||
|
||||
~rocksdb_slicetransform_t() override { (*destructor_)(state_); }
|
||||
|
||||
@@ -1411,14 +1337,6 @@ struct rocksdb_compactionservice_t : public CompactionService {
|
||||
cancel_awaiting_jobs_(cancel_awaiting_jobs),
|
||||
on_installation_(on_installation) {}
|
||||
|
||||
// No copying allowed
|
||||
rocksdb_compactionservice_t(const rocksdb_compactionservice_t&) = delete;
|
||||
rocksdb_compactionservice_t& operator=(const rocksdb_compactionservice_t&) =
|
||||
delete;
|
||||
rocksdb_compactionservice_t(rocksdb_compactionservice_t&&) = delete;
|
||||
rocksdb_compactionservice_t& operator=(rocksdb_compactionservice_t&&) =
|
||||
delete;
|
||||
|
||||
~rocksdb_compactionservice_t() override {
|
||||
if (destructor_) {
|
||||
(*destructor_)(state_);
|
||||
@@ -4785,60 +4703,12 @@ const char* rocksdb_block_based_options_get_user_defined_index_factory_name(
|
||||
return name;
|
||||
}
|
||||
|
||||
void rocksdb_block_based_options_set_use_udi_as_primary_index(
|
||||
rocksdb_block_based_table_options_t* opt, unsigned char v) {
|
||||
opt->use_udi_as_primary_index = v != 0;
|
||||
opt->SyncIndexModeFromLegacyUdiOptions();
|
||||
}
|
||||
|
||||
unsigned char rocksdb_block_based_options_get_use_udi_as_primary_index(
|
||||
rocksdb_block_based_table_options_t* opt) {
|
||||
return opt->use_udi_as_primary_index;
|
||||
}
|
||||
|
||||
void rocksdb_block_based_options_set_fail_if_no_udi_on_open(
|
||||
rocksdb_block_based_table_options_t* opt, unsigned char v) {
|
||||
opt->fail_if_no_udi_on_open = v != 0;
|
||||
opt->SyncIndexModeFromLegacyUdiOptions();
|
||||
}
|
||||
|
||||
unsigned char rocksdb_block_based_options_get_fail_if_no_udi_on_open(
|
||||
rocksdb_block_based_table_options_t* opt) {
|
||||
return opt->fail_if_no_udi_on_open;
|
||||
}
|
||||
|
||||
void rocksdb_block_based_options_set_index_mode(
|
||||
rocksdb_block_based_table_options_t* opt, int v) {
|
||||
opt->rep.index_mode = static_cast<BlockBasedTableOptions::IndexMode>(v);
|
||||
opt->index_mode_explicit = true;
|
||||
opt->rep.use_udi_as_primary_index = false;
|
||||
opt->rep.fail_if_no_udi_on_open = false;
|
||||
}
|
||||
|
||||
int rocksdb_block_based_options_get_index_mode(
|
||||
rocksdb_block_based_table_options_t* opt) {
|
||||
return ROCKSDB_NAMESPACE::lossless_cast<int>(
|
||||
opt->rep.GetEffectiveIndexMode());
|
||||
}
|
||||
|
||||
void rocksdb_options_set_block_based_table_factory(
|
||||
rocksdb_options_t* opt,
|
||||
rocksdb_block_based_table_options_t* table_options) {
|
||||
if (table_options) {
|
||||
opt->rep.table_factory.reset(
|
||||
ROCKSDB_NAMESPACE::NewBlockBasedTableFactory(table_options->rep));
|
||||
if (table_options->index_mode_explicit &&
|
||||
table_options->rep.index_mode ==
|
||||
BlockBasedTableOptions::IndexMode::kStandardDefault) {
|
||||
// The default struct value cannot carry an explicit selection. Preserve
|
||||
// that selection when transferring the C wrapper into a C++ factory.
|
||||
ConfigOptions config;
|
||||
config.invoke_prepare_options = false;
|
||||
Status s = opt->rep.table_factory->ConfigureOption(config, "index_mode",
|
||||
"kStandardDefault");
|
||||
assert(s.ok());
|
||||
s.PermitUncheckedError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4952,12 +4822,6 @@ int rocksdb_compactionjobinfo_job_id(const rocksdb_compactionjobinfo_t* info) {
|
||||
return info->rep.job_id;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
rocksdb_compactionjobinfo_separate_remote_compaction_pool_selected(
|
||||
const rocksdb_compactionjobinfo_t* info) {
|
||||
return info->rep.separate_remote_compaction_pool_selected;
|
||||
}
|
||||
|
||||
int rocksdb_compactionjobinfo_num_l0_files(
|
||||
const rocksdb_compactionjobinfo_t* info) {
|
||||
return info->rep.num_l0_files;
|
||||
@@ -5021,12 +4885,6 @@ int rocksdb_subcompactionjobinfo_job_id(
|
||||
return info->rep.job_id;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
rocksdb_subcompactionjobinfo_separate_remote_compaction_pool_selected(
|
||||
const rocksdb_subcompactionjobinfo_t* info) {
|
||||
return info->rep.separate_remote_compaction_pool_selected;
|
||||
}
|
||||
|
||||
int rocksdb_subcompactionjobinfo_subcompaction_job_id(
|
||||
const rocksdb_subcompactionjobinfo_t* info) {
|
||||
return info->rep.subcompaction_job_id;
|
||||
@@ -5265,11 +5123,6 @@ uint64_t rocksdb_table_properties_udi_is_primary_index(
|
||||
return props->rep.udi_is_primary_index;
|
||||
}
|
||||
|
||||
uint64_t rocksdb_table_properties_standard_index_is_stub(
|
||||
const rocksdb_table_properties_t* props) {
|
||||
return props->rep.standard_index_is_stub;
|
||||
}
|
||||
|
||||
uint64_t rocksdb_table_properties_filter_size(
|
||||
const rocksdb_table_properties_t* props) {
|
||||
return props->rep.filter_size;
|
||||
@@ -5735,16 +5588,6 @@ uint64_t rocksdb_blob_file_garbage_info_garbage_blob_bytes(
|
||||
}
|
||||
// END generated: c_generated_metadata_structs_auto.cc.inc
|
||||
|
||||
unsigned char rocksdb_compactionjobinfo_use_separate_remote_compaction_pool(
|
||||
const rocksdb_compactionjobinfo_t* info) {
|
||||
return info->rep.separate_remote_compaction_pool_selected;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_subcompactionjobinfo_use_separate_remote_compaction_pool(
|
||||
const rocksdb_subcompactionjobinfo_t* info) {
|
||||
return info->rep.separate_remote_compaction_pool_selected;
|
||||
}
|
||||
|
||||
rocksdb_compactionjobinfo_t* rocksdb_compactionjobinfo_create() {
|
||||
return new rocksdb_compactionjobinfo_t;
|
||||
}
|
||||
@@ -7120,12 +6963,7 @@ rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom_format(
|
||||
// they delegate to a NewBloomFilterPolicy() instead of user
|
||||
// supplied C functions.
|
||||
struct Wrapper : public rocksdb_filterpolicy_t {
|
||||
const FilterPolicy* rep_ = nullptr;
|
||||
Wrapper() = default;
|
||||
Wrapper(const Wrapper&) = delete;
|
||||
Wrapper& operator=(const Wrapper&) = delete;
|
||||
Wrapper(Wrapper&&) = delete;
|
||||
Wrapper& operator=(Wrapper&&) = delete;
|
||||
const FilterPolicy* rep_;
|
||||
~Wrapper() override { delete rep_; }
|
||||
const char* Name() const override { return rep_->Name(); }
|
||||
const char* CompatibilityName() const override {
|
||||
@@ -7165,12 +7003,7 @@ rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_ribbon_format(
|
||||
// they delegate to a NewRibbonFilterPolicy() instead of user
|
||||
// supplied C functions.
|
||||
struct Wrapper : public rocksdb_filterpolicy_t {
|
||||
const FilterPolicy* rep_ = nullptr;
|
||||
Wrapper() = default;
|
||||
Wrapper(const Wrapper&) = delete;
|
||||
Wrapper& operator=(const Wrapper&) = delete;
|
||||
Wrapper(Wrapper&&) = delete;
|
||||
Wrapper& operator=(Wrapper&&) = delete;
|
||||
const FilterPolicy* rep_;
|
||||
~Wrapper() override { delete rep_; }
|
||||
const char* Name() const override { return rep_->Name(); }
|
||||
const char* CompatibilityName() const override {
|
||||
@@ -7606,7 +7439,6 @@ void rocksdb_readoptions_set_table_index_factory_from_string(
|
||||
char** errptr) {
|
||||
opt->table_index_factory.reset();
|
||||
opt->rep.table_index_factory = nullptr;
|
||||
opt->rep.read_index = ReadOptions::ReadIndex::kDefault;
|
||||
if (value == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -7618,21 +7450,11 @@ void rocksdb_readoptions_set_table_index_factory_from_string(
|
||||
}
|
||||
opt->table_index_factory = std::move(factory);
|
||||
opt->rep.table_index_factory = opt->table_index_factory.get();
|
||||
opt->rep.read_index = ReadOptions::ReadIndex::kPreferCustom;
|
||||
}
|
||||
|
||||
void rocksdb_readoptions_clear_table_index_factory(rocksdb_readoptions_t* opt) {
|
||||
opt->table_index_factory.reset();
|
||||
opt->rep.table_index_factory = nullptr;
|
||||
opt->rep.read_index = ReadOptions::ReadIndex::kDefault;
|
||||
}
|
||||
|
||||
void rocksdb_readoptions_set_read_index(rocksdb_readoptions_t* opt, int v) {
|
||||
opt->rep.read_index = static_cast<ReadOptions::ReadIndex>(v);
|
||||
}
|
||||
|
||||
int rocksdb_readoptions_get_read_index(const rocksdb_readoptions_t* opt) {
|
||||
return static_cast<int>(opt->rep.read_index);
|
||||
}
|
||||
|
||||
const char* rocksdb_readoptions_get_table_index_factory_name(
|
||||
@@ -10195,16 +10017,6 @@ unsigned char rocksdb_options_get_write_dbid_to_manifest(
|
||||
return opt->rep.write_dbid_to_manifest;
|
||||
}
|
||||
|
||||
void rocksdb_options_set_track_options_file_number_in_manifest(
|
||||
rocksdb_options_t* opt, unsigned char v) {
|
||||
opt->rep.track_options_file_number_in_manifest = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_options_get_track_options_file_number_in_manifest(
|
||||
rocksdb_options_t* opt) {
|
||||
return opt->rep.track_options_file_number_in_manifest;
|
||||
}
|
||||
|
||||
void rocksdb_options_set_write_identity_file(rocksdb_options_t* opt,
|
||||
unsigned char v) {
|
||||
opt->rep.write_identity_file = v;
|
||||
@@ -10280,16 +10092,6 @@ const char* rocksdb_options_get_db_host_id(rocksdb_options_t* opt,
|
||||
return opt->rep.db_host_id.data();
|
||||
}
|
||||
|
||||
void rocksdb_options_set_use_separate_remote_compaction_pool(
|
||||
rocksdb_options_t* opt, unsigned char v) {
|
||||
opt->rep.use_separate_remote_compaction_pool = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_options_get_use_separate_remote_compaction_pool(
|
||||
rocksdb_options_t* opt) {
|
||||
return opt->rep.use_separate_remote_compaction_pool;
|
||||
}
|
||||
|
||||
void rocksdb_options_set_remote_compaction_manifest_floor(
|
||||
rocksdb_options_t* opt, unsigned char v) {
|
||||
opt->rep.remote_compaction_manifest_floor = v;
|
||||
@@ -11383,16 +11185,6 @@ unsigned char rocksdb_trace_options_get_preserve_write_order(
|
||||
return opt->rep.preserve_write_order;
|
||||
}
|
||||
|
||||
void rocksdb_trace_options_set_include_read_write_options(
|
||||
rocksdb_trace_options_t* opt, unsigned char v) {
|
||||
opt->rep.include_read_write_options = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_trace_options_get_include_read_write_options(
|
||||
rocksdb_trace_options_t* opt) {
|
||||
return opt->rep.include_read_write_options;
|
||||
}
|
||||
|
||||
/* BlockCacheTraceOptions */
|
||||
|
||||
void rocksdb_block_cache_trace_options_set_sampling_frequency(
|
||||
@@ -11472,16 +11264,6 @@ unsigned char rocksdb_compaction_options_get_allow_trivial_move(
|
||||
|
||||
/* CompactRangeOptions */
|
||||
|
||||
void rocksdb_compactoptions_set_skip_missing_blob_files(
|
||||
rocksdb_compactoptions_t* opt, unsigned char v) {
|
||||
opt->rep.skip_missing_blob_files = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_compactoptions_get_skip_missing_blob_files(
|
||||
rocksdb_compactoptions_t* opt) {
|
||||
return opt->rep.skip_missing_blob_files;
|
||||
}
|
||||
|
||||
void rocksdb_compactoptions_set_blob_garbage_collection_policy(
|
||||
rocksdb_compactoptions_t* opt, int v) {
|
||||
opt->rep.blob_garbage_collection_policy =
|
||||
@@ -11629,16 +11411,6 @@ int rocksdb_ingestexternalfileoptions_get_file_opening_threads(
|
||||
return opt->rep.file_opening_threads;
|
||||
}
|
||||
|
||||
void rocksdb_ingestexternalfileoptions_set_reject_too_old_file(
|
||||
rocksdb_ingestexternalfileoptions_t* opt, unsigned char v) {
|
||||
opt->rep.reject_too_old_file = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_ingestexternalfileoptions_get_reject_too_old_file(
|
||||
rocksdb_ingestexternalfileoptions_t* opt) {
|
||||
return opt->rep.reject_too_old_file;
|
||||
}
|
||||
|
||||
/* OpenAndCompactOptions */
|
||||
|
||||
void rocksdb_open_and_compact_options_set_max_secondary_open_retries(
|
||||
@@ -11663,16 +11435,6 @@ unsigned char rocksdb_import_column_family_options_get_move_files(
|
||||
return opt->rep.move_files;
|
||||
}
|
||||
|
||||
void rocksdb_import_column_family_options_set_reject_too_old_file(
|
||||
rocksdb_import_column_family_options_t* opt, unsigned char v) {
|
||||
opt->rep.reject_too_old_file = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_import_column_family_options_get_reject_too_old_file(
|
||||
rocksdb_import_column_family_options_t* opt) {
|
||||
return opt->rep.reject_too_old_file;
|
||||
}
|
||||
|
||||
/* SizeApproximationOptions */
|
||||
|
||||
void rocksdb_size_approximation_options_set_include_memtables(
|
||||
@@ -11967,6 +11729,26 @@ unsigned char rocksdb_block_based_options_get_use_delta_encoding(
|
||||
return opt->rep.use_delta_encoding;
|
||||
}
|
||||
|
||||
void rocksdb_block_based_options_set_use_udi_as_primary_index(
|
||||
rocksdb_block_based_table_options_t* opt, unsigned char v) {
|
||||
opt->rep.use_udi_as_primary_index = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_block_based_options_get_use_udi_as_primary_index(
|
||||
rocksdb_block_based_table_options_t* opt) {
|
||||
return opt->rep.use_udi_as_primary_index;
|
||||
}
|
||||
|
||||
void rocksdb_block_based_options_set_fail_if_no_udi_on_open(
|
||||
rocksdb_block_based_table_options_t* opt, unsigned char v) {
|
||||
opt->rep.fail_if_no_udi_on_open = v;
|
||||
}
|
||||
|
||||
unsigned char rocksdb_block_based_options_get_fail_if_no_udi_on_open(
|
||||
rocksdb_block_based_table_options_t* opt) {
|
||||
return opt->rep.fail_if_no_udi_on_open;
|
||||
}
|
||||
|
||||
void rocksdb_block_based_options_set_whole_key_filtering(
|
||||
rocksdb_block_based_table_options_t* opt, unsigned char v) {
|
||||
opt->rep.whole_key_filtering = v;
|
||||
@@ -13539,74 +13321,6 @@ void rocksdb_transactiondb_multi_get_cf(
|
||||
}
|
||||
}
|
||||
|
||||
void rocksdb_transactiondb_batched_multi_get_cf(
|
||||
rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options,
|
||||
rocksdb_column_family_handle_t* column_family, size_t num_keys,
|
||||
const char* const* keys_list, const size_t* keys_list_sizes,
|
||||
rocksdb_pinnableslice_t** values, char** errs, const bool sorted_input) {
|
||||
Slice* key_slices = new Slice[num_keys];
|
||||
PinnableSlice* value_slices = new PinnableSlice[num_keys];
|
||||
Status* statuses = new Status[num_keys];
|
||||
for (size_t i = 0; i < num_keys; ++i) {
|
||||
key_slices[i] = Slice(keys_list[i], keys_list_sizes[i]);
|
||||
}
|
||||
|
||||
txn_db->rep->MultiGet(options->rep, column_family->rep, num_keys, key_slices,
|
||||
value_slices, statuses, sorted_input);
|
||||
|
||||
for (size_t i = 0; i < num_keys; ++i) {
|
||||
if (statuses[i].ok()) {
|
||||
values[i] = new (rocksdb_pinnableslice_t);
|
||||
values[i]->rep = std::move(value_slices[i]);
|
||||
errs[i] = nullptr;
|
||||
} else {
|
||||
values[i] = nullptr;
|
||||
if (!statuses[i].IsNotFound()) {
|
||||
errs[i] = strdup(statuses[i].ToString().c_str());
|
||||
} else {
|
||||
errs[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete[] key_slices;
|
||||
delete[] value_slices;
|
||||
delete[] statuses;
|
||||
}
|
||||
|
||||
void rocksdb_transactiondb_batched_multi_get_cf_slice(
|
||||
rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options,
|
||||
rocksdb_column_family_handle_t* column_family, size_t num_keys,
|
||||
const rocksdb_slice_t* keys_list, rocksdb_pinnableslice_t** values,
|
||||
char** errs, const bool sorted_input) {
|
||||
PinnableSlice* value_slices = new PinnableSlice[num_keys];
|
||||
Status* statuses = new Status[num_keys];
|
||||
|
||||
// Cast rocksdb_slice_t* to Slice* - they have identical memory layout
|
||||
const Slice* key_slices = reinterpret_cast<const Slice*>(keys_list);
|
||||
|
||||
txn_db->rep->MultiGet(options->rep, column_family->rep, num_keys, key_slices,
|
||||
value_slices, statuses, sorted_input);
|
||||
|
||||
for (size_t i = 0; i < num_keys; ++i) {
|
||||
if (statuses[i].ok()) {
|
||||
values[i] = new (rocksdb_pinnableslice_t);
|
||||
values[i]->rep = std::move(value_slices[i]);
|
||||
errs[i] = nullptr;
|
||||
} else {
|
||||
values[i] = nullptr;
|
||||
if (!statuses[i].IsNotFound()) {
|
||||
errs[i] = strdup(statuses[i].ToString().c_str());
|
||||
} else {
|
||||
errs[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete[] value_slices;
|
||||
delete[] statuses;
|
||||
}
|
||||
|
||||
void rocksdb_transaction_set_commit_timestamp(rocksdb_transaction_t* txn,
|
||||
uint64_t commit_timestamp) {
|
||||
txn->rep->SetCommitTimestamp(commit_timestamp);
|
||||
|
||||
+3
-189
@@ -240,138 +240,6 @@ static void CheckPinnableMultiGetError(
|
||||
CheckCondition(strstr(error, expected) != NULL);
|
||||
}
|
||||
|
||||
static void CheckTxnDBBatchedMultiGet(rocksdb_transactiondb_t* db,
|
||||
const rocksdb_readoptions_t* options,
|
||||
rocksdb_column_family_handle_t* cf,
|
||||
const char* expected_a) {
|
||||
for (int sorted = 0; sorted <= 1; ++sorted) {
|
||||
const char* keys[4] = {"b", "a", "b", "missing"};
|
||||
const size_t sizes[4] = {1, 1, 1, 7};
|
||||
const char* expected[4] = {"", expected_a, "", NULL};
|
||||
if (sorted) {
|
||||
keys[0] = "a";
|
||||
keys[1] = "b";
|
||||
expected[0] = expected_a;
|
||||
expected[1] = "";
|
||||
}
|
||||
for (int slices = 0; slices <= 1; ++slices) {
|
||||
rocksdb_pinnableslice_t* values[4];
|
||||
char* errs[4];
|
||||
if (slices) {
|
||||
rocksdb_slice_t key_slices[4];
|
||||
for (size_t i = 0; i < 4; ++i) {
|
||||
key_slices[i].data = keys[i];
|
||||
key_slices[i].size = sizes[i];
|
||||
}
|
||||
rocksdb_transactiondb_batched_multi_get_cf_slice(
|
||||
db, options, cf, 4, key_slices, values, errs, sorted);
|
||||
} else {
|
||||
rocksdb_transactiondb_batched_multi_get_cf(db, options, cf, 4, keys,
|
||||
sizes, values, errs, sorted);
|
||||
}
|
||||
for (size_t i = 0; i < 4; ++i) {
|
||||
CheckNoError(errs[i]);
|
||||
if (expected[i] == NULL) {
|
||||
CheckCondition(values[i] == NULL);
|
||||
} else {
|
||||
size_t size;
|
||||
CheckCondition(values[i] != NULL);
|
||||
const char* value = rocksdb_pinnableslice_value(values[i], &size);
|
||||
CheckEqual(expected[i], value, size);
|
||||
}
|
||||
rocksdb_pinnableslice_destroy(values[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
rocksdb_transactiondb_batched_multi_get_cf(db, options, cf, 0, NULL, NULL,
|
||||
NULL, NULL, false);
|
||||
rocksdb_transactiondb_batched_multi_get_cf_slice(db, options, cf, 0, NULL,
|
||||
NULL, NULL, true);
|
||||
}
|
||||
|
||||
static void TestTxnDBBatchedMultiGet(void) {
|
||||
rocksdb_options_t* options = rocksdb_options_create();
|
||||
rocksdb_readoptions_t* ro = rocksdb_readoptions_create();
|
||||
rocksdb_writeoptions_t* wo = rocksdb_writeoptions_create();
|
||||
rocksdb_transaction_options_t* to = rocksdb_transaction_options_create();
|
||||
rocksdb_transactiondb_options_t* dbo = rocksdb_transactiondb_options_create();
|
||||
char path[200];
|
||||
char* err = NULL;
|
||||
snprintf(path, sizeof(path), "%s/rocksdb_c_test-batched-txn-%" PRIu64,
|
||||
GetTempDir(), GetTestId());
|
||||
rocksdb_options_set_create_if_missing(options, 1);
|
||||
rocksdb_transaction_options_set_skip_prepare(to, 0);
|
||||
for (int policy = rocksdb_txndb_write_policy_write_committed;
|
||||
policy <= rocksdb_txndb_write_policy_write_prepared; ++policy) {
|
||||
rocksdb_destroy_db(options, path, &err);
|
||||
CheckNoError(err);
|
||||
rocksdb_transactiondb_options_set_write_policy(dbo, policy);
|
||||
rocksdb_transactiondb_t* db =
|
||||
rocksdb_transactiondb_open(options, dbo, path, &err);
|
||||
CheckNoError(err);
|
||||
rocksdb_column_family_handle_t* cf =
|
||||
rocksdb_transactiondb_create_column_family(db, options, "batched",
|
||||
&err);
|
||||
CheckNoError(err);
|
||||
rocksdb_transactiondb_put_cf(db, wo, cf, "a", 1, "old", 3, &err);
|
||||
CheckNoError(err);
|
||||
rocksdb_transactiondb_put_cf(db, wo, cf, "b", 1, "", 0, &err);
|
||||
CheckNoError(err);
|
||||
CheckTxnDBBatchedMultiGet(db, ro, cf, "old");
|
||||
|
||||
rocksdb_transaction_t* txn = rocksdb_transaction_begin(db, wo, to, NULL);
|
||||
rocksdb_transaction_set_name(txn, "batched", 7, &err);
|
||||
CheckNoError(err);
|
||||
rocksdb_transaction_put_cf(txn, cf, "a", 1, "new", 3, &err);
|
||||
CheckNoError(err);
|
||||
rocksdb_transaction_prepare(txn, &err);
|
||||
CheckNoError(err);
|
||||
// WRITE_PREPARED puts the new value in the base DB before commit. Reads
|
||||
// must go through TransactionDB to keep that value invisible.
|
||||
CheckTxnDBBatchedMultiGet(db, ro, cf, "old");
|
||||
const rocksdb_snapshot_t* snapshot =
|
||||
rocksdb_transactiondb_create_snapshot(db);
|
||||
rocksdb_transaction_commit(txn, &err);
|
||||
CheckNoError(err);
|
||||
CheckTxnDBBatchedMultiGet(db, ro, cf, "new");
|
||||
rocksdb_readoptions_set_snapshot(ro, snapshot);
|
||||
CheckTxnDBBatchedMultiGet(db, ro, cf, "old");
|
||||
rocksdb_readoptions_set_snapshot(ro, NULL);
|
||||
rocksdb_transactiondb_release_snapshot(db, snapshot);
|
||||
// A timestamp on a non-timestamped column family must return an error,
|
||||
// rather than being reported as a missing key.
|
||||
rocksdb_readoptions_set_timestamp(ro, "timestamp", 9);
|
||||
for (int slices = 0; slices <= 1; ++slices) {
|
||||
const char* keys[1] = {"a"};
|
||||
const size_t sizes[1] = {1};
|
||||
const rocksdb_slice_t key_slices[1] = {{"a", 1}};
|
||||
rocksdb_pinnableslice_t* values[1];
|
||||
char* errs[1];
|
||||
if (slices) {
|
||||
rocksdb_transactiondb_batched_multi_get_cf_slice(
|
||||
db, ro, cf, 1, key_slices, values, errs, true);
|
||||
} else {
|
||||
rocksdb_transactiondb_batched_multi_get_cf(db, ro, cf, 1, keys, sizes,
|
||||
values, errs, true);
|
||||
}
|
||||
CheckCondition(values[0] == NULL);
|
||||
CheckCondition(errs[0] != NULL);
|
||||
rocksdb_free(errs[0]);
|
||||
}
|
||||
rocksdb_readoptions_set_timestamp(ro, NULL, 0);
|
||||
rocksdb_transaction_destroy(txn);
|
||||
rocksdb_column_family_handle_destroy(cf);
|
||||
rocksdb_transactiondb_close(db);
|
||||
rocksdb_destroy_db(options, path, &err);
|
||||
CheckNoError(err);
|
||||
}
|
||||
rocksdb_transactiondb_options_destroy(dbo);
|
||||
rocksdb_transaction_options_destroy(to);
|
||||
rocksdb_writeoptions_destroy(wo);
|
||||
rocksdb_readoptions_destroy(ro);
|
||||
rocksdb_options_destroy(options);
|
||||
}
|
||||
|
||||
static void CheckIter(rocksdb_iterator_t* iter, const char* key,
|
||||
const char* val) {
|
||||
size_t len;
|
||||
@@ -456,6 +324,7 @@ static void CheckPutCF(void* ptr, uint32_t cfid, const char* k, size_t klen,
|
||||
break;
|
||||
default:
|
||||
CheckCondition(false);
|
||||
break;
|
||||
}
|
||||
(*state)++;
|
||||
}
|
||||
@@ -474,6 +343,7 @@ static void CheckDelCF(void* ptr, uint32_t cfid, const char* k, size_t klen) {
|
||||
break;
|
||||
default:
|
||||
CheckCondition(false);
|
||||
break;
|
||||
}
|
||||
(*state)++;
|
||||
}
|
||||
@@ -495,6 +365,7 @@ static void CheckMergeCF(void* ptr, uint32_t cfid, const char* k, size_t klen,
|
||||
break;
|
||||
default:
|
||||
CheckCondition(false);
|
||||
break;
|
||||
}
|
||||
(*state)++;
|
||||
}
|
||||
@@ -3759,42 +3630,6 @@ int main(int argc, char** argv) {
|
||||
bbo, &factory_name_len);
|
||||
CheckCondition(factory_name == NULL);
|
||||
CheckCondition(factory_name_len == 0);
|
||||
CheckCondition(
|
||||
rocksdb_block_based_options_get_use_udi_as_primary_index(bbo) == 0);
|
||||
rocksdb_block_based_options_set_use_udi_as_primary_index(bbo, 1);
|
||||
CheckCondition(
|
||||
rocksdb_block_based_options_get_use_udi_as_primary_index(bbo) == 1);
|
||||
rocksdb_block_based_options_set_use_udi_as_primary_index(bbo, 0);
|
||||
CheckCondition(
|
||||
rocksdb_block_based_options_get_use_udi_as_primary_index(bbo) == 0);
|
||||
CheckCondition(
|
||||
rocksdb_block_based_options_get_fail_if_no_udi_on_open(bbo) == 0);
|
||||
rocksdb_block_based_options_set_fail_if_no_udi_on_open(bbo, 1);
|
||||
CheckCondition(
|
||||
rocksdb_block_based_options_get_fail_if_no_udi_on_open(bbo) == 1);
|
||||
rocksdb_block_based_options_set_fail_if_no_udi_on_open(bbo, 0);
|
||||
CheckCondition(
|
||||
rocksdb_block_based_options_get_fail_if_no_udi_on_open(bbo) == 0);
|
||||
|
||||
// index_mode defaults to standard_default and tracks the deprecated
|
||||
// bools until it is set explicitly; after that an explicit value wins no
|
||||
// matter what order the deprecated setters are called in.
|
||||
CheckCondition(rocksdb_block_based_table_index_mode_standard_default ==
|
||||
rocksdb_block_based_options_get_index_mode(bbo));
|
||||
rocksdb_block_based_options_set_use_udi_as_primary_index(bbo, 1);
|
||||
CheckCondition(rocksdb_block_based_table_index_mode_custom_default ==
|
||||
rocksdb_block_based_options_get_index_mode(bbo));
|
||||
rocksdb_block_based_options_set_index_mode(
|
||||
bbo, rocksdb_block_based_table_index_mode_custom_only);
|
||||
CheckCondition(rocksdb_block_based_table_index_mode_custom_only ==
|
||||
rocksdb_block_based_options_get_index_mode(bbo));
|
||||
rocksdb_block_based_options_set_index_mode(
|
||||
bbo, rocksdb_block_based_table_index_mode_standard_only);
|
||||
rocksdb_block_based_options_set_fail_if_no_udi_on_open(bbo, 1);
|
||||
CheckCondition(rocksdb_block_based_table_index_mode_standard_only ==
|
||||
rocksdb_block_based_options_get_index_mode(bbo));
|
||||
rocksdb_block_based_options_set_use_udi_as_primary_index(bbo, 0);
|
||||
rocksdb_block_based_options_set_fail_if_no_udi_on_open(bbo, 0);
|
||||
|
||||
rocksdb_block_based_options_destroy(bbo);
|
||||
}
|
||||
@@ -4842,24 +4677,6 @@ int main(int argc, char** argv) {
|
||||
CheckCondition(table_index_factory_name == NULL);
|
||||
CheckCondition(table_index_factory_name_len == 0);
|
||||
|
||||
// read_index: set_table_index_factory_from_string implies prefer_custom;
|
||||
// clearing it returns to default; the explicit setter reaches builtin,
|
||||
// which the legacy factory shim cannot express.
|
||||
CheckCondition(rocksdb_readoptions_read_index_default ==
|
||||
rocksdb_readoptions_get_read_index(ro));
|
||||
rocksdb_readoptions_set_read_index(ro,
|
||||
rocksdb_readoptions_read_index_builtin);
|
||||
CheckCondition(rocksdb_readoptions_read_index_builtin ==
|
||||
rocksdb_readoptions_get_read_index(ro));
|
||||
rocksdb_readoptions_set_table_index_factory_from_string(ro, "trie_index",
|
||||
10, &err);
|
||||
CheckNoError(err);
|
||||
CheckCondition(rocksdb_readoptions_read_index_prefer_custom ==
|
||||
rocksdb_readoptions_get_read_index(ro));
|
||||
rocksdb_readoptions_clear_table_index_factory(ro);
|
||||
CheckCondition(rocksdb_readoptions_read_index_default ==
|
||||
rocksdb_readoptions_get_read_index(ro));
|
||||
|
||||
// optimize_multiget_for_io defaults to true (1); flip to 0 to verify the
|
||||
// setter is wired through to the underlying C++ ReadOptions field.
|
||||
CheckCondition(1 == rocksdb_readoptions_get_optimize_multiget_for_io(ro));
|
||||
@@ -5770,9 +5587,6 @@ int main(int argc, char** argv) {
|
||||
CheckNoError(err);
|
||||
}
|
||||
|
||||
StartPhase("transactiondb_batched_multi_get");
|
||||
TestTxnDBBatchedMultiGet();
|
||||
|
||||
StartPhase("transactions");
|
||||
{
|
||||
rocksdb_close(db);
|
||||
|
||||
@@ -26,8 +26,6 @@ class CoalescingIterator : public Iterator {
|
||||
// No copy allowed
|
||||
CoalescingIterator(const CoalescingIterator&) = delete;
|
||||
CoalescingIterator& operator=(const CoalescingIterator&) = delete;
|
||||
CoalescingIterator(CoalescingIterator&&) = delete;
|
||||
CoalescingIterator& operator=(CoalescingIterator&&) = delete;
|
||||
|
||||
bool Valid() const override { return impl_.Valid(); }
|
||||
void SeekToFirst() override { impl_.SeekToFirst(); }
|
||||
|
||||
+12
-44
@@ -475,9 +475,6 @@ ColumnFamilyOptions SanitizeCfOptions(const ImmutableDBOptions& db_options,
|
||||
result.preclude_last_level_data_seconds > 0)) {
|
||||
// With no writes coming in, we don't need periodic SeqnoToTime entries.
|
||||
// Existing SST files may or may not have that info associated with them.
|
||||
// Remote compaction runs in a secondary (read-only) instance but writes
|
||||
// files, so it restores both from the primary. See
|
||||
// DBImplSecondary::CompactWithoutInstallation().
|
||||
ROCKS_LOG_WARN(
|
||||
db_options.info_log.get(),
|
||||
"preserve_internal_time_seconds and preclude_last_level_data_seconds "
|
||||
@@ -616,8 +613,7 @@ ColumnFamilyData::ColumnFamilyData(
|
||||
const FileOptions* file_options, ColumnFamilySet* column_family_set,
|
||||
BlockCacheTracer* const block_cache_tracer,
|
||||
const std::shared_ptr<IOTracer>& io_tracer, const std::string& db_id,
|
||||
const std::string& db_session_id, bool read_only,
|
||||
bool options_are_sanitized, bool fast_sst_open)
|
||||
const std::string& db_session_id, bool read_only, bool fast_sst_open)
|
||||
: id_(id),
|
||||
name_(name),
|
||||
dummy_versions_(_dummy_versions),
|
||||
@@ -627,16 +623,11 @@ ColumnFamilyData::ColumnFamilyData(
|
||||
dropped_(false),
|
||||
flush_skip_reschedule_(false),
|
||||
internal_comparator_(cf_options.comparator),
|
||||
initial_cf_options_(
|
||||
options_are_sanitized
|
||||
? cf_options
|
||||
: SanitizeCfOptions(db_options, read_only, cf_options)),
|
||||
initial_cf_options_(SanitizeCfOptions(db_options, read_only, cf_options)),
|
||||
ioptions_(db_options, initial_cf_options_),
|
||||
mutable_cf_options_(initial_cf_options_),
|
||||
is_delete_range_supported_(
|
||||
cf_options.table_factory->IsDeleteRangeSupported()),
|
||||
is_table_builder_supported_(
|
||||
cf_options.table_factory->IsTableBuilderSupported()),
|
||||
write_buffer_manager_(write_buffer_manager),
|
||||
mem_(nullptr),
|
||||
imm_(ioptions_.min_write_buffer_number_to_merge,
|
||||
@@ -1027,16 +1018,13 @@ ColumnFamilyData::GetWriteStallConditionAndCause(
|
||||
int num_unflushed_memtables, int num_l0_files,
|
||||
uint64_t num_compaction_needed_bytes,
|
||||
const MutableCFOptions& mutable_cf_options,
|
||||
const ImmutableCFOptions& immutable_cf_options,
|
||||
bool table_builder_supported) {
|
||||
const bool auto_compactions =
|
||||
table_builder_supported && !mutable_cf_options.disable_auto_compactions;
|
||||
const ImmutableCFOptions& immutable_cf_options) {
|
||||
if (num_unflushed_memtables >= mutable_cf_options.max_write_buffer_number) {
|
||||
return {WriteStallCondition::kStopped, WriteStallCause::kMemtableLimit};
|
||||
} else if (auto_compactions &&
|
||||
} else if (!mutable_cf_options.disable_auto_compactions &&
|
||||
num_l0_files >= mutable_cf_options.level0_stop_writes_trigger) {
|
||||
return {WriteStallCondition::kStopped, WriteStallCause::kL0FileCountLimit};
|
||||
} else if (auto_compactions &&
|
||||
} else if (!mutable_cf_options.disable_auto_compactions &&
|
||||
mutable_cf_options.hard_pending_compaction_bytes_limit > 0 &&
|
||||
num_compaction_needed_bytes >=
|
||||
mutable_cf_options.hard_pending_compaction_bytes_limit) {
|
||||
@@ -1048,12 +1036,12 @@ ColumnFamilyData::GetWriteStallConditionAndCause(
|
||||
num_unflushed_memtables - 1 >=
|
||||
immutable_cf_options.min_write_buffer_number_to_merge) {
|
||||
return {WriteStallCondition::kDelayed, WriteStallCause::kMemtableLimit};
|
||||
} else if (auto_compactions &&
|
||||
} else if (!mutable_cf_options.disable_auto_compactions &&
|
||||
mutable_cf_options.level0_slowdown_writes_trigger >= 0 &&
|
||||
num_l0_files >=
|
||||
mutable_cf_options.level0_slowdown_writes_trigger) {
|
||||
return {WriteStallCondition::kDelayed, WriteStallCause::kL0FileCountLimit};
|
||||
} else if (auto_compactions &&
|
||||
} else if (!mutable_cf_options.disable_auto_compactions &&
|
||||
mutable_cf_options.soft_pending_compaction_bytes_limit > 0 &&
|
||||
num_compaction_needed_bytes >=
|
||||
mutable_cf_options.soft_pending_compaction_bytes_limit) {
|
||||
@@ -1075,7 +1063,7 @@ WriteStallCondition ColumnFamilyData::RecalculateWriteStallConditions(
|
||||
auto write_stall_condition_and_cause = GetWriteStallConditionAndCause(
|
||||
imm()->NumNotFlushed(), vstorage->l0_delay_trigger_count(),
|
||||
vstorage->estimated_compaction_needed_bytes(), mutable_cf_options,
|
||||
ioptions(), is_table_builder_supported_);
|
||||
ioptions());
|
||||
write_stall_condition = write_stall_condition_and_cause.first;
|
||||
auto write_stall_cause = write_stall_condition_and_cause.second;
|
||||
|
||||
@@ -1281,8 +1269,7 @@ void ColumnFamilyData::CreateNewMemtable(SequenceNumber earliest_seq) {
|
||||
}
|
||||
|
||||
bool ColumnFamilyData::NeedsCompaction() const {
|
||||
return is_table_builder_supported_ &&
|
||||
!mutable_cf_options_.disable_auto_compactions &&
|
||||
return !mutable_cf_options_.disable_auto_compactions &&
|
||||
compaction_picker_->NeedsCompaction(current_->storage_info());
|
||||
}
|
||||
|
||||
@@ -1547,13 +1534,6 @@ Status ColumnFamilyData::ValidateOptions(
|
||||
return s;
|
||||
}
|
||||
|
||||
if (!cf_options.table_factory->IsTableBuilderSupported() &&
|
||||
!cf_options.disallow_memtable_writes) {
|
||||
return Status::InvalidArgument(
|
||||
"A table factory that cannot build tables requires "
|
||||
"disallow_memtable_writes");
|
||||
}
|
||||
|
||||
if (cf_options.ttl > 0 && cf_options.ttl != kDefaultTtl) {
|
||||
if (!cf_options.table_factory->IsInstanceOf(
|
||||
TableFactory::kBlockBasedTableName())) {
|
||||
@@ -1754,21 +1734,10 @@ Status ColumnFamilyData::SetOptions(
|
||||
if (s.ok()) {
|
||||
mutable_cf_options_ = MutableCFOptions(cf_opts);
|
||||
mutable_cf_options_.RefreshDerivedOptions(ioptions_);
|
||||
options_install_pending_ = true;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
bool ColumnFamilyData::SetOptionsIsNoOp(
|
||||
const DBOptions& db_opts,
|
||||
const std::unordered_map<std::string, std::string>& options_map) const {
|
||||
// SetOptions() validates the resulting options, so a request that changes
|
||||
// nothing must pass the same check to return the same status.
|
||||
return !IsDropped() && !options_install_pending_ &&
|
||||
MutableCFOptionsUnchangedByMap(mutable_cf_options_, options_map) &&
|
||||
ValidateOptions(db_opts, GetLatestCFOptions()).ok();
|
||||
}
|
||||
|
||||
Status ColumnFamilyData::AddDirectories(
|
||||
std::map<std::string, std::shared_ptr<FSDirectory>>* created_dirs) {
|
||||
Status s;
|
||||
@@ -1869,7 +1838,7 @@ ColumnFamilySet::ColumnFamilySet(
|
||||
ColumnFamilyData::kDummyColumnFamilyDataId, "", nullptr, nullptr,
|
||||
nullptr, ColumnFamilyOptions(), *db_options, &file_options_, nullptr,
|
||||
block_cache_tracer, io_tracer, db_id, db_session_id,
|
||||
/*read_only=*/true, /*options_are_sanitized=*/false)),
|
||||
/*read_only*/ true)),
|
||||
default_cfd_cache_(nullptr),
|
||||
db_name_(dbname),
|
||||
db_options_(db_options),
|
||||
@@ -2038,13 +2007,12 @@ void ColumnFamilySet::EndBulkFlushableMemAccountingUpdate() {
|
||||
// under a DB mutex AND write thread
|
||||
ColumnFamilyData* ColumnFamilySet::CreateColumnFamily(
|
||||
const std::string& name, uint32_t id, Version* dummy_versions,
|
||||
const ColumnFamilyOptions& options, bool read_only,
|
||||
bool options_are_sanitized) {
|
||||
const ColumnFamilyOptions& options, bool read_only) {
|
||||
assert(column_families_.find(name) == column_families_.end());
|
||||
ColumnFamilyData* new_cfd = new ColumnFamilyData(
|
||||
id, name, dummy_versions, table_cache_, write_buffer_manager_, options,
|
||||
*db_options_, &file_options_, this, block_cache_tracer_, io_tracer_,
|
||||
db_id_, db_session_id_, read_only, options_are_sanitized, fast_sst_open_);
|
||||
db_id_, db_session_id_, read_only, fast_sst_open_);
|
||||
column_families_.insert({name, id});
|
||||
column_family_data_.insert({id, new_cfd});
|
||||
auto ucmp = new_cfd->user_comparator();
|
||||
|
||||
+18
-50
@@ -171,7 +171,7 @@ class ColumnFamilyHandleImpl : public ColumnFamilyHandle {
|
||||
ColumnFamilyHandleImpl(ColumnFamilyData* cfd, DBImpl* db,
|
||||
InstrumentedMutex* mutex);
|
||||
// destroy without mutex
|
||||
~ColumnFamilyHandleImpl() override;
|
||||
virtual ~ColumnFamilyHandleImpl();
|
||||
virtual ColumnFamilyData* cfd() const { return cfd_; }
|
||||
virtual DBImpl* db() const { return db_; }
|
||||
|
||||
@@ -368,12 +368,6 @@ class ColumnFamilyData {
|
||||
|
||||
bool is_delete_range_supported() { return is_delete_range_supported_; }
|
||||
|
||||
// False when the table factory cannot write tables, so the column family is
|
||||
// never compacted.
|
||||
bool is_table_builder_supported() const {
|
||||
return is_table_builder_supported_;
|
||||
}
|
||||
|
||||
// Validate CF options against DB options
|
||||
static Status ValidateOptions(const DBOptions& db_options,
|
||||
const ColumnFamilyOptions& cf_options);
|
||||
@@ -381,19 +375,6 @@ class ColumnFamilyData {
|
||||
Status SetOptions(
|
||||
const DBOptions& db_options,
|
||||
const std::unordered_map<std::string, std::string>& options_map);
|
||||
// REQUIRES: DB mutex held
|
||||
// Returns true if the column family is not dropped, SetOptions(db_options,
|
||||
// options_map) would succeed without changing any option, and options from
|
||||
// an earlier SetOptions() are not still waiting for MarkOptionsInstalled().
|
||||
// Can return false for a request that changes nothing, for example one that
|
||||
// sets a table factory field.
|
||||
bool SetOptionsIsNoOp(
|
||||
const DBOptions& db_options,
|
||||
const std::unordered_map<std::string, std::string>& options_map) const;
|
||||
// REQUIRES: DB mutex held
|
||||
// Call after the options from SetOptions() are in the current SuperVersion
|
||||
// and every other user of them is updated.
|
||||
void MarkOptionsInstalled() { options_install_pending_ = false; }
|
||||
|
||||
InternalStats* internal_stats() { return internal_stats_.get(); }
|
||||
|
||||
@@ -568,15 +549,12 @@ class ColumnFamilyData {
|
||||
--num_in_flight_compactions_;
|
||||
}
|
||||
|
||||
// L0 files and pending compaction bytes stall writes only when the column
|
||||
// family can be compacted automatically, which requires
|
||||
// 'table_builder_supported' and no disable_auto_compactions.
|
||||
static std::pair<WriteStallCondition, WriteStallCause>
|
||||
GetWriteStallConditionAndCause(int num_unflushed_memtables, int num_l0_files,
|
||||
uint64_t num_compaction_needed_bytes,
|
||||
const MutableCFOptions& mutable_cf_options,
|
||||
const ImmutableCFOptions& immutable_cf_options,
|
||||
bool table_builder_supported);
|
||||
GetWriteStallConditionAndCause(
|
||||
int num_unflushed_memtables, int num_l0_files,
|
||||
uint64_t num_compaction_needed_bytes,
|
||||
const MutableCFOptions& mutable_cf_options,
|
||||
const ImmutableCFOptions& immutable_cf_options);
|
||||
|
||||
// Recalculate some stall conditions, which are changed only during
|
||||
// compaction, adding new memtable and/or recalculation of compaction score.
|
||||
@@ -676,15 +654,17 @@ class ColumnFamilyData {
|
||||
|
||||
private:
|
||||
friend class ColumnFamilySet;
|
||||
ColumnFamilyData(
|
||||
uint32_t id, const std::string& name, Version* dummy_versions,
|
||||
Cache* table_cache, WriteBufferManager* write_buffer_manager,
|
||||
const ColumnFamilyOptions& options, const ImmutableDBOptions& db_options,
|
||||
const FileOptions* file_options, ColumnFamilySet* column_family_set,
|
||||
BlockCacheTracer* const block_cache_tracer,
|
||||
const std::shared_ptr<IOTracer>& io_tracer, const std::string& db_id,
|
||||
const std::string& db_session_id, bool read_only,
|
||||
bool options_are_sanitized, bool fast_sst_open = false);
|
||||
ColumnFamilyData(uint32_t id, const std::string& name,
|
||||
Version* dummy_versions, Cache* table_cache,
|
||||
WriteBufferManager* write_buffer_manager,
|
||||
const ColumnFamilyOptions& options,
|
||||
const ImmutableDBOptions& db_options,
|
||||
const FileOptions* file_options,
|
||||
ColumnFamilySet* column_family_set,
|
||||
BlockCacheTracer* const block_cache_tracer,
|
||||
const std::shared_ptr<IOTracer>& io_tracer,
|
||||
const std::string& db_id, const std::string& db_session_id,
|
||||
bool read_only, bool fast_sst_open = false);
|
||||
|
||||
std::vector<std::string> GetDbPaths() const;
|
||||
|
||||
@@ -714,12 +694,6 @@ class ColumnFamilyData {
|
||||
MutableCFOptions mutable_cf_options_;
|
||||
|
||||
const bool is_delete_range_supported_;
|
||||
const bool is_table_builder_supported_;
|
||||
|
||||
// True from a successful SetOptions() until MarkOptionsInstalled(). A
|
||||
// DB::SetOptions() call that fails on a later column family leaves it set
|
||||
// for the column families it already changed.
|
||||
bool options_install_pending_ = false;
|
||||
|
||||
std::unique_ptr<TableCache> table_cache_;
|
||||
std::unique_ptr<BlobFileCache> blob_file_cache_;
|
||||
@@ -876,8 +850,7 @@ class ColumnFamilySet {
|
||||
ColumnFamilyData* CreateColumnFamily(const std::string& name, uint32_t id,
|
||||
Version* dummy_version,
|
||||
const ColumnFamilyOptions& options,
|
||||
bool read_only,
|
||||
bool options_are_sanitized);
|
||||
bool read_only);
|
||||
|
||||
const UnorderedMap<uint32_t, size_t>& GetRunningColumnFamiliesTimestampSize()
|
||||
const {
|
||||
@@ -978,11 +951,6 @@ class RefedColumnFamilySet {
|
||||
explicit iterator(ColumnFamilySet::iterator wrapped) : wrapped_(wrapped) {
|
||||
MaybeRef(*wrapped_);
|
||||
}
|
||||
// No copying allowed
|
||||
iterator(const iterator&) = delete;
|
||||
iterator& operator=(const iterator&) = delete;
|
||||
iterator(iterator&&) = delete;
|
||||
iterator& operator=(iterator&&) = delete;
|
||||
~iterator() { MaybeUnref(*wrapped_); }
|
||||
inline void MaybeRef(ColumnFamilyData* cfd) {
|
||||
if (cfd->GetID() != ColumnFamilyData::kDummyColumnFamilyDataId) {
|
||||
|
||||
+39
-519
@@ -25,7 +25,6 @@
|
||||
#include "rocksdb/iterator.h"
|
||||
#include "rocksdb/listener.h"
|
||||
#include "rocksdb/utilities/object_registry.h"
|
||||
#include "rocksdb/utilities/options_util.h"
|
||||
#include "test_util/sync_point.h"
|
||||
#include "test_util/testharness.h"
|
||||
#include "test_util/testutil.h"
|
||||
@@ -33,7 +32,6 @@
|
||||
#include "util/defer.h"
|
||||
#include "util/string_util.h"
|
||||
#include "utilities/fault_injection_env.h"
|
||||
#include "utilities/fault_injection_fs.h"
|
||||
#include "utilities/merge_operators.h"
|
||||
|
||||
namespace ROCKSDB_NAMESPACE {
|
||||
@@ -115,8 +113,7 @@ class ColumnFamilyTestBase : public testing::Test {
|
||||
}
|
||||
|
||||
void Build(int base, int n, int flush_every = 0) {
|
||||
std::string key_space;
|
||||
std::string value_space;
|
||||
std::string key_space, value_space;
|
||||
WriteBatch batch;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
@@ -182,35 +179,6 @@ class ColumnFamilyTestBase : public testing::Test {
|
||||
db_.reset();
|
||||
}
|
||||
|
||||
void AssertColumnFamilyNames(const std::vector<std::string>& expected) {
|
||||
std::vector<std::string> column_families;
|
||||
ASSERT_OK(DB::ListColumnFamilies(db_options_, dbname_, &column_families));
|
||||
ASSERT_EQ(expected, column_families);
|
||||
}
|
||||
|
||||
void LoadLatestColumnFamilyDescriptors(
|
||||
std::vector<ColumnFamilyDescriptor>* descriptors) {
|
||||
ConfigOptions config_options;
|
||||
config_options.env = db_options_.env;
|
||||
DBOptions loaded_db_options;
|
||||
ASSERT_OK(LoadLatestOptions(config_options, dbname_, &loaded_db_options,
|
||||
descriptors));
|
||||
}
|
||||
|
||||
size_t CountOptionsFiles() {
|
||||
std::vector<std::string> children;
|
||||
EXPECT_OK(db_options_.env->GetChildren(dbname_, &children));
|
||||
size_t count = 0;
|
||||
for (const auto& child : children) {
|
||||
uint64_t number = 0;
|
||||
FileType type;
|
||||
if (ParseFileName(child, &number, &type) && type == kOptionsFile) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
Status TryOpen(std::vector<std::string> cf,
|
||||
std::vector<ColumnFamilyOptions> options = {}) {
|
||||
std::vector<ColumnFamilyDescriptor> column_families;
|
||||
@@ -468,6 +436,7 @@ class ColumnFamilyTestBase : public testing::Test {
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AssertCountLiveLogFiles(int value) {
|
||||
@@ -545,9 +514,8 @@ class ColumnFamilyTest
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(FormatDef, ColumnFamilyTest,
|
||||
testing::Values(test::kDefaultFormatVersion));
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
FormatLatest, ColumnFamilyTest,
|
||||
testing::Values(BlockBasedTableOptions::kLatestSupportedFormatVersion));
|
||||
INSTANTIATE_TEST_CASE_P(FormatLatest, ColumnFamilyTest,
|
||||
testing::Values(kLatestBbtFormatVersion));
|
||||
|
||||
TEST_P(ColumnFamilyTest, DontReuseColumnFamilyID) {
|
||||
for (int iter = 0; iter < 3; ++iter) {
|
||||
@@ -737,11 +705,8 @@ INSTANTIATE_TEST_CASE_P(
|
||||
std::make_tuple(test::kDefaultFormatVersion, false)));
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
FormatLatest, FlushEmptyCFTestWithParam,
|
||||
testing::Values(
|
||||
std::make_tuple(BlockBasedTableOptions::kLatestSupportedFormatVersion,
|
||||
true),
|
||||
std::make_tuple(BlockBasedTableOptions::kLatestSupportedFormatVersion,
|
||||
false)));
|
||||
testing::Values(std::make_tuple(kLatestBbtFormatVersion, true),
|
||||
std::make_tuple(kLatestBbtFormatVersion, false)));
|
||||
|
||||
TEST_P(ColumnFamilyTest, AddDrop) {
|
||||
Open();
|
||||
@@ -805,26 +770,6 @@ TEST_P(ColumnFamilyTest, EmptyNameRejected) {
|
||||
ASSERT_TRUE(handles.empty());
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, CreateRejectsOptionsThatOpenRejects) {
|
||||
// CreateColumnFamily() used to skip the table factory checks of DB::Open, so
|
||||
// it persisted a column family that made the next DB::Open fail.
|
||||
Open();
|
||||
ColumnFamilyOptions hash_index_options = column_family_options_;
|
||||
BlockBasedTableOptions table_options;
|
||||
table_options.index_type = BlockBasedTableOptions::kHashSearch;
|
||||
hash_index_options.table_factory.reset(
|
||||
NewBlockBasedTableFactory(table_options));
|
||||
hash_index_options.prefix_extractor.reset();
|
||||
ColumnFamilyHandle* handle = nullptr;
|
||||
Status s = db_->CreateColumnFamily(hash_index_options, "hash_index", &handle);
|
||||
ASSERT_TRUE(s.IsInvalidArgument()) << s.ToString();
|
||||
ASSERT_EQ(handle, nullptr);
|
||||
|
||||
Close();
|
||||
AssertColumnFamilyNames({kDefaultColumnFamilyName});
|
||||
ASSERT_OK(TryOpen({kDefaultColumnFamilyName}));
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, BulkAddDrop) {
|
||||
constexpr int kNumCF = 1000;
|
||||
ColumnFamilyOptions cf_options;
|
||||
@@ -972,9 +917,7 @@ TEST_P(ColumnFamilyTest, IgnoreRecoveredLog) {
|
||||
CreateColumnFamilies({"cf1", "cf2"});
|
||||
|
||||
// fill up the DB
|
||||
std::string one;
|
||||
std::string two;
|
||||
std::string three;
|
||||
std::string one, two, three;
|
||||
PutFixed64(&one, 1);
|
||||
PutFixed64(&two, 2);
|
||||
PutFixed64(&three, 3);
|
||||
@@ -1182,10 +1125,7 @@ TEST_P(ColumnFamilyTest, DifferentWriteBufferSizes) {
|
||||
db_options_.max_total_wal_size = std::numeric_limits<uint64_t>::max();
|
||||
Open();
|
||||
CreateColumnFamilies({"one", "two", "three"});
|
||||
ColumnFamilyOptions default_cf;
|
||||
ColumnFamilyOptions one;
|
||||
ColumnFamilyOptions two;
|
||||
ColumnFamilyOptions three;
|
||||
ColumnFamilyOptions default_cf, one, two, three;
|
||||
// setup options. all column families have max_write_buffer_number setup to 10
|
||||
// "default" -> 100KB memtable, start flushing immediately
|
||||
// "one" -> 200KB memtable, start flushing with two immutable memtables
|
||||
@@ -1337,9 +1277,7 @@ TEST_P(ColumnFamilyTest, GetComparator) {
|
||||
|
||||
// Add three column families - one with no comparator and two
|
||||
// with comparators specified
|
||||
ColumnFamilyOptions second;
|
||||
ColumnFamilyOptions third;
|
||||
ColumnFamilyOptions fourth;
|
||||
ColumnFamilyOptions second, third, fourth;
|
||||
second.comparator = &third_comparator;
|
||||
third.comparator = &fourth_comparator;
|
||||
CreateColumnFamilies({"second", "third", "fourth"}, {second, third, fourth});
|
||||
@@ -1352,16 +1290,12 @@ TEST_P(ColumnFamilyTest, GetComparator) {
|
||||
TEST_P(ColumnFamilyTest, DifferentMergeOperators) {
|
||||
Open();
|
||||
CreateColumnFamilies({"first", "second"});
|
||||
ColumnFamilyOptions default_cf;
|
||||
ColumnFamilyOptions first;
|
||||
ColumnFamilyOptions second;
|
||||
ColumnFamilyOptions default_cf, first, second;
|
||||
first.merge_operator = MergeOperators::CreateUInt64AddOperator();
|
||||
second.merge_operator = MergeOperators::CreateStringAppendOperator();
|
||||
Reopen({default_cf, first, second});
|
||||
|
||||
std::string one;
|
||||
std::string two;
|
||||
std::string three;
|
||||
std::string one, two, three;
|
||||
PutFixed64(&one, 1);
|
||||
PutFixed64(&two, 2);
|
||||
PutFixed64(&three, 3);
|
||||
@@ -1386,9 +1320,7 @@ TEST_P(ColumnFamilyTest, DifferentMergeOperators) {
|
||||
TEST_P(ColumnFamilyTest, DifferentCompactionStyles) {
|
||||
Open();
|
||||
CreateColumnFamilies({"one", "two"});
|
||||
ColumnFamilyOptions default_cf;
|
||||
ColumnFamilyOptions one;
|
||||
ColumnFamilyOptions two;
|
||||
ColumnFamilyOptions default_cf, one, two;
|
||||
db_options_.max_open_files = 20; // only 10 files in file cache
|
||||
|
||||
default_cf.level_compaction_dynamic_level_bytes = false;
|
||||
@@ -1460,9 +1392,7 @@ TEST_P(ColumnFamilyTest, DifferentCompactionStyles) {
|
||||
TEST_P(ColumnFamilyTest, MultipleManualCompactions) {
|
||||
Open();
|
||||
CreateColumnFamilies({"one", "two"});
|
||||
ColumnFamilyOptions default_cf;
|
||||
ColumnFamilyOptions one;
|
||||
ColumnFamilyOptions two;
|
||||
ColumnFamilyOptions default_cf, one, two;
|
||||
db_options_.max_open_files = 20; // only 10 files in file cache
|
||||
db_options_.max_background_compactions = 3;
|
||||
|
||||
@@ -1562,9 +1492,7 @@ TEST_P(ColumnFamilyTest, MultipleManualCompactions) {
|
||||
TEST_P(ColumnFamilyTest, AutomaticAndManualCompactions) {
|
||||
Open();
|
||||
CreateColumnFamilies({"one", "two"});
|
||||
ColumnFamilyOptions default_cf;
|
||||
ColumnFamilyOptions one;
|
||||
ColumnFamilyOptions two;
|
||||
ColumnFamilyOptions default_cf, one, two;
|
||||
db_options_.max_open_files = 20; // only 10 files in file cache
|
||||
db_options_.max_background_compactions = 3;
|
||||
|
||||
@@ -1661,9 +1589,7 @@ TEST_P(ColumnFamilyTest, AutomaticAndManualCompactions) {
|
||||
TEST_P(ColumnFamilyTest, ManualAndAutomaticCompactions) {
|
||||
Open();
|
||||
CreateColumnFamilies({"one", "two"});
|
||||
ColumnFamilyOptions default_cf;
|
||||
ColumnFamilyOptions one;
|
||||
ColumnFamilyOptions two;
|
||||
ColumnFamilyOptions default_cf, one, two;
|
||||
db_options_.max_open_files = 20; // only 10 files in file cache
|
||||
db_options_.max_background_compactions = 3;
|
||||
|
||||
@@ -1762,8 +1688,7 @@ TEST_P(ColumnFamilyTest, ManualAndAutomaticCompactions) {
|
||||
TEST_P(ColumnFamilyTest, SameCFManualManualCompactions) {
|
||||
Open();
|
||||
CreateColumnFamilies({"one"});
|
||||
ColumnFamilyOptions default_cf;
|
||||
ColumnFamilyOptions one;
|
||||
ColumnFamilyOptions default_cf, one;
|
||||
db_options_.max_open_files = 20; // only 10 files in file cache
|
||||
db_options_.max_background_compactions = 3;
|
||||
|
||||
@@ -1863,8 +1788,7 @@ TEST_P(ColumnFamilyTest, SameCFManualManualCompactions) {
|
||||
TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactions) {
|
||||
Open();
|
||||
CreateColumnFamilies({"one"});
|
||||
ColumnFamilyOptions default_cf;
|
||||
ColumnFamilyOptions one;
|
||||
ColumnFamilyOptions default_cf, one;
|
||||
db_options_.max_open_files = 20; // only 10 files in file cache
|
||||
db_options_.max_background_compactions = 3;
|
||||
|
||||
@@ -1955,8 +1879,7 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactions) {
|
||||
TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactionsLevel) {
|
||||
Open();
|
||||
CreateColumnFamilies({"one"});
|
||||
ColumnFamilyOptions default_cf;
|
||||
ColumnFamilyOptions one;
|
||||
ColumnFamilyOptions default_cf, one;
|
||||
db_options_.max_open_files = 20; // only 10 files in file cache
|
||||
db_options_.max_background_compactions = 3;
|
||||
|
||||
@@ -2053,8 +1976,7 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactionsLevel) {
|
||||
TEST_P(ColumnFamilyTest, SameCFAutomaticManualCompactions) {
|
||||
Open();
|
||||
CreateColumnFamilies({"one"});
|
||||
ColumnFamilyOptions default_cf;
|
||||
ColumnFamilyOptions one;
|
||||
ColumnFamilyOptions default_cf, one;
|
||||
db_options_.max_open_files = 20; // only 10 files in file cache
|
||||
db_options_.max_background_compactions = 3;
|
||||
|
||||
@@ -2267,9 +2189,7 @@ TEST_P(ColumnFamilyTest, DontRollEmptyLogs) {
|
||||
TEST_P(ColumnFamilyTest, FlushStaleColumnFamilies) {
|
||||
Open();
|
||||
CreateColumnFamilies({"one", "two"});
|
||||
ColumnFamilyOptions default_cf;
|
||||
ColumnFamilyOptions one;
|
||||
ColumnFamilyOptions two;
|
||||
ColumnFamilyOptions default_cf, one, two;
|
||||
default_cf.write_buffer_size = 100000; // small write buffer size
|
||||
default_cf.arena_block_size = 4096;
|
||||
default_cf.disable_auto_compactions = true;
|
||||
@@ -2330,378 +2250,8 @@ struct CountOptionsFilesFs : public FileSystemWrapper {
|
||||
|
||||
std::atomic<int> options_files_created{};
|
||||
};
|
||||
|
||||
struct FailOptionsFilesFs : public FileSystemWrapper {
|
||||
explicit FailOptionsFilesFs(const std::shared_ptr<FileSystem>& t)
|
||||
: FileSystemWrapper(t) {}
|
||||
const char* Name() const override { return "FailOptionsFilesFs"; }
|
||||
|
||||
IOStatus NewWritableFile(const std::string& f, const FileOptions& file_opts,
|
||||
std::unique_ptr<FSWritableFile>* r,
|
||||
IODebugContext* dbg) override {
|
||||
if (fail_options_writes.load(std::memory_order_relaxed) &&
|
||||
f.find("OPTIONS-") != std::string::npos) {
|
||||
return IOStatus::IOError("injected OPTIONS-file creation failure");
|
||||
}
|
||||
return FileSystemWrapper::NewWritableFile(f, file_opts, r, dbg);
|
||||
}
|
||||
|
||||
std::atomic<bool> fail_options_writes{false};
|
||||
};
|
||||
} // namespace
|
||||
|
||||
TEST_P(ColumnFamilyTest, TrackedOptionsWriteFailureDoesNotChangeManifest) {
|
||||
db_options_.track_options_file_number_in_manifest = true;
|
||||
db_options_.max_manifest_file_size = 1;
|
||||
db_options_.max_manifest_space_amp_pct = 0;
|
||||
auto fail_fs =
|
||||
std::make_shared<FailOptionsFilesFs>(db_options_.env->GetFileSystem());
|
||||
auto fail_env =
|
||||
std::make_unique<CompositeEnvWrapper>(db_options_.env, fail_fs);
|
||||
SaveAndRestore<Env*> save_restore_env(&db_options_.env, fail_env.get());
|
||||
|
||||
Open();
|
||||
OptionsFileManifestState before_failure;
|
||||
ASSERT_OK(VersionSet::GetOptionsFileManifestState(
|
||||
dbname_, db_options_.env->GetFileSystem().get(), &before_failure));
|
||||
fail_fs->fail_options_writes.store(true, std::memory_order_relaxed);
|
||||
ColumnFamilyHandle* handle = nullptr;
|
||||
ASSERT_NOK(db_->CreateColumnFamily(ColumnFamilyOptions(), "one", &handle));
|
||||
ASSERT_EQ(nullptr, handle);
|
||||
fail_fs->fail_options_writes.store(false, std::memory_order_relaxed);
|
||||
|
||||
OptionsFileManifestState after_failure;
|
||||
ASSERT_OK(VersionSet::GetOptionsFileManifestState(
|
||||
dbname_, db_options_.env->GetFileSystem().get(), &after_failure));
|
||||
ASSERT_EQ(before_failure.has_committed_options_file_number,
|
||||
after_failure.has_committed_options_file_number);
|
||||
ASSERT_EQ(before_failure.committed_options_file_number,
|
||||
after_failure.committed_options_file_number);
|
||||
|
||||
std::vector<ColumnFamilyDescriptor> loaded_cfs;
|
||||
LoadLatestColumnFamilyDescriptors(&loaded_cfs);
|
||||
ASSERT_EQ(1U, loaded_cfs.size());
|
||||
ASSERT_EQ(kDefaultColumnFamilyName, loaded_cfs.front().name);
|
||||
|
||||
const uint64_t old_manifest_number =
|
||||
dbfull()->GetVersionSet()->manifest_file_number();
|
||||
ASSERT_OK(db_->Put(WriteOptions(), "key", "value"));
|
||||
ASSERT_OK(db_->Flush(FlushOptions()));
|
||||
ASSERT_NE(old_manifest_number,
|
||||
dbfull()->GetVersionSet()->manifest_file_number());
|
||||
|
||||
OptionsFileManifestState after_rotation;
|
||||
ASSERT_OK(VersionSet::GetOptionsFileManifestState(
|
||||
dbname_, db_options_.env->GetFileSystem().get(), &after_rotation));
|
||||
ASSERT_EQ(before_failure.has_committed_options_file_number,
|
||||
after_rotation.has_committed_options_file_number);
|
||||
ASSERT_EQ(before_failure.committed_options_file_number,
|
||||
after_rotation.committed_options_file_number);
|
||||
Close();
|
||||
|
||||
AssertColumnFamilyNames({kDefaultColumnFamilyName});
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, TrackedDropFailsBeforeManifestOnOptionsError) {
|
||||
db_options_.track_options_file_number_in_manifest = true;
|
||||
auto fail_fs =
|
||||
std::make_shared<FailOptionsFilesFs>(db_options_.env->GetFileSystem());
|
||||
auto fail_env =
|
||||
std::make_unique<CompositeEnvWrapper>(db_options_.env, fail_fs);
|
||||
SaveAndRestore<Env*> save_restore_env(&db_options_.env, fail_env.get());
|
||||
|
||||
Open();
|
||||
ColumnFamilyHandle* handle = nullptr;
|
||||
ASSERT_OK(db_->CreateColumnFamily(ColumnFamilyOptions(), "one", &handle));
|
||||
ASSERT_NE(nullptr, handle);
|
||||
|
||||
fail_fs->fail_options_writes.store(true, std::memory_order_relaxed);
|
||||
ASSERT_NOK(db_->DropColumnFamily(handle));
|
||||
fail_fs->fail_options_writes.store(false, std::memory_order_relaxed);
|
||||
ASSERT_OK(db_->DestroyColumnFamilyHandle(handle));
|
||||
Close();
|
||||
|
||||
AssertColumnFamilyNames({kDefaultColumnFamilyName, "one"});
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, TrackedManifestFailureKeepsPreviousOptions) {
|
||||
db_options_.track_options_file_number_in_manifest = true;
|
||||
auto fault_fs =
|
||||
std::make_shared<FaultInjectionTestFS>(db_options_.env->GetFileSystem());
|
||||
std::unique_ptr<Env> fault_env(NewCompositeEnv(fault_fs));
|
||||
SaveAndRestore<Env*> save_restore_env(&db_options_.env, fault_env.get());
|
||||
|
||||
Open();
|
||||
std::string selected_options_before;
|
||||
ASSERT_OK(GetLatestOptionsFileName(dbname_, db_options_.env,
|
||||
&selected_options_before));
|
||||
|
||||
std::atomic<bool> inject_error{true};
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"VersionSet::LogAndApply:WriteManifest", [&](void*) {
|
||||
if (inject_error.exchange(false)) {
|
||||
fault_fs->SetThreadLocalErrorContext(
|
||||
FaultInjectionIOType::kWrite, /*seed=*/0, /*one_in=*/1,
|
||||
/*retryable=*/false, /*has_data_loss=*/false);
|
||||
fault_fs->EnableThreadLocalErrorInjection(
|
||||
FaultInjectionIOType::kWrite);
|
||||
}
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
|
||||
ColumnFamilyHandle* handle = nullptr;
|
||||
ASSERT_NOK(db_->CreateColumnFamily(ColumnFamilyOptions(), "one", &handle));
|
||||
ASSERT_EQ(nullptr, handle);
|
||||
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
fault_fs->DisableThreadLocalErrorInjection(FaultInjectionIOType::kWrite);
|
||||
|
||||
std::string selected_options_after;
|
||||
ASSERT_OK(GetLatestOptionsFileName(dbname_, db_options_.env,
|
||||
&selected_options_after));
|
||||
ASSERT_EQ(selected_options_before, selected_options_after);
|
||||
Close();
|
||||
|
||||
AssertColumnFamilyNames({kDefaultColumnFamilyName});
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, FirstTrackedCreateFailureIgnoresUncommittedOptions) {
|
||||
// Create a legacy DB without a committed number, then enable tracking while
|
||||
// Open also
|
||||
// needs to create a missing CF. The current topology must be bound before
|
||||
// the proposed topology OPTIONS file can become a durable orphan.
|
||||
Open();
|
||||
Close();
|
||||
db_options_.track_options_file_number_in_manifest = true;
|
||||
db_options_.create_missing_column_families = true;
|
||||
|
||||
auto fault_fs =
|
||||
std::make_shared<FaultInjectionTestFS>(db_options_.env->GetFileSystem());
|
||||
std::unique_ptr<Env> fault_env(NewCompositeEnv(fault_fs));
|
||||
SaveAndRestore<Env*> save_restore_env(&db_options_.env, fault_env.get());
|
||||
|
||||
bool injected = false;
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"DBImpl::CreateColumnFamilyImpl:AfterPersistOptions", [&](void*) {
|
||||
if (!injected) {
|
||||
injected = true;
|
||||
fault_fs->SetThreadLocalErrorContext(
|
||||
FaultInjectionIOType::kWrite, /*seed=*/0, /*one_in=*/1,
|
||||
/*retryable=*/false, /*has_data_loss=*/false);
|
||||
fault_fs->EnableThreadLocalErrorInjection(
|
||||
FaultInjectionIOType::kWrite);
|
||||
}
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
|
||||
ASSERT_NOK(TryOpen({kDefaultColumnFamilyName, "one"}));
|
||||
ASSERT_TRUE(injected);
|
||||
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
fault_fs->DisableThreadLocalErrorInjection(FaultInjectionIOType::kWrite);
|
||||
|
||||
std::vector<ColumnFamilyDescriptor> loaded_cfs;
|
||||
LoadLatestColumnFamilyDescriptors(&loaded_cfs);
|
||||
ASSERT_EQ(1U, loaded_cfs.size());
|
||||
ASSERT_EQ(kDefaultColumnFamilyName, loaded_cfs.front().name);
|
||||
|
||||
OptionsFileManifestState protocol_state;
|
||||
ASSERT_OK(VersionSet::GetOptionsFileManifestState(
|
||||
dbname_, db_options_.env->GetFileSystem().get(), &protocol_state));
|
||||
ASSERT_TRUE(protocol_state.has_committed_options_file_number);
|
||||
std::string selected_options;
|
||||
ASSERT_OK(
|
||||
GetLatestOptionsFileName(dbname_, db_options_.env, &selected_options));
|
||||
ASSERT_EQ(OptionsFileName(protocol_state.committed_options_file_number),
|
||||
selected_options);
|
||||
|
||||
AssertColumnFamilyNames({kDefaultColumnFamilyName});
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, TrackedCreatePersistsCommittedOptions) {
|
||||
db_options_.track_options_file_number_in_manifest = true;
|
||||
Open();
|
||||
|
||||
ColumnFamilyOptions requested;
|
||||
requested.arena_block_size = 0;
|
||||
ColumnFamilyHandle* handle = nullptr;
|
||||
ASSERT_OK(db_->CreateColumnFamily(requested, "one", &handle));
|
||||
const ColumnFamilyOptions effective = db_->GetOptions(handle);
|
||||
ASSERT_GT(effective.arena_block_size, 0U);
|
||||
|
||||
std::vector<ColumnFamilyDescriptor> loaded_cfs;
|
||||
LoadLatestColumnFamilyDescriptors(&loaded_cfs);
|
||||
ASSERT_EQ(2U, loaded_cfs.size());
|
||||
ASSERT_EQ("one", loaded_cfs[1].name);
|
||||
ASSERT_EQ(effective.arena_block_size, loaded_cfs[1].options.arena_block_size);
|
||||
|
||||
ASSERT_OK(db_->DestroyColumnFamilyHandle(handle));
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, TrackedBatchTopologyWritesOneOptionsSnapshot) {
|
||||
db_options_.track_options_file_number_in_manifest = true;
|
||||
auto count_fs =
|
||||
std::make_shared<CountOptionsFilesFs>(db_options_.env->GetFileSystem());
|
||||
auto count_env =
|
||||
std::make_unique<CompositeEnvWrapper>(db_options_.env, count_fs);
|
||||
SaveAndRestore<Env*> save_restore_env(&db_options_.env, count_env.get());
|
||||
|
||||
Open();
|
||||
count_fs->options_files_created.store(0, std::memory_order_relaxed);
|
||||
std::vector<ColumnFamilyHandle*> handles;
|
||||
ASSERT_OK(db_->CreateColumnFamilies(ColumnFamilyOptions(),
|
||||
{"one", "two", "three"}, &handles));
|
||||
ASSERT_EQ(3U, handles.size());
|
||||
ASSERT_EQ(1, count_fs->options_files_created.load(std::memory_order_relaxed));
|
||||
|
||||
count_fs->options_files_created.store(0, std::memory_order_relaxed);
|
||||
ASSERT_OK(db_->DropColumnFamilies(handles));
|
||||
ASSERT_EQ(1, count_fs->options_files_created.load(std::memory_order_relaxed));
|
||||
for (auto* handle : handles) {
|
||||
ASSERT_OK(db_->DestroyColumnFamilyHandle(handle));
|
||||
}
|
||||
|
||||
std::vector<ColumnFamilyDescriptor> loaded_cfs;
|
||||
LoadLatestColumnFamilyDescriptors(&loaded_cfs);
|
||||
ASSERT_EQ(1U, loaded_cfs.size());
|
||||
ASSERT_EQ(kDefaultColumnFamilyName, loaded_cfs.front().name);
|
||||
Close();
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, TrackedPartialBatchFiltersOptionsSuperset) {
|
||||
db_options_.track_options_file_number_in_manifest = true;
|
||||
auto fault_fs =
|
||||
std::make_shared<FaultInjectionTestFS>(db_options_.env->GetFileSystem());
|
||||
std::unique_ptr<Env> fault_env(NewCompositeEnv(fault_fs));
|
||||
SaveAndRestore<Env*> save_restore_env(&db_options_.env, fault_env.get());
|
||||
|
||||
Open();
|
||||
std::atomic<int> manifest_writes{0};
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"VersionSet::LogAndApply:WriteManifest", [&](void*) {
|
||||
if (manifest_writes.fetch_add(1, std::memory_order_relaxed) == 1) {
|
||||
fault_fs->SetThreadLocalErrorContext(
|
||||
FaultInjectionIOType::kWrite, /*seed=*/0, /*one_in=*/1,
|
||||
/*retryable=*/false, /*has_data_loss=*/false);
|
||||
fault_fs->EnableThreadLocalErrorInjection(
|
||||
FaultInjectionIOType::kWrite);
|
||||
}
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
|
||||
std::vector<ColumnFamilyHandle*> handles;
|
||||
ASSERT_NOK(db_->CreateColumnFamilies(ColumnFamilyOptions(), {"one", "two"},
|
||||
&handles));
|
||||
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
fault_fs->DisableThreadLocalErrorInjection(FaultInjectionIOType::kWrite);
|
||||
ASSERT_EQ(1U, handles.size());
|
||||
|
||||
std::vector<ColumnFamilyDescriptor> loaded_cfs;
|
||||
LoadLatestColumnFamilyDescriptors(&loaded_cfs);
|
||||
ASSERT_EQ(2U, loaded_cfs.size());
|
||||
ASSERT_EQ(kDefaultColumnFamilyName, loaded_cfs[0].name);
|
||||
ASSERT_EQ("one", loaded_cfs[1].name);
|
||||
|
||||
ConfigOptions config_options;
|
||||
config_options.env = db_options_.env;
|
||||
DBOptions loaded_db_options;
|
||||
ASSERT_OK(LoadLatestOptions(config_options, dbname_, &loaded_db_options,
|
||||
&loaded_cfs));
|
||||
ASSERT_OK(CheckOptionsCompatibility(config_options, dbname_,
|
||||
loaded_db_options, loaded_cfs));
|
||||
ASSERT_OK(db_->DestroyColumnFamilyHandle(handles.front()));
|
||||
Close();
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, TrackedPartialBatchDropFiltersOptionsSuperset) {
|
||||
db_options_.track_options_file_number_in_manifest = true;
|
||||
auto fault_fs =
|
||||
std::make_shared<FaultInjectionTestFS>(db_options_.env->GetFileSystem());
|
||||
std::unique_ptr<Env> fault_env(NewCompositeEnv(fault_fs));
|
||||
SaveAndRestore<Env*> save_restore_env(&db_options_.env, fault_env.get());
|
||||
|
||||
Open();
|
||||
std::vector<ColumnFamilyHandle*> handles;
|
||||
ASSERT_OK(db_->CreateColumnFamilies(ColumnFamilyOptions(), {"one", "two"},
|
||||
&handles));
|
||||
ASSERT_EQ(2U, handles.size());
|
||||
|
||||
std::atomic<int> manifest_writes{0};
|
||||
SyncPoint::GetInstance()->SetCallBack(
|
||||
"VersionSet::LogAndApply:WriteManifest", [&](void*) {
|
||||
if (manifest_writes.fetch_add(1, std::memory_order_relaxed) == 1) {
|
||||
fault_fs->SetThreadLocalErrorContext(
|
||||
FaultInjectionIOType::kWrite, /*seed=*/0, /*one_in=*/1,
|
||||
/*retryable=*/false, /*has_data_loss=*/false);
|
||||
fault_fs->EnableThreadLocalErrorInjection(
|
||||
FaultInjectionIOType::kWrite);
|
||||
}
|
||||
});
|
||||
SyncPoint::GetInstance()->EnableProcessing();
|
||||
|
||||
ASSERT_NOK(db_->DropColumnFamilies(handles));
|
||||
|
||||
SyncPoint::GetInstance()->DisableProcessing();
|
||||
SyncPoint::GetInstance()->ClearAllCallBacks();
|
||||
fault_fs->DisableThreadLocalErrorInjection(FaultInjectionIOType::kWrite);
|
||||
|
||||
std::vector<ColumnFamilyDescriptor> loaded_cfs;
|
||||
LoadLatestColumnFamilyDescriptors(&loaded_cfs);
|
||||
ASSERT_EQ(2U, loaded_cfs.size());
|
||||
ASSERT_EQ(kDefaultColumnFamilyName, loaded_cfs[0].name);
|
||||
ASSERT_EQ("two", loaded_cfs[1].name);
|
||||
for (auto* handle : handles) {
|
||||
ASSERT_OK(db_->DestroyColumnFamilyHandle(handle));
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, InvalidTrackedTopologyChangeCreatesNoOptionsOrphan) {
|
||||
db_options_.track_options_file_number_in_manifest = true;
|
||||
Open();
|
||||
|
||||
ColumnFamilyHandle* handle = nullptr;
|
||||
ASSERT_OK(db_->CreateColumnFamily(ColumnFamilyOptions(), "one", &handle));
|
||||
const size_t before_duplicate_create = CountOptionsFiles();
|
||||
ColumnFamilyHandle* duplicate = nullptr;
|
||||
ASSERT_TRUE(db_->CreateColumnFamily(ColumnFamilyOptions(), "one", &duplicate)
|
||||
.IsInvalidArgument());
|
||||
ASSERT_EQ(nullptr, duplicate);
|
||||
ASSERT_EQ(before_duplicate_create, CountOptionsFiles());
|
||||
|
||||
ASSERT_OK(db_->DropColumnFamily(handle));
|
||||
const size_t before_duplicate_drop = CountOptionsFiles();
|
||||
ASSERT_TRUE(db_->DropColumnFamily(handle).IsInvalidArgument());
|
||||
ASSERT_EQ(before_duplicate_drop, CountOptionsFiles());
|
||||
ASSERT_OK(db_->DestroyColumnFamilyHandle(handle));
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest,
|
||||
PartialMultiDropConsumesLegacyOptionsPersistenceFailure) {
|
||||
auto fail_fs =
|
||||
std::make_shared<FailOptionsFilesFs>(db_options_.env->GetFileSystem());
|
||||
auto fail_env =
|
||||
std::make_unique<CompositeEnvWrapper>(db_options_.env, fail_fs);
|
||||
SaveAndRestore<Env*> save_restore_env(&db_options_.env, fail_env.get());
|
||||
|
||||
Open();
|
||||
ColumnFamilyHandle* handle = nullptr;
|
||||
ASSERT_OK(db_->CreateColumnFamily(ColumnFamilyOptions(), "one", &handle));
|
||||
|
||||
fail_fs->fail_options_writes.store(true, std::memory_order_relaxed);
|
||||
Status s = db_->DropColumnFamilies({handle, db_->DefaultColumnFamily()});
|
||||
ASSERT_TRUE(s.IsInvalidArgument());
|
||||
fail_fs->fail_options_writes.store(false, std::memory_order_relaxed);
|
||||
|
||||
ASSERT_OK(db_->DestroyColumnFamilyHandle(handle));
|
||||
Close();
|
||||
AssertColumnFamilyNames({kDefaultColumnFamilyName});
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, CreateMissingColumnFamilies) {
|
||||
// Can't accidentally add CFs to an existing DB
|
||||
Open();
|
||||
@@ -2734,16 +2284,6 @@ TEST_P(ColumnFamilyTest, CreateMissingColumnFamilies) {
|
||||
ASSERT_OK(TryOpen({"default", "one", "two", "three", "four"}));
|
||||
Close();
|
||||
ASSERT_EQ(my_fs->options_files_created.load(), 2);
|
||||
|
||||
Destroy();
|
||||
db_options_.track_options_file_number_in_manifest = true;
|
||||
my_fs->options_files_created.store(0, std::memory_order_relaxed);
|
||||
ASSERT_OK(TryOpen({"default", "one", "two", "three", "four"}));
|
||||
Close();
|
||||
// A new tracked DB writes its initial snapshot, one proposed batch snapshot,
|
||||
// and the normal final DB::Open snapshot, independent of the number of
|
||||
// missing CFs.
|
||||
ASSERT_EQ(my_fs->options_files_created.load(), 3);
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, SanitizeCfOptions) {
|
||||
@@ -3731,12 +3271,6 @@ TEST_P(ColumnFamilyTest, FlushCloseWALFiles) {
|
||||
TEST_P(ColumnFamilyTest, IteratorCloseWALFile1) {
|
||||
SpecialEnv env(Env::Default());
|
||||
db_options_.env = &env;
|
||||
// The DB keeps its Env pointer until Close(). Close it before the local Env
|
||||
// is destroyed, including when an ASSERT below exits the test early.
|
||||
Defer close_db_on_exit([this] {
|
||||
Close();
|
||||
db_options_.env = env_;
|
||||
});
|
||||
db_options_.max_background_flushes = 1;
|
||||
// When this option is removed, the test will need re-engineering
|
||||
db_options_.background_close_inactive_wals = true;
|
||||
@@ -3746,38 +3280,25 @@ TEST_P(ColumnFamilyTest, IteratorCloseWALFile1) {
|
||||
CreateColumnFamilies({"one"});
|
||||
ASSERT_OK(Put(1, "fodor", "mirko"));
|
||||
// Create an iterator holding the current super version.
|
||||
std::unique_ptr<Iterator> it(db_->NewIterator(ReadOptions(), handles_[1]));
|
||||
Iterator* it = db_->NewIterator(ReadOptions(), handles_[1]);
|
||||
ASSERT_OK(it->status());
|
||||
|
||||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
|
||||
{"DBImpl::BGWorkFlush:done",
|
||||
"ColumnFamilyTest::IteratorCloseWALFile1:SetupFlushDone"},
|
||||
});
|
||||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
|
||||
Defer disable_sync_points(
|
||||
[] { ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing(); });
|
||||
|
||||
// A flush will make `it` hold the last reference of its super version.
|
||||
ASSERT_OK(Flush(1));
|
||||
// Flush() can return before the background function releases all temporary
|
||||
// references to the old super version.
|
||||
TEST_SYNC_POINT("ColumnFamilyTest::IteratorCloseWALFile1:SetupFlushDone");
|
||||
|
||||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
|
||||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({
|
||||
{"ColumnFamilyTest::IteratorCloseWALFile1:ReleaseFlush",
|
||||
"DBImpl::BackgroundCallFlush:start"},
|
||||
});
|
||||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
|
||||
|
||||
ASSERT_OK(Put(1, "fodor", "mirko"));
|
||||
ASSERT_OK(Put(0, "fodor", "mirko"));
|
||||
ASSERT_OK(Put(1, "fodor", "mirko"));
|
||||
|
||||
// Flush jobs close previous WAL files after finishing. Keep the next flush
|
||||
// from starting so the iterator destructor is responsible for closing the
|
||||
// WAL. Occupying one Env worker is insufficient because the shared Env can
|
||||
// have multiple HIGH-priority workers.
|
||||
// Flush jobs will close previous WAL files after finishing. By
|
||||
// block flush jobs from running, we trigger a condition where
|
||||
// the iterator destructor should close the WAL files.
|
||||
test::SleepingBackgroundTask sleeping_task;
|
||||
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask, &sleeping_task,
|
||||
Env::Priority::HIGH);
|
||||
// Make sure the task is sleeping. Otherwise, it might start to execute
|
||||
// after sleeping_task.WaitUntilDone() and cause TSAN warning.
|
||||
sleeping_task.WaitUntilSleeping();
|
||||
|
||||
WriteOptions wo;
|
||||
wo.sync = true;
|
||||
ASSERT_OK(db_->Put(wo, handles_[1], "fodor", "mirko"));
|
||||
@@ -3785,15 +3306,18 @@ TEST_P(ColumnFamilyTest, IteratorCloseWALFile1) {
|
||||
ASSERT_EQ(2, env.num_open_wal_file_.load());
|
||||
// Deleting the iterator will clear its super version, triggering
|
||||
// closing all files
|
||||
it.reset();
|
||||
delete it;
|
||||
ASSERT_EQ(1, env.num_open_wal_file_.load());
|
||||
|
||||
TEST_SYNC_POINT("ColumnFamilyTest::IteratorCloseWALFile1:ReleaseFlush");
|
||||
sleeping_task.WakeUp();
|
||||
sleeping_task.WaitUntilDone();
|
||||
WaitForFlush(1);
|
||||
|
||||
Reopen();
|
||||
ASSERT_EQ("mirko", Get(0, "fodor"));
|
||||
ASSERT_EQ("mirko", Get(1, "fodor"));
|
||||
db_options_.env = env_;
|
||||
Close();
|
||||
}
|
||||
|
||||
TEST_P(ColumnFamilyTest, IteratorCloseWALFile2) {
|
||||
@@ -4050,8 +3574,7 @@ TEST_P(ColumnFamilyTest, DefaultCfPathsTest) {
|
||||
// Leave cf_paths for one column families to be empty.
|
||||
// Files should be generated according to db_paths for that
|
||||
// column family.
|
||||
ColumnFamilyOptions cf_opt1;
|
||||
ColumnFamilyOptions cf_opt2;
|
||||
ColumnFamilyOptions cf_opt1, cf_opt2;
|
||||
cf_opt1.cf_paths.emplace_back(dbname_ + "_one_1",
|
||||
std::numeric_limits<uint64_t>::max());
|
||||
CreateColumnFamilies({"one", "two"}, {cf_opt1, cf_opt2});
|
||||
@@ -4076,8 +3599,7 @@ TEST_P(ColumnFamilyTest, DefaultCfPathsTest) {
|
||||
TEST_P(ColumnFamilyTest, MultipleCFPathsTest) {
|
||||
Open();
|
||||
// Configure Column family specific paths.
|
||||
ColumnFamilyOptions cf_opt1;
|
||||
ColumnFamilyOptions cf_opt2;
|
||||
ColumnFamilyOptions cf_opt1, cf_opt2;
|
||||
cf_opt1.cf_paths.emplace_back(dbname_ + "_one_1",
|
||||
std::numeric_limits<uint64_t>::max());
|
||||
cf_opt2.cf_paths.emplace_back(dbname_ + "_two_1",
|
||||
@@ -4193,9 +3715,7 @@ TEST(ColumnFamilyTest, ValidateMemtableKVChecksumOption) {
|
||||
// the behavior of manual flush is that it skips retaining UDTs.
|
||||
class ColumnFamilyRetainUDTTest : public ColumnFamilyTestBase {
|
||||
public:
|
||||
ColumnFamilyRetainUDTTest()
|
||||
: ColumnFamilyTestBase(
|
||||
BlockBasedTableOptions::kLatestSupportedFormatVersion) {}
|
||||
ColumnFamilyRetainUDTTest() : ColumnFamilyTestBase(kLatestBbtFormatVersion) {}
|
||||
|
||||
void SetUp() override {
|
||||
db_options_.allow_concurrent_memtable_write = false;
|
||||
|
||||
@@ -214,8 +214,7 @@ bool Compaction::IsBottommostLevel(
|
||||
} else {
|
||||
output_l0_idx = -1;
|
||||
}
|
||||
Slice smallest_key;
|
||||
Slice largest_key;
|
||||
Slice smallest_key, largest_key;
|
||||
GetBoundaryKeys(vstorage, inputs, &smallest_key, &largest_key);
|
||||
return !vstorage->RangeMightExistAfterSortedRun(smallest_key, largest_key,
|
||||
output_level, output_l0_idx);
|
||||
@@ -555,10 +554,6 @@ bool Compaction::InputCompressionMatchesOutput() const {
|
||||
}
|
||||
|
||||
bool Compaction::IsTrivialMove() const {
|
||||
if (skip_missing_blob_files_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Avoid a move if there is lots of overlapping grandparent data.
|
||||
// Otherwise, the move could create a parent file that will require
|
||||
// a very expensive merge later on.
|
||||
|
||||
@@ -114,8 +114,6 @@ class Compaction {
|
||||
// No copying allowed
|
||||
Compaction(const Compaction&) = delete;
|
||||
void operator=(const Compaction&) = delete;
|
||||
Compaction(Compaction&&) = delete;
|
||||
void operator=(Compaction&&) = delete;
|
||||
|
||||
~Compaction();
|
||||
|
||||
@@ -151,14 +149,6 @@ class Compaction {
|
||||
// Returns input version of the compaction
|
||||
Version* input_version() const { return input_version_; }
|
||||
|
||||
bool skip_missing_blob_files() const { return skip_missing_blob_files_; }
|
||||
|
||||
// Set before registering or running this compaction.
|
||||
void SetSkipMissingBlobFiles(bool skip_missing_blob_files) {
|
||||
assert(is_manual_compaction_ || !skip_missing_blob_files);
|
||||
skip_missing_blob_files_ = skip_missing_blob_files;
|
||||
}
|
||||
|
||||
// Returns the ColumnFamilyData associated with the compaction.
|
||||
ColumnFamilyData* column_family_data() const { return cfd_; }
|
||||
|
||||
@@ -279,13 +269,6 @@ class Compaction {
|
||||
// Does this compaction include all sst files?
|
||||
bool is_full_compaction() const { return is_full_compaction_; }
|
||||
|
||||
bool separate_remote_compaction_pool_selected() const {
|
||||
return separate_remote_compaction_pool_selected_;
|
||||
}
|
||||
void SetSeparateRemoteCompactionPoolSelected(bool selected) {
|
||||
separate_remote_compaction_pool_selected_ = selected;
|
||||
}
|
||||
|
||||
// Was this compaction triggered manually by the client?
|
||||
bool is_manual_compaction() const { return is_manual_compaction_; }
|
||||
|
||||
@@ -546,7 +529,7 @@ class Compaction {
|
||||
|
||||
// Get the atomic file boundaries for all files in the compaction. Necessary
|
||||
// in order to avoid the scenario described in
|
||||
// https://github.com/meta/rocksdb/pull/4432#discussion_r221072219 and
|
||||
// https://github.com/facebook/rocksdb/pull/4432#discussion_r221072219 and
|
||||
// plumb down appropriate key boundaries to RangeDelAggregator during
|
||||
// compaction.
|
||||
static std::vector<CompactionInputFiles> PopulateWithAtomicBoundaries(
|
||||
@@ -624,11 +607,9 @@ class Compaction {
|
||||
const bool bottommost_level_;
|
||||
// Does this compaction include all sst files?
|
||||
const bool is_full_compaction_;
|
||||
bool separate_remote_compaction_pool_selected_ = false;
|
||||
|
||||
// Is this compaction requested by the client?
|
||||
const bool is_manual_compaction_;
|
||||
bool skip_missing_blob_files_ = false;
|
||||
|
||||
// The data with timestamp > trim_ts_ will be removed
|
||||
const std::string trim_ts_;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "db/compaction/compaction_iterator.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
@@ -13,7 +12,6 @@
|
||||
#include "db/blob/blob_fetcher.h"
|
||||
#include "db/blob/blob_file_builder.h"
|
||||
#include "db/blob/blob_index.h"
|
||||
#include "db/blob/missing_blob_repair_iterator.h"
|
||||
#include "db/blob/prefetch_buffer_collection.h"
|
||||
#include "db/snapshot_checker.h"
|
||||
#include "db/wide/blob_column_resolver_util.h"
|
||||
@@ -141,8 +139,7 @@ CompactionIterator::CompactionIterator(
|
||||
const std::shared_ptr<Logger> info_log,
|
||||
const std::string* full_history_ts_low,
|
||||
std::optional<SequenceNumber> preserve_seqno_min,
|
||||
const Version* input_version, Env::IOActivity blob_read_io_activity,
|
||||
std::optional<uint64_t> blob_gc_cutoff_file_number)
|
||||
const Version* input_version, Env::IOActivity blob_read_io_activity)
|
||||
: CompactionIterator(
|
||||
input, cmp, merge_helper, last_sequence, snapshots, earliest_snapshot,
|
||||
earliest_write_conflict_snapshot, job_snapshot, snapshot_checker, env,
|
||||
@@ -152,7 +149,7 @@ CompactionIterator::CompactionIterator(
|
||||
compaction ? std::make_unique<RealCompaction>(compaction) : nullptr,
|
||||
must_count_input_entries, compaction_filter, shutting_down, info_log,
|
||||
full_history_ts_low, preserve_seqno_min, input_version,
|
||||
blob_read_io_activity, blob_gc_cutoff_file_number) {}
|
||||
blob_read_io_activity) {}
|
||||
|
||||
CompactionIterator::CompactionIterator(
|
||||
InternalIterator* input, const Comparator* cmp, MergeHelper* merge_helper,
|
||||
@@ -171,8 +168,7 @@ CompactionIterator::CompactionIterator(
|
||||
const std::shared_ptr<Logger> info_log,
|
||||
const std::string* full_history_ts_low,
|
||||
std::optional<SequenceNumber> preserve_seqno_min,
|
||||
const Version* input_version, Env::IOActivity blob_read_io_activity,
|
||||
std::optional<uint64_t> blob_gc_cutoff_file_number)
|
||||
const Version* input_version, Env::IOActivity blob_read_io_activity)
|
||||
: input_(input, cmp, must_count_input_entries),
|
||||
cmp_(cmp),
|
||||
merge_helper_(merge_helper),
|
||||
@@ -187,9 +183,6 @@ CompactionIterator::CompactionIterator(
|
||||
blob_file_builder_(blob_file_builder),
|
||||
compaction_(std::move(compaction)),
|
||||
compaction_filter_(compaction_filter),
|
||||
merge_order_(merge_helper
|
||||
? merge_helper->merge_order()
|
||||
: CompactionFilter::MergeOrder::kFilterBeforeMerge),
|
||||
filter_supports_v4_(
|
||||
compaction_filter_ ? compaction_filter_->SupportsFilterV4() : false),
|
||||
shutting_down_(shutting_down),
|
||||
@@ -209,10 +202,7 @@ CompactionIterator::CompactionIterator(
|
||||
current_user_key_snapshot_(0),
|
||||
merge_out_iter_(merge_helper_),
|
||||
blob_garbage_collection_cutoff_file_number_(
|
||||
blob_gc_cutoff_file_number.has_value()
|
||||
? *blob_gc_cutoff_file_number
|
||||
: ComputeBlobGarbageCollectionCutoffFileNumber(
|
||||
compaction_.get())),
|
||||
ComputeBlobGarbageCollectionCutoffFileNumber(compaction_.get())),
|
||||
blob_fetcher_(CreateBlobFetcherIfNeeded(compaction_.get(), input_version,
|
||||
blob_read_io_activity)),
|
||||
prefetch_buffers_(
|
||||
@@ -222,20 +212,8 @@ CompactionIterator::CompactionIterator(
|
||||
level_(compaction_ == nullptr ? 0 : compaction_->level()),
|
||||
preserve_seqno_after_(preserve_seqno_min.value_or(earliest_snapshot)) {
|
||||
assert(snapshots_ != nullptr);
|
||||
if (compaction_filter_ &&
|
||||
merge_order_ == CompactionFilter::MergeOrder::kMergeBeforeFilter &&
|
||||
(snapshot_checker_ != nullptr || timestamp_size_ != 0 ||
|
||||
compaction_filter_->IsStackedBlobDbInternalCompactionFilter())) {
|
||||
status_ = Status::NotSupported(
|
||||
"Merge-before-filter does not support SnapshotChecker, timestamps, "
|
||||
"or stacked BlobDB");
|
||||
}
|
||||
assert(preserve_seqno_after_ <= earliest_snapshot_);
|
||||
|
||||
TEST_SYNC_POINT_CALLBACK(
|
||||
"CompactionIterator::BlobGarbageCollectionCutoffFileNumber",
|
||||
&blob_garbage_collection_cutoff_file_number_);
|
||||
|
||||
if (compaction_ != nullptr) {
|
||||
level_ptrs_ = std::vector<size_t>(compaction_->number_levels(), 0);
|
||||
}
|
||||
@@ -290,41 +268,18 @@ void CompactionIterator::ResetRecordCounts() {
|
||||
}
|
||||
|
||||
void CompactionIterator::SeekToFirst() {
|
||||
SeekToFirstWithoutPreparingOutput();
|
||||
PrepareOutputIfNeeded();
|
||||
}
|
||||
|
||||
void CompactionIterator::SeekToFirstWithoutPreparingOutput() {
|
||||
if (!status_.ok()) {
|
||||
return;
|
||||
}
|
||||
NextFromInput();
|
||||
PrepareOutput();
|
||||
}
|
||||
|
||||
void CompactionIterator::Next() {
|
||||
NextImpl();
|
||||
PrepareOutputIfNeeded();
|
||||
}
|
||||
|
||||
void CompactionIterator::NextWithoutPreparingOutput() { NextImpl(); }
|
||||
|
||||
void CompactionIterator::NextImpl() {
|
||||
if (!status_.ok()) {
|
||||
return;
|
||||
}
|
||||
output_prepared_ = false;
|
||||
// If there is a merge output, return it before continuing to process the
|
||||
// input.
|
||||
if (merge_out_iter_.Valid()) {
|
||||
merge_out_iter_.Next();
|
||||
|
||||
// Check if we returned all records of the merge output.
|
||||
if (merge_out_iter_.Valid() &&
|
||||
merge_order_ == CompactionFilter::MergeOrder::kMergeBeforeFilter) {
|
||||
if (!SelectMergeOutput(ValidContext::kMerge1) && status_.ok()) {
|
||||
NextFromInput();
|
||||
}
|
||||
} else if (merge_out_iter_.Valid()) {
|
||||
if (merge_out_iter_.Valid()) {
|
||||
key_ = merge_out_iter_.key();
|
||||
value_ = merge_out_iter_.value();
|
||||
Status s = ParseInternalKey(key_, &ikey_, allow_data_in_errors_);
|
||||
@@ -384,33 +339,25 @@ void CompactionIterator::NextImpl() {
|
||||
// Record that we've outputted a record for the current key.
|
||||
has_outputted_key_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CompactionIterator::PrepareOutputIfNeeded() {
|
||||
if (!output_prepared_) {
|
||||
PrepareOutput();
|
||||
output_prepared_ = true;
|
||||
}
|
||||
PrepareOutput();
|
||||
}
|
||||
|
||||
bool CompactionIterator::InvokeFilterIfNeeded(bool* need_skip,
|
||||
Slice* skip_until,
|
||||
bool merge_output) {
|
||||
Slice* skip_until) {
|
||||
if (!compaction_filter_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ikey_.type != kTypeValue && ikey_.type != kTypeBlobIndex &&
|
||||
ikey_.type != kTypeWideColumnEntity &&
|
||||
!(merge_output && ikey_.type == kTypeMerge)) {
|
||||
ikey_.type != kTypeWideColumnEntity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CompactionFilter::Decision decision =
|
||||
CompactionFilter::Decision::kUndetermined;
|
||||
CompactionFilter::ValueType value_type =
|
||||
ikey_.type == kTypeValue ? CompactionFilter::ValueType::kValue
|
||||
: ikey_.type == kTypeMerge ? CompactionFilter::ValueType::kMergeOperand
|
||||
ikey_.type == kTypeValue ? CompactionFilter::ValueType::kValue
|
||||
: ikey_.type == kTypeBlobIndex
|
||||
? CompactionFilter::ValueType::kBlobIndex
|
||||
: CompactionFilter::ValueType::kWideColumnEntity;
|
||||
@@ -643,45 +590,6 @@ bool CompactionIterator::InvokeFilterIfNeeded(bool* need_skip,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (merge_order_ == CompactionFilter::MergeOrder::kMergeBeforeFilter) {
|
||||
const bool operand = ikey_.type == kTypeMerge;
|
||||
switch (decision) {
|
||||
case CompactionFilter::Decision::kKeep:
|
||||
case CompactionFilter::Decision::kRemove:
|
||||
case CompactionFilter::Decision::kChangeValue:
|
||||
case CompactionFilter::Decision::kRemoveAndSkipUntil:
|
||||
break;
|
||||
case CompactionFilter::Decision::kPurge:
|
||||
if (!operand) {
|
||||
// Use ordinary removal for both input values and merge results, so
|
||||
// later compactions apply the same policy. SingleDelete cannot be
|
||||
// mixed with Merge or ordinary Delete on affected keys.
|
||||
decision = CompactionFilter::Decision::kRemove;
|
||||
break;
|
||||
}
|
||||
[[fallthrough]];
|
||||
case CompactionFilter::Decision::kChangeWideColumnEntity:
|
||||
if (!operand) {
|
||||
break;
|
||||
}
|
||||
// Partial results and untouched operands must remain valid merge
|
||||
// operands. Neither SingleDelete nor an entity replacement represents
|
||||
// an operand; kRemove drops its effect and kChangeValue replaces it.
|
||||
[[fallthrough]];
|
||||
case CompactionFilter::Decision::kChangeBlobIndex:
|
||||
case CompactionFilter::Decision::kIOError:
|
||||
case CompactionFilter::Decision::kUndetermined:
|
||||
// kChangeBlobIndex/kIOError belong to the old stacked BlobDB protocol.
|
||||
// Integrated BlobDB changes use kChangeValue and report resolver errors
|
||||
// through Status. kUndetermined is only a FilterBlobByKey fallback,
|
||||
// never a final FilterV2/V3/V4 decision.
|
||||
status_ = Status::NotSupported(
|
||||
"Invalid decision for merge-before-filter value type");
|
||||
validity_info_.Invalidate();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (decision == CompactionFilter::Decision::kRemoveAndSkipUntil &&
|
||||
cmp_->Compare(*compaction_filter_skip_until_.rep(), ikey_.user_key) <=
|
||||
0) {
|
||||
@@ -691,11 +599,6 @@ bool CompactionIterator::InvokeFilterIfNeeded(bool* need_skip,
|
||||
}
|
||||
|
||||
if (decision == CompactionFilter::Decision::kRemove) {
|
||||
if (ikey_.type == kTypeMerge) {
|
||||
++iter_stats_.num_record_drop_user;
|
||||
validity_info_.Invalidate();
|
||||
return true;
|
||||
}
|
||||
// convert the current key to a delete; key_ is pointing into
|
||||
// current_key_ at this point, so updating current_key_ updates key()
|
||||
ikey_.type = kTypeDeletion;
|
||||
@@ -712,7 +615,7 @@ bool CompactionIterator::InvokeFilterIfNeeded(bool* need_skip,
|
||||
value_.clear();
|
||||
iter_stats_.num_record_drop_user++;
|
||||
} else if (decision == CompactionFilter::Decision::kChangeValue) {
|
||||
if (ikey_.type != kTypeValue && ikey_.type != kTypeMerge) {
|
||||
if (ikey_.type != kTypeValue) {
|
||||
ikey_.type = kTypeValue;
|
||||
current_key_.UpdateInternalKey(ikey_.sequence, kTypeValue);
|
||||
}
|
||||
@@ -794,221 +697,6 @@ bool CompactionIterator::InvokeFilterIfNeeded(bool* need_skip,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CompactionIterator::PrefilterUncombinedOutputs(uint8_t valid_context) {
|
||||
uncombined_prefiltered_ = true;
|
||||
uncombined_decisions_.clear();
|
||||
uncombined_index_ = 0;
|
||||
MergeOutputIterator it(merge_helper_);
|
||||
for (it.SeekToFirst(); it.Valid(); it.Next()) {
|
||||
key_ = it.key();
|
||||
value_ = it.value();
|
||||
status_ = ParseInternalKey(key_, &ikey_, allow_data_in_errors_);
|
||||
if (!status_.ok()) {
|
||||
validity_info_.Invalidate();
|
||||
merge_out_iter_.Invalidate();
|
||||
return false;
|
||||
}
|
||||
current_key_.UpdateInternalKey(ikey_.sequence, ikey_.type);
|
||||
key_ = current_key_.GetInternalKey();
|
||||
ikey_.user_key = current_key_.GetUserKey();
|
||||
entity_deserialized_ = false;
|
||||
blob_value_.Reset();
|
||||
validity_info_.SetValid(valid_context);
|
||||
UncombinedDecision decision;
|
||||
if (merge_helper_->OperandEligible(ikey_.sequence)) {
|
||||
bool need_skip = false;
|
||||
Slice skip_until;
|
||||
if (!InvokeFilterIfNeeded(&need_skip, &skip_until, true)) {
|
||||
merge_out_iter_.Invalidate();
|
||||
return false;
|
||||
}
|
||||
if (need_skip) {
|
||||
// Newer operands of this batch were not output yet, so the skip drops
|
||||
// the whole batch.
|
||||
merge_out_iter_.Invalidate();
|
||||
validity_info_.Invalidate();
|
||||
pinned_iters_mgr_.ReleasePinnedData();
|
||||
SkipUntil(skip_until);
|
||||
return false;
|
||||
}
|
||||
decision.keep = Valid();
|
||||
if (decision.keep && value_.data() == compaction_filter_value_.data()) {
|
||||
decision.changed = true;
|
||||
decision.value = compaction_filter_value_;
|
||||
}
|
||||
}
|
||||
uncombined_decisions_.push_back(std::move(decision));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CompactionIterator::SelectMergeOutput(uint8_t valid_context) {
|
||||
const bool prefiltered =
|
||||
compaction_filter_ != nullptr &&
|
||||
merge_helper_->outcome() == MergeHelper::Outcome::kUncombined;
|
||||
if (prefiltered && !uncombined_prefiltered_ &&
|
||||
!PrefilterUncombinedOutputs(valid_context)) {
|
||||
return false;
|
||||
}
|
||||
while (merge_out_iter_.Valid() && !IsShuttingDown() &&
|
||||
!IsPausingManualCompaction()) {
|
||||
key_ = merge_out_iter_.key();
|
||||
value_ = merge_out_iter_.value();
|
||||
status_ = ParseInternalKey(key_, &ikey_, allow_data_in_errors_);
|
||||
if (!status_.ok()) {
|
||||
validity_info_.Invalidate();
|
||||
merge_out_iter_.Invalidate();
|
||||
return false;
|
||||
}
|
||||
current_key_.UpdateInternalKey(ikey_.sequence, ikey_.type);
|
||||
key_ = current_key_.GetInternalKey();
|
||||
ikey_.user_key = current_key_.GetUserKey();
|
||||
entity_deserialized_ = false;
|
||||
blob_value_.Reset();
|
||||
validity_info_.SetValid(valid_context);
|
||||
if (prefiltered) {
|
||||
if (uncombined_index_ < uncombined_decisions_.size()) {
|
||||
const UncombinedDecision& decision =
|
||||
uncombined_decisions_[uncombined_index_];
|
||||
if (!decision.keep) {
|
||||
validity_info_.Invalidate();
|
||||
} else if (decision.changed) {
|
||||
value_ = decision.value;
|
||||
}
|
||||
}
|
||||
++uncombined_index_;
|
||||
} else if (merge_helper_->aggregate_eligible() && compaction_filter_) {
|
||||
bool need_skip = false;
|
||||
Slice skip_until;
|
||||
if (!InvokeFilterIfNeeded(&need_skip, &skip_until, true)) {
|
||||
merge_out_iter_.Invalidate();
|
||||
return false;
|
||||
}
|
||||
if (need_skip) {
|
||||
merge_out_iter_.Invalidate();
|
||||
validity_info_.Invalidate();
|
||||
pinned_iters_mgr_.ReleasePinnedData();
|
||||
SkipUntil(skip_until);
|
||||
return false;
|
||||
}
|
||||
if (Valid() && ikey_.type == kTypeDeletion) {
|
||||
SequenceNumber prev_snapshot = 0;
|
||||
current_user_key_sequence_ = ikey_.sequence;
|
||||
current_user_key_snapshot_ =
|
||||
visible_at_tip_
|
||||
? earliest_snapshot_
|
||||
: findEarliestVisibleSnapshot(ikey_.sequence, &prev_snapshot);
|
||||
ProcessDeletion(prev_snapshot, true);
|
||||
}
|
||||
}
|
||||
if (Valid()) {
|
||||
return true;
|
||||
}
|
||||
merge_out_iter_.Next();
|
||||
}
|
||||
if (merge_until_status_.IsMergeInProgress()) {
|
||||
has_current_user_key_ = false;
|
||||
}
|
||||
pinned_iters_mgr_.ReleasePinnedData();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CompactionIterator::ProcessDeletion(SequenceNumber prev_snapshot,
|
||||
bool input_already_advanced) {
|
||||
if (compaction_ != nullptr &&
|
||||
(ikey_.type == kTypeDeletion ||
|
||||
(ikey_.type == kTypeDeletionWithTimestamp &&
|
||||
cmp_with_history_ts_low_ < 0)) &&
|
||||
!compaction_->allow_ingest_behind() &&
|
||||
DefinitelyInSnapshot(ikey_.sequence, earliest_snapshot_) &&
|
||||
compaction_->KeyNotExistsBeyondOutputLevel(ikey_.user_key,
|
||||
&level_ptrs_)) {
|
||||
// TODO(noetzli): This is the only place where we use compaction_
|
||||
// (besides the constructor). We should probably get rid of this
|
||||
// dependency and find a way to do similar filtering during flushes.
|
||||
//
|
||||
// For this user key:
|
||||
// (1) there is no data in higher levels
|
||||
// (2) data in lower levels will have larger sequence numbers
|
||||
// (3) data in layers that are being compacted here and have
|
||||
// smaller sequence numbers will be dropped in the next
|
||||
// few iterations of this loop (by rule (A) above).
|
||||
// Therefore this deletion marker is obsolete and can be dropped.
|
||||
//
|
||||
// Note: Dropping this Delete will not affect TransactionDB
|
||||
// write-conflict checking since it is earlier than any snapshot.
|
||||
//
|
||||
// It seems that we can also drop deletion later than earliest snapshot
|
||||
// given that:
|
||||
// (1) The deletion is earlier than earliest_write_conflict_snapshot, and
|
||||
// (2) No value exist earlier than the deletion.
|
||||
//
|
||||
// Note also that a deletion marker of type kTypeDeletionWithTimestamp
|
||||
// will be treated as a different user key unless the timestamp is older
|
||||
// than *full_history_ts_low_.
|
||||
validity_info_.Invalidate();
|
||||
++iter_stats_.num_record_drop_obsolete;
|
||||
if (!bottommost_level_) {
|
||||
++iter_stats_.num_optimized_del_drop_obsolete;
|
||||
}
|
||||
if (!input_already_advanced) {
|
||||
AdvanceInputIterWithoutOutput();
|
||||
}
|
||||
} else if ((ikey_.type == kTypeDeletion ||
|
||||
(ikey_.type == kTypeDeletionWithTimestamp &&
|
||||
cmp_with_history_ts_low_ < 0)) &&
|
||||
bottommost_level_) {
|
||||
assert(compaction_);
|
||||
assert(!compaction_->allow_ingest_behind()); // bottommost_level_ is true
|
||||
// Handle the case where we have a delete key at the bottom most level
|
||||
// We can skip outputting the key iff there are no subsequent puts for
|
||||
// this key
|
||||
assert(compaction_->KeyNotExistsBeyondOutputLevel(ikey_.user_key,
|
||||
&level_ptrs_));
|
||||
validity_info_.Invalidate();
|
||||
ParsedInternalKey next_ikey;
|
||||
if (!input_already_advanced) {
|
||||
AdvanceInputIterWithoutOutput();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
const Compaction* c =
|
||||
compaction_ ? compaction_->real_compaction() : nullptr;
|
||||
#endif
|
||||
TEST_SYNC_POINT_CALLBACK(
|
||||
"CompactionIterator::NextFromInput:BottommostDelete:1",
|
||||
const_cast<Compaction*>(c));
|
||||
// Skip over all versions of this key that happen to occur in the same
|
||||
// snapshot range as the delete.
|
||||
//
|
||||
// Note that a deletion marker of type kTypeDeletionWithTimestamp will be
|
||||
// considered to have a different user key unless the timestamp is older
|
||||
// than *full_history_ts_low_.
|
||||
//
|
||||
// Range tombstone start keys are skipped as they are not "real" keys.
|
||||
while (!IsPausingManualCompaction() && !IsShuttingDown() &&
|
||||
input_.Valid() &&
|
||||
(ParseInternalKey(input_.key(), &next_ikey, allow_data_in_errors_)
|
||||
.ok()) &&
|
||||
cmp_->EqualWithoutTimestamp(ikey_.user_key, next_ikey.user_key) &&
|
||||
(prev_snapshot == 0 || input_.IsDeleteRangeSentinelKey() ||
|
||||
DefinitelyNotInSnapshot(next_ikey.sequence, prev_snapshot))) {
|
||||
AdvanceInputIterWithoutOutput();
|
||||
}
|
||||
// If you find you still need to output a row with this key, we need to
|
||||
// output the delete too
|
||||
if (input_.Valid() &&
|
||||
(ParseInternalKey(input_.key(), &next_ikey, allow_data_in_errors_)
|
||||
.ok()) &&
|
||||
cmp_->EqualWithoutTimestamp(ikey_.user_key, next_ikey.user_key)) {
|
||||
validity_info_.SetValid(ValidContext::kKeepDel);
|
||||
at_next_ = true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CompactionIterator::NextFromInput() {
|
||||
at_next_ = false;
|
||||
validity_info_.Invalidate();
|
||||
@@ -1034,12 +722,6 @@ void CompactionIterator::NextFromInput() {
|
||||
status_ = pik_status;
|
||||
return;
|
||||
}
|
||||
if (has_consumed_earlier_entries_of_current_key_ &&
|
||||
!cmp_->EqualWithoutTimestamp(ikey_.user_key, current_user_key_)) {
|
||||
// current_user_key_ remains usable when lookahead or merge handling
|
||||
// clears has_current_user_key_.
|
||||
has_consumed_earlier_entries_of_current_key_ = false;
|
||||
}
|
||||
TEST_SYNC_POINT_CALLBACK("CompactionIterator:ProcessKV", &ikey_);
|
||||
if (is_range_del_) {
|
||||
validity_info_.SetValid(kRangeDeletion);
|
||||
@@ -1125,7 +807,7 @@ void CompactionIterator::NextFromInput() {
|
||||
// Apply the compaction filter to the first committed version of the user
|
||||
// key.
|
||||
if (current_key_committed_ &&
|
||||
!InvokeFilterIfNeeded(&need_skip, &skip_until, false)) {
|
||||
!InvokeFilterIfNeeded(&need_skip, &skip_until)) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -1147,7 +829,7 @@ void CompactionIterator::NextFromInput() {
|
||||
// Apply the compaction filter to the first committed version of the
|
||||
// user key.
|
||||
if (current_key_committed_ &&
|
||||
!InvokeFilterIfNeeded(&need_skip, &skip_until, false)) {
|
||||
!InvokeFilterIfNeeded(&need_skip, &skip_until)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1270,14 +952,14 @@ void CompactionIterator::NextFromInput() {
|
||||
(full_history_ts_low_ && cmp_with_history_ts_low_ < 0));
|
||||
|
||||
ParsedInternalKey next_ikey;
|
||||
AdvanceInputIterWithoutOutput();
|
||||
AdvanceInputIter();
|
||||
while (input_.Valid() && input_.IsDeleteRangeSentinelKey() &&
|
||||
ParseInternalKey(input_.key(), &next_ikey, allow_data_in_errors_)
|
||||
.ok() &&
|
||||
cmp_->EqualWithoutTimestamp(ikey_.user_key, next_ikey.user_key)) {
|
||||
// skip range tombstone start keys with the same user key
|
||||
// since they are not "real" point keys.
|
||||
AdvanceInputIterWithoutOutput();
|
||||
AdvanceInputIter();
|
||||
}
|
||||
|
||||
// Check whether the next key exists, is not corrupt, and is the same key
|
||||
@@ -1294,27 +976,13 @@ void CompactionIterator::NextFromInput() {
|
||||
TEST_SYNC_POINT_CALLBACK(
|
||||
"CompactionIterator::NextFromInput:SingleDelete:1",
|
||||
const_cast<Compaction*>(c));
|
||||
if (missing_blob_repair_iterator_ &&
|
||||
missing_blob_repair_iterator_->IsRepairDeletion()) {
|
||||
ikey_.type =
|
||||
timestamp_size_ == 0 ? kTypeDeletion : kTypeDeletionWithTimestamp;
|
||||
current_key_.UpdateInternalKey(ikey_.sequence, ikey_.type);
|
||||
value_.clear();
|
||||
if (DeletionIsObsolete()) {
|
||||
++iter_stats_.num_record_drop_obsolete;
|
||||
if (!bottommost_level_) {
|
||||
++iter_stats_.num_optimized_del_drop_obsolete;
|
||||
}
|
||||
} else {
|
||||
validity_info_.SetValid(ValidContext::kKeepDel);
|
||||
}
|
||||
} else if (last_key_seq_zeroed_) {
|
||||
if (last_key_seq_zeroed_) {
|
||||
// Drop SD and the next key since they are both in the last
|
||||
// snapshot (since last key has seqno zeroed).
|
||||
++iter_stats_.num_record_drop_hidden;
|
||||
++iter_stats_.num_record_drop_obsolete;
|
||||
assert(bottommost_level_);
|
||||
AdvanceInputIterWithoutOutput();
|
||||
AdvanceInputIter();
|
||||
} else if (prev_snapshot == 0 ||
|
||||
DefinitelyNotInSnapshot(next_ikey.sequence, prev_snapshot)) {
|
||||
// Check whether the next key belongs to the same snapshot as the
|
||||
@@ -1386,7 +1054,7 @@ void CompactionIterator::NextFromInput() {
|
||||
++iter_stats_.num_record_drop_obsolete;
|
||||
// Already called input_.Next() once. Call it a second time to
|
||||
// skip past the second key.
|
||||
AdvanceInputIterWithoutOutput();
|
||||
AdvanceInputIter();
|
||||
} else {
|
||||
// Found a matching value, but we cannot drop both keys since
|
||||
// there is an earlier snapshot and we need to leave behind a record
|
||||
@@ -1481,8 +1149,15 @@ void CompactionIterator::NextFromInput() {
|
||||
}
|
||||
|
||||
++iter_stats_.num_record_drop_hidden;
|
||||
AdvanceInputIterWithoutOutput();
|
||||
} else if (DeletionIsObsolete()) {
|
||||
AdvanceInputIter();
|
||||
} else if (compaction_ != nullptr &&
|
||||
(ikey_.type == kTypeDeletion ||
|
||||
(ikey_.type == kTypeDeletionWithTimestamp &&
|
||||
cmp_with_history_ts_low_ < 0)) &&
|
||||
!compaction_->allow_ingest_behind() &&
|
||||
DefinitelyInSnapshot(ikey_.sequence, earliest_snapshot_) &&
|
||||
compaction_->KeyNotExistsBeyondOutputLevel(ikey_.user_key,
|
||||
&level_ptrs_)) {
|
||||
// TODO(noetzli): This is the only place where we use compaction_
|
||||
// (besides the constructor). We should probably get rid of this
|
||||
// dependency and find a way to do similar filtering during flushes.
|
||||
@@ -1510,11 +1185,53 @@ void CompactionIterator::NextFromInput() {
|
||||
if (!bottommost_level_) {
|
||||
++iter_stats_.num_optimized_del_drop_obsolete;
|
||||
}
|
||||
AdvanceInputIterWithoutOutput();
|
||||
AdvanceInputIter();
|
||||
} else if ((ikey_.type == kTypeDeletion ||
|
||||
(ikey_.type == kTypeDeletionWithTimestamp &&
|
||||
cmp_with_history_ts_low_ < 0)) &&
|
||||
ProcessDeletion(prev_snapshot, false)) {
|
||||
bottommost_level_) {
|
||||
assert(compaction_);
|
||||
assert(!compaction_->allow_ingest_behind()); // bottommost_level_ is true
|
||||
// Handle the case where we have a delete key at the bottom most level
|
||||
// We can skip outputting the key iff there are no subsequent puts for
|
||||
// this key
|
||||
assert(compaction_->KeyNotExistsBeyondOutputLevel(ikey_.user_key,
|
||||
&level_ptrs_));
|
||||
ParsedInternalKey next_ikey;
|
||||
AdvanceInputIter();
|
||||
#ifndef NDEBUG
|
||||
const Compaction* c =
|
||||
compaction_ ? compaction_->real_compaction() : nullptr;
|
||||
#endif
|
||||
TEST_SYNC_POINT_CALLBACK(
|
||||
"CompactionIterator::NextFromInput:BottommostDelete:1",
|
||||
const_cast<Compaction*>(c));
|
||||
// Skip over all versions of this key that happen to occur in the same
|
||||
// snapshot range as the delete.
|
||||
//
|
||||
// Note that a deletion marker of type kTypeDeletionWithTimestamp will be
|
||||
// considered to have a different user key unless the timestamp is older
|
||||
// than *full_history_ts_low_.
|
||||
//
|
||||
// Range tombstone start keys are skipped as they are not "real" keys.
|
||||
while (!IsPausingManualCompaction() && !IsShuttingDown() &&
|
||||
input_.Valid() &&
|
||||
(ParseInternalKey(input_.key(), &next_ikey, allow_data_in_errors_)
|
||||
.ok()) &&
|
||||
cmp_->EqualWithoutTimestamp(ikey_.user_key, next_ikey.user_key) &&
|
||||
(prev_snapshot == 0 || input_.IsDeleteRangeSentinelKey() ||
|
||||
DefinitelyNotInSnapshot(next_ikey.sequence, prev_snapshot))) {
|
||||
AdvanceInputIter();
|
||||
}
|
||||
// If you find you still need to output a row with this key, we need to
|
||||
// output the delete too
|
||||
if (input_.Valid() &&
|
||||
(ParseInternalKey(input_.key(), &next_ikey, allow_data_in_errors_)
|
||||
.ok()) &&
|
||||
cmp_->EqualWithoutTimestamp(ikey_.user_key, next_ikey.user_key)) {
|
||||
validity_info_.SetValid(ValidContext::kKeepDel);
|
||||
at_next_ = true;
|
||||
}
|
||||
} else if (ikey_.type == kTypeValuePreferredSeqno &&
|
||||
DefinitelyInSnapshot(ikey_.sequence, earliest_snapshot_) &&
|
||||
(bottommost_level_ ||
|
||||
@@ -1550,7 +1267,7 @@ void CompactionIterator::NextFromInput() {
|
||||
key_, RangeDelPositioningMode::kForwardTraversal)) {
|
||||
++iter_stats_.num_record_drop_hidden;
|
||||
++iter_stats_.num_record_drop_range_del;
|
||||
AdvanceInputIterWithoutOutput();
|
||||
AdvanceInputIter();
|
||||
} else {
|
||||
InternalKey ikey_after_swap(ikey_.user_key,
|
||||
std::min(preferred_seqno, ikey_.sequence),
|
||||
@@ -1589,45 +1306,36 @@ void CompactionIterator::NextFromInput() {
|
||||
// have hit (A)
|
||||
// We encapsulate the merge related state machine in a different
|
||||
// object to minimize change to the existing flow.
|
||||
has_consumed_earlier_entries_of_current_key_ = true;
|
||||
merge_until_status_ = merge_helper_->MergeUntil(
|
||||
&input_, range_del_agg_, prev_snapshot, bottommost_level_,
|
||||
allow_data_in_errors_, blob_fetcher_.get(), full_history_ts_low_,
|
||||
prefetch_buffers_.get(), &iter_stats_);
|
||||
merge_out_iter_.SeekToFirst();
|
||||
uncombined_prefiltered_ = false;
|
||||
|
||||
if (!merge_until_status_.ok() &&
|
||||
!merge_until_status_.IsMergeInProgress()) {
|
||||
status_ = merge_until_status_;
|
||||
return;
|
||||
} else if (merge_out_iter_.Valid()) {
|
||||
if (merge_order_ == CompactionFilter::MergeOrder::kMergeBeforeFilter) {
|
||||
SelectMergeOutput(ValidContext::kMerge2);
|
||||
if (!status_.ok()) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// NOTE: key, value, and ikey_ refer to old entries.
|
||||
// These will be correctly set below.
|
||||
key_ = merge_out_iter_.key();
|
||||
value_ = merge_out_iter_.value();
|
||||
pik_status = ParseInternalKey(key_, &ikey_, allow_data_in_errors_);
|
||||
// MergeUntil stops when it encounters a corrupt key and does not
|
||||
// include them in the result, so we expect the keys here to valid.
|
||||
if (!pik_status.ok()) {
|
||||
ROCKS_LOG_FATAL(
|
||||
info_log_, "Invalid key %s in compaction. %s",
|
||||
allow_data_in_errors_ ? key_.ToString(true).c_str() : "hidden",
|
||||
pik_status.getState());
|
||||
assert(false);
|
||||
}
|
||||
// Keep current_key_ in sync.
|
||||
current_key_.UpdateInternalKey(ikey_.sequence, ikey_.type);
|
||||
key_ = current_key_.GetInternalKey();
|
||||
ikey_.user_key = current_key_.GetUserKey();
|
||||
validity_info_.SetValid(ValidContext::kMerge2);
|
||||
// NOTE: key, value, and ikey_ refer to old entries.
|
||||
// These will be correctly set below.
|
||||
key_ = merge_out_iter_.key();
|
||||
value_ = merge_out_iter_.value();
|
||||
pik_status = ParseInternalKey(key_, &ikey_, allow_data_in_errors_);
|
||||
// MergeUntil stops when it encounters a corrupt key and does not
|
||||
// include them in the result, so we expect the keys here to valid.
|
||||
if (!pik_status.ok()) {
|
||||
ROCKS_LOG_FATAL(
|
||||
info_log_, "Invalid key %s in compaction. %s",
|
||||
allow_data_in_errors_ ? key_.ToString(true).c_str() : "hidden",
|
||||
pik_status.getState());
|
||||
assert(false);
|
||||
}
|
||||
// Keep current_key_ in sync.
|
||||
current_key_.UpdateInternalKey(ikey_.sequence, ikey_.type);
|
||||
key_ = current_key_.GetInternalKey();
|
||||
ikey_.user_key = current_key_.GetUserKey();
|
||||
validity_info_.SetValid(ValidContext::kMerge2);
|
||||
} else {
|
||||
// all merge operands were filtered out. reset the user key, since the
|
||||
// batch consumed by the merge operator should not shadow any keys
|
||||
@@ -1656,7 +1364,7 @@ void CompactionIterator::NextFromInput() {
|
||||
if (should_delete) {
|
||||
++iter_stats_.num_record_drop_hidden;
|
||||
++iter_stats_.num_record_drop_range_del;
|
||||
AdvanceInputIterWithoutOutput();
|
||||
AdvanceInputIter();
|
||||
} else {
|
||||
validity_info_.SetValid(ValidContext::kNewUserKey);
|
||||
}
|
||||
@@ -1679,17 +1387,6 @@ void CompactionIterator::NextFromInput() {
|
||||
}
|
||||
}
|
||||
|
||||
bool CompactionIterator::DeletionIsObsolete() {
|
||||
return compaction_ &&
|
||||
(ikey_.type == kTypeDeletion ||
|
||||
(ikey_.type == kTypeDeletionWithTimestamp &&
|
||||
cmp_with_history_ts_low_ < 0)) &&
|
||||
!compaction_->allow_ingest_behind() &&
|
||||
DefinitelyInSnapshot(ikey_.sequence, earliest_snapshot_) &&
|
||||
compaction_->KeyNotExistsBeyondOutputLevel(ikey_.user_key,
|
||||
&level_ptrs_);
|
||||
}
|
||||
|
||||
bool CompactionIterator::ExtractLargeValueIfNeededImpl() {
|
||||
if (!blob_file_builder_) {
|
||||
return false;
|
||||
@@ -2158,31 +1855,6 @@ void CompactionIterator::GarbageCollectEntityBlobsIfNeeded() {
|
||||
fetched_blob_values, new_blob_columns);
|
||||
}
|
||||
|
||||
Status CompactionIterator::OutputHasExternalBlobReferences(
|
||||
bool* has_external_refs) const {
|
||||
assert(has_external_refs);
|
||||
*has_external_refs = false;
|
||||
if (ikey_.type == kTypeBlobIndex) {
|
||||
BlobIndex index;
|
||||
const Status s = index.DecodeFrom(value_);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
*has_external_refs = !index.IsInlined() && !index.IsSameFile();
|
||||
return Status::OK();
|
||||
}
|
||||
if (ikey_.type == kTypeWideColumnEntity) {
|
||||
return WideColumnSerialization::ForEachBlobFileNumber(
|
||||
value_, [has_external_refs](const BlobIndex& index) {
|
||||
if (!index.IsInlined() && !index.IsSameFile()) {
|
||||
*has_external_refs = true;
|
||||
}
|
||||
return Status::OK();
|
||||
});
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
void CompactionIterator::PrepareOutput() {
|
||||
if (Valid()) {
|
||||
if (LIKELY(!is_range_del_)) {
|
||||
@@ -2269,19 +1941,7 @@ void CompactionIterator::PrepareOutput() {
|
||||
if (BottommostSeqnoCanBeZeroed(
|
||||
ikey_.sequence, preserve_seqno_after_, timestamp_size_,
|
||||
full_history_ts_low_ != nullptr, cmp_with_history_ts_low_ < 0)) {
|
||||
bool has_external_blob_refs = false;
|
||||
if (timestamp_size_) {
|
||||
const Status s =
|
||||
OutputHasExternalBlobReferences(&has_external_blob_refs);
|
||||
if (!s.ok()) {
|
||||
status_ = s;
|
||||
(void)status_.ok();
|
||||
validity_info_.Invalidate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// External blob records include the timestamp in their stored user key.
|
||||
if (!timestamp_size_ || has_external_blob_refs) {
|
||||
if (!timestamp_size_) {
|
||||
current_key_.UpdateInternalKey(0, ikey_.type);
|
||||
} else {
|
||||
// For UDT, the seqno and timestamp could only be zeroed out after the
|
||||
|
||||
@@ -5,16 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <cinttypes>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "db/blob/blob_index.h"
|
||||
@@ -34,7 +29,6 @@ class BlobFileBuilder;
|
||||
class BlobFileCache;
|
||||
class BlobFetcher;
|
||||
class Version;
|
||||
class MissingBlobRepairIterator;
|
||||
class PrefetchBufferCollection;
|
||||
class FilePrefetchBuffer;
|
||||
class Version;
|
||||
@@ -280,8 +274,7 @@ class CompactionIterator {
|
||||
const std::string* full_history_ts_low = nullptr,
|
||||
std::optional<SequenceNumber> preserve_seqno_min = {},
|
||||
const Version* input_version = nullptr,
|
||||
Env::IOActivity blob_read_io_activity = Env::IOActivity::kCompaction,
|
||||
std::optional<uint64_t> blob_gc_cutoff_file_number = {});
|
||||
Env::IOActivity blob_read_io_activity = Env::IOActivity::kCompaction);
|
||||
|
||||
// Constructor with custom CompactionProxy, used for tests.
|
||||
CompactionIterator(
|
||||
@@ -303,8 +296,7 @@ class CompactionIterator {
|
||||
const std::string* full_history_ts_low = nullptr,
|
||||
std::optional<SequenceNumber> preserve_seqno_min = {},
|
||||
const Version* input_version = nullptr,
|
||||
Env::IOActivity blob_read_io_activity = Env::IOActivity::kCompaction,
|
||||
std::optional<uint64_t> blob_gc_cutoff_file_number = {});
|
||||
Env::IOActivity blob_read_io_activity = Env::IOActivity::kCompaction);
|
||||
|
||||
~CompactionIterator();
|
||||
|
||||
@@ -317,36 +309,16 @@ class CompactionIterator {
|
||||
Env::IOActivity io_activity,
|
||||
bool allow_write_path_fallback);
|
||||
|
||||
// Install before the first seek; the normalizer must outlive this iterator.
|
||||
void SetMissingBlobRepairIterator(const MissingBlobRepairIterator* iterator) {
|
||||
assert(key_.empty());
|
||||
missing_blob_repair_iterator_ = iterator;
|
||||
}
|
||||
|
||||
static uint64_t ComputeBlobGarbageCollectionCutoffFileNumber(
|
||||
const CompactionProxy* compaction);
|
||||
|
||||
// Seek to the beginning of the compaction iterator output.
|
||||
//
|
||||
// REQUIRED: Call only once.
|
||||
void SeekToFirst();
|
||||
|
||||
// Positions at the first output without extracting/relocating blobs yet.
|
||||
// CompactionJob uses this when an SST checkpoint may need to be persisted
|
||||
// before the current key is added to a blob file.
|
||||
void SeekToFirstWithoutPreparingOutput();
|
||||
|
||||
// Produces the next record in the compaction.
|
||||
//
|
||||
// REQUIRED: SeekToFirst() has been called.
|
||||
void Next();
|
||||
|
||||
// Advances without extracting/relocating blobs for the new current key.
|
||||
void NextWithoutPreparingOutput();
|
||||
|
||||
// Completes output preparation once for the current key.
|
||||
void PrepareOutputIfNeeded();
|
||||
|
||||
// Getters
|
||||
const Slice& key() const { return key_; }
|
||||
const Slice& value() const { return value_; }
|
||||
@@ -376,15 +348,6 @@ class CompactionIterator {
|
||||
return at_next_ || merge_out_iter_.Valid();
|
||||
}
|
||||
|
||||
// Returns true if an earlier input entry for the current valid user key was
|
||||
// consumed without being output.
|
||||
//
|
||||
// REQUIRED: Valid() must be true
|
||||
bool HasConsumedEarlierEntriesOfCurrentKey() const {
|
||||
assert(Valid());
|
||||
return has_consumed_earlier_entries_of_current_key_;
|
||||
}
|
||||
|
||||
Status InputStatus() const { return input_.status(); }
|
||||
|
||||
bool IsDeleteRangeSentinelKey() const { return is_range_del_; }
|
||||
@@ -393,8 +356,6 @@ class CompactionIterator {
|
||||
// Processes the input stream to find the next output
|
||||
void NextFromInput();
|
||||
|
||||
void NextImpl();
|
||||
|
||||
// Do final preparations before presenting the output to the callee.
|
||||
void PrepareOutput();
|
||||
|
||||
@@ -460,16 +421,7 @@ class CompactionIterator {
|
||||
|
||||
// Invoke compaction filter if needed.
|
||||
// Return true on success, false on failures (e.g.: kIOError).
|
||||
bool InvokeFilterIfNeeded(bool* need_skip, Slice* skip_until,
|
||||
bool merge_output);
|
||||
bool SelectMergeOutput(uint8_t valid_context);
|
||||
bool PrefilterUncombinedOutputs(uint8_t valid_context);
|
||||
bool ProcessDeletion(SequenceNumber prev_snapshot,
|
||||
bool input_already_advanced);
|
||||
|
||||
bool DeletionIsObsolete();
|
||||
|
||||
Status OutputHasExternalBlobReferences(bool* has_external_refs) const;
|
||||
bool InvokeFilterIfNeeded(bool* need_skip, Slice* skip_until);
|
||||
|
||||
// Given a sequence number, return the sequence number of the
|
||||
// earliest snapshot that this sequence number is visible in.
|
||||
@@ -504,6 +456,8 @@ class CompactionIterator {
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t ComputeBlobGarbageCollectionCutoffFileNumber(
|
||||
const CompactionProxy* compaction);
|
||||
static std::unique_ptr<BlobFetcher> CreateBlobFetcherIfNeeded(
|
||||
const CompactionProxy* compaction, const Version* input_version,
|
||||
Env::IOActivity blob_read_io_activity);
|
||||
@@ -511,7 +465,6 @@ class CompactionIterator {
|
||||
CreatePrefetchBufferCollectionIfNeeded(const CompactionProxy* compaction);
|
||||
|
||||
SequenceIterWrapper input_;
|
||||
const MissingBlobRepairIterator* missing_blob_repair_iterator_ = nullptr;
|
||||
const Comparator* cmp_;
|
||||
MergeHelper* merge_helper_;
|
||||
const std::vector<SequenceNumber>* snapshots_;
|
||||
@@ -531,7 +484,6 @@ class CompactionIterator {
|
||||
BlobFileBuilder* blob_file_builder_;
|
||||
std::unique_ptr<CompactionProxy> compaction_;
|
||||
const CompactionFilter* compaction_filter_;
|
||||
const CompactionFilter::MergeOrder merge_order_;
|
||||
const bool filter_supports_v4_;
|
||||
const std::atomic<bool>* shutting_down_;
|
||||
const std::atomic<bool>& manual_compaction_canceled_;
|
||||
@@ -605,8 +557,6 @@ class CompactionIterator {
|
||||
// If false, the iterator holds a copy of the current compaction iterator
|
||||
// output (or current key in the underlying iterator during NextFromInput()).
|
||||
bool at_next_ = false;
|
||||
// Whether an earlier input entry of the current user key was not output.
|
||||
bool has_consumed_earlier_entries_of_current_key_ = false;
|
||||
|
||||
// A copy of the current internal key.
|
||||
IterKey current_key_;
|
||||
@@ -624,17 +574,6 @@ class CompactionIterator {
|
||||
bool clear_and_output_next_key_ = false;
|
||||
|
||||
MergeOutputIterator merge_out_iter_;
|
||||
// Merge-before-filter decisions for the current batch of uncombined
|
||||
// operands. They are made before any operand is output, so
|
||||
// kRemoveAndSkipUntil drops the whole batch, as in the legacy order.
|
||||
struct UncombinedDecision {
|
||||
bool keep = true;
|
||||
bool changed = false;
|
||||
std::string value;
|
||||
};
|
||||
std::vector<UncombinedDecision> uncombined_decisions_;
|
||||
size_t uncombined_index_ = 0;
|
||||
bool uncombined_prefiltered_ = false;
|
||||
Status merge_until_status_;
|
||||
// PinnedIteratorsManager used to pin input_ Iterator blocks while reading
|
||||
// merge operands and then releasing them after consuming them.
|
||||
@@ -675,7 +614,6 @@ class CompactionIterator {
|
||||
// it) and PrepareOutput() can skip redundant work. Reset for each candidate
|
||||
// input record and whenever the filter rewrites the entity value.
|
||||
bool entity_deserialized_{false};
|
||||
bool output_prepared_{false};
|
||||
// "level_ptrs" holds indices that remember which file of an associated
|
||||
// level we were last checking during the last call to compaction->
|
||||
// KeyNotExistsBeyondOutputLevel(). This allows future calls to the function
|
||||
@@ -703,16 +641,7 @@ class CompactionIterator {
|
||||
|
||||
void AdvanceInputIter() { input_.Next(); }
|
||||
|
||||
// Advances past an input entry that will not be emitted as output.
|
||||
void AdvanceInputIterWithoutOutput() {
|
||||
has_consumed_earlier_entries_of_current_key_ = true;
|
||||
input_.Next();
|
||||
}
|
||||
|
||||
void SkipUntil(const Slice& skip_until) {
|
||||
has_consumed_earlier_entries_of_current_key_ = true;
|
||||
input_.Seek(skip_until);
|
||||
}
|
||||
void SkipUntil(const Slice& skip_until) { input_.Seek(skip_until); }
|
||||
|
||||
bool IsShuttingDown() {
|
||||
// This is a best-effort facility, so memory_order_relaxed is sufficient.
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+96
-592
File diff suppressed because it is too large.
Load diff
+14
-163
@@ -14,11 +14,9 @@
|
||||
#include <limits>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "db/blob/blob_counting_iterator.h"
|
||||
#include "db/blob/blob_file_completion_callback.h"
|
||||
#include "db/column_family.h"
|
||||
#include "db/compaction/compaction_iterator.h"
|
||||
@@ -53,7 +51,6 @@ class Arena;
|
||||
class CompactionState;
|
||||
class ErrorHandler;
|
||||
class MemTable;
|
||||
class MissingBlobRepairIterator;
|
||||
class SnapshotChecker;
|
||||
class SystemClock;
|
||||
class TableCache;
|
||||
@@ -174,25 +171,10 @@ class CompactionJob {
|
||||
|
||||
virtual ~CompactionJob();
|
||||
|
||||
using RemoteCompactionExecutor = std::function<void(std::function<void()>)>;
|
||||
using LocalCompactionExecutor =
|
||||
std::function<Status(std::function<void()>, Env::Priority)>;
|
||||
|
||||
// Set before Prepare(). Remote submissions are asynchronous: returning
|
||||
// accepts the task exactly once, and throwing must leave it unsubmitted.
|
||||
// Local execution blocks until the task finishes or is canceled. Both
|
||||
// executors must outlive Run(). Service workers leave these unset.
|
||||
void SetCompactionExecutors(RemoteCompactionExecutor remote_executor,
|
||||
LocalCompactionExecutor local_executor) {
|
||||
remote_compaction_executor_ = std::move(remote_executor);
|
||||
local_compaction_executor_ = std::move(local_executor);
|
||||
}
|
||||
|
||||
// no copy/move
|
||||
CompactionJob(CompactionJob&& job) = delete;
|
||||
CompactionJob(const CompactionJob& job) = delete;
|
||||
CompactionJob& operator=(const CompactionJob& job) = delete;
|
||||
CompactionJob& operator=(CompactionJob&& job) = delete;
|
||||
|
||||
// REQUIRED: mutex held
|
||||
// Prepare for the compaction by setting up boundaries for each subcompaction
|
||||
@@ -240,7 +222,6 @@ class CompactionJob {
|
||||
|
||||
// Iterate through input and compact the kv-pairs.
|
||||
void ProcessKeyValueCompaction(SubcompactionState* sub_compact);
|
||||
void ProcessLocalKeyValueCompaction(SubcompactionState* sub_compact);
|
||||
|
||||
CompactionState* compact_;
|
||||
InternalStats::CompactionStatsFull internal_stats_;
|
||||
@@ -258,10 +239,6 @@ class CompactionJob {
|
||||
|
||||
CompactionJobStats* job_stats_;
|
||||
|
||||
// Lower bound for the minimal sequence number whose write time is
|
||||
// preserved. See Prepare().
|
||||
SequenceNumber preserve_time_min_seqno_floor_ = 0;
|
||||
|
||||
private:
|
||||
friend class CompactionJobTestBase;
|
||||
|
||||
@@ -329,7 +306,6 @@ class CompactionJob {
|
||||
|
||||
void InitializeCompactionRun();
|
||||
void RunSubcompactions();
|
||||
void RecordRemoteCompactionInputBlobFileCount();
|
||||
void UpdateTimingStats(uint64_t start_micros);
|
||||
void RemoveEmptyOutputs();
|
||||
void CleanupAbortedSubcompactions();
|
||||
@@ -349,8 +325,7 @@ class CompactionJob {
|
||||
uint64_t num_input_range_del);
|
||||
|
||||
CompactionServiceJobStatus ProcessKeyValueCompactionWithCompactionService(
|
||||
SubcompactionState* sub_compact,
|
||||
CompactionFilter::MergeOrder merge_order);
|
||||
SubcompactionState* sub_compact);
|
||||
|
||||
struct CompactionIOStatsSnapshot {
|
||||
PerfLevel prev_perf_level = PerfLevel::kEnableTime;
|
||||
@@ -394,9 +369,8 @@ class CompactionJob {
|
||||
struct SubcompactionInternalIterators {
|
||||
std::unique_ptr<InternalIterator> raw_input;
|
||||
std::unique_ptr<InternalIterator> clip;
|
||||
std::unique_ptr<BlobCountingIterator> blob_counter;
|
||||
std::unique_ptr<InternalIterator> blob_counter;
|
||||
std::unique_ptr<InternalIterator> trim_history_iter;
|
||||
std::unique_ptr<MissingBlobRepairIterator> missing_blob_repair;
|
||||
};
|
||||
|
||||
bool ShouldUseLocalCompaction(SubcompactionState* sub_compact);
|
||||
@@ -405,8 +379,7 @@ class CompactionJob {
|
||||
SubcompactionState* sub_compact,
|
||||
const CompactionFilter* configured_compaction_filter,
|
||||
const CompactionFilter*& compaction_filter,
|
||||
std::unique_ptr<CompactionFilter>& compaction_filter_from_factory,
|
||||
CompactionFilter::MergeOrder& merge_order);
|
||||
std::unique_ptr<CompactionFilter>& compaction_filter_from_factory);
|
||||
void InitializeReadOptionsAndBoundaries(
|
||||
size_t ts_sz, ReadOptions& read_options,
|
||||
SubcompactionKeyBoundaries& boundaries);
|
||||
@@ -424,14 +397,11 @@ class CompactionJob {
|
||||
MergeHelper& merge, std::unique_ptr<BlobFileBuilder>& blob_file_builder,
|
||||
const WriteOptions& write_options);
|
||||
std::pair<CompactionFileOpenFunc, CompactionFileCloseFunc> CreateFileHandlers(
|
||||
SubcompactionState* sub_compact, SubcompactionKeyBoundaries& boundaries,
|
||||
BlobFileBuilder* blob_file_builder,
|
||||
const BlobCountingIterator* blob_counter);
|
||||
SubcompactionState* sub_compact, SubcompactionKeyBoundaries& boundaries);
|
||||
Status ProcessKeyValue(SubcompactionState* sub_compact, ColumnFamilyData* cfd,
|
||||
CompactionIterator* c_iter,
|
||||
const CompactionFileOpenFunc& open_file_func,
|
||||
const CompactionFileCloseFunc& close_file_func,
|
||||
bool defer_blob_output_preparation,
|
||||
uint64_t& prev_cpu_micros);
|
||||
void UpdateSubcompactionJobStatsIncrementally(
|
||||
CompactionIterator* c_iter, CompactionJobStats* compaction_job_stats,
|
||||
@@ -460,17 +430,15 @@ class CompactionJob {
|
||||
uint64_t prev_cpu_micros,
|
||||
const CompactionIOStatsSnapshot& io_stats);
|
||||
|
||||
// update the thread status for starting a compaction.
|
||||
void ReportStartedCompaction(Compaction* compaction);
|
||||
void InitializeThreadStatus();
|
||||
|
||||
Status FinishCompactionOutputFile(
|
||||
const Status& input_status,
|
||||
const ParsedInternalKey& prev_iter_output_internal_key,
|
||||
const Slice& next_table_min_key, const Slice* comp_start_user_key,
|
||||
const Slice* comp_end_user_key, const CompactionIterator* c_iter,
|
||||
bool post_prepare_retry, SubcompactionState* sub_compact,
|
||||
BlobFileBuilder* blob_file_builder,
|
||||
const BlobCountingIterator* blob_counter, CompactionOutputs& outputs);
|
||||
SubcompactionState* sub_compact, CompactionOutputs& outputs);
|
||||
Status InstallCompactionResults(bool* compaction_released);
|
||||
Status OpenCompactionOutputFile(SubcompactionState* sub_compact,
|
||||
CompactionOutputs& outputs);
|
||||
@@ -483,8 +451,6 @@ class CompactionJob {
|
||||
void NotifyOnSubcompactionCompleted(SubcompactionState* sub_compact);
|
||||
|
||||
uint32_t job_id_;
|
||||
// Limits unsafe resume-boundary diagnostics to one per compaction job.
|
||||
mutable std::atomic<bool> logged_unsafe_resume_boundary_{false};
|
||||
|
||||
// DBImpl state
|
||||
const std::string& dbname_;
|
||||
@@ -540,8 +506,6 @@ class CompactionJob {
|
||||
// has no owning DBImpl to report to (compaction service workers, unit tests).
|
||||
// Updated without the DB mutex held.
|
||||
std::atomic<int>* num_running_remote_compactions_;
|
||||
RemoteCompactionExecutor remote_compaction_executor_;
|
||||
LocalCompactionExecutor local_compaction_executor_;
|
||||
|
||||
// Stores the sequence number to time mapping gathered from all input files
|
||||
// it also collects the smallest_seqno -> oldest_ancestor_time from the SST.
|
||||
@@ -567,45 +531,16 @@ class CompactionJob {
|
||||
uint64_t min_manifest_file_number_ = 0;
|
||||
uint64_t min_manifest_file_size_ = 0;
|
||||
|
||||
// Remote subcompactions run concurrently and validate their blob garbage
|
||||
// before moving output into the primary. This aggregate prevents each
|
||||
// subcompaction from independently claiming up to the same blob-file total.
|
||||
port::Mutex remote_blob_garbage_mutex_;
|
||||
std::unordered_map<uint64_t, BlobGarbageMeter::BlobStats>
|
||||
remote_blob_garbage_;
|
||||
|
||||
// Minimum blob-file dependency among subcompactions successfully dispatched
|
||||
// to a remote worker. Recorded once for the whole job after they finish.
|
||||
std::atomic<uint64_t> remote_compaction_min_blob_file_number_{
|
||||
std::numeric_limits<uint64_t>::max()};
|
||||
|
||||
// Writer for persisting compaction progress during compaction
|
||||
log::Writer* compaction_progress_writer_ = nullptr;
|
||||
|
||||
// Get table file name in where it's outputting to, which should also be in
|
||||
// `output_directory_`.
|
||||
virtual std::string GetTableFileName(uint64_t file_number);
|
||||
virtual const std::string& GetBlobOutputPath() const;
|
||||
virtual uint64_t NewBlobFileNumber();
|
||||
virtual uint64_t GetNextBlobFileNumber() const;
|
||||
virtual Status RestoreNextBlobFileNumber(
|
||||
const SubcompactionProgress& subcompaction_progress);
|
||||
virtual std::optional<uint64_t> GetBlobGarbageCollectionCutoffFileNumber()
|
||||
const {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// True if this job builds output files as a remote (offloaded)
|
||||
// CompactionService worker. Overridden by CompactionServiceCompactionJob.
|
||||
virtual bool IsRemoteCompaction() const { return false; }
|
||||
// Checks the actual filter order against what the job requires before any
|
||||
// input is processed. A remote worker compares it with the primary's
|
||||
// request and records the acknowledgment or decline in its result.
|
||||
virtual Status ValidateCompactionFilterMergeOrder(
|
||||
const CompactionFilter* /*compaction_filter*/,
|
||||
CompactionFilter::MergeOrder /*merge_order*/) {
|
||||
return Status::OK();
|
||||
}
|
||||
// The rate limiter priority (io_priority) is determined dynamically here.
|
||||
// The Compaction Read and Write priorities are the same for different
|
||||
// scenarios, such as write stalled.
|
||||
@@ -619,7 +554,7 @@ class CompactionJob {
|
||||
const ReadOptions& read_options,
|
||||
std::vector<std::shared_ptr<const TableProperties>>&
|
||||
output_files_table_properties,
|
||||
bool is_proximal_level);
|
||||
bool is_proximal_level = false);
|
||||
|
||||
Status ReadTablePropertiesDirectly(
|
||||
const ImmutableOptions& ioptions, const MutableCFOptions& moptions,
|
||||
@@ -636,22 +571,12 @@ class CompactionJob {
|
||||
bool ShouldUpdateSubcompactionProgress(
|
||||
const SubcompactionState* sub_compact, const CompactionIterator* c_iter,
|
||||
const ParsedInternalKey& prev_iter_output_internal_key,
|
||||
const Slice& next_table_min_internal_key, const FileMetaData* meta,
|
||||
const BlobFileBuilder* blob_file_builder,
|
||||
const BlobCountingIterator* blob_counter, bool post_prepare_retry) const;
|
||||
const Slice& next_table_min_internal_key, const FileMetaData* meta) const;
|
||||
|
||||
void UpdateSubcompactionProgress(const CompactionIterator* c_iter,
|
||||
const Slice next_table_min_key,
|
||||
SubcompactionState* sub_compact);
|
||||
|
||||
Status RestoreBlobCompactionProgress(
|
||||
SubcompactionState* sub_compact,
|
||||
const SubcompactionProgress& subcompaction_progress);
|
||||
|
||||
void UpdateBlobCompactionProgress(
|
||||
SubcompactionState* sub_compact,
|
||||
SubcompactionProgress& subcompaction_progress);
|
||||
|
||||
Status PersistSubcompactionProgress(SubcompactionState* sub_compact);
|
||||
|
||||
void UpdateSubcompactionProgressPerLevel(
|
||||
@@ -659,12 +584,6 @@ class CompactionJob {
|
||||
SubcompactionProgress& subcompaction_progress);
|
||||
};
|
||||
|
||||
// Version of the blob-aware remote compaction result produced by this binary.
|
||||
// Zero means the worker did not advertise support.
|
||||
constexpr uint64_t kCompactionServiceBlobVersion = 1;
|
||||
constexpr uint64_t kCompactionServiceBlobGCCutoffVersion = 1;
|
||||
constexpr uint64_t kCompactionServiceMergeBeforeFilterVersion = 1;
|
||||
|
||||
// CompactionServiceInput is used the pass compaction information between two
|
||||
// db instances. It contains the information needed to do a compaction. It
|
||||
// doesn't contain the LSM tree information, which is passed though MANIFEST
|
||||
@@ -672,11 +591,6 @@ constexpr uint64_t kCompactionServiceMergeBeforeFilterVersion = 1;
|
||||
struct CompactionServiceInput {
|
||||
std::string cf_name;
|
||||
|
||||
// Requests merge-before-filter. Old workers ignore this field and return no
|
||||
// applied-order acknowledgment, so the primary falls back to local compaction
|
||||
// before importing their output.
|
||||
bool merge_before_filter = false;
|
||||
|
||||
// Snapshot sequence numbers in strictly increasing order.
|
||||
std::vector<SequenceNumber> snapshots;
|
||||
|
||||
@@ -684,23 +598,6 @@ struct CompactionServiceInput {
|
||||
// files needed for this compaction, for both input level files and output
|
||||
// level files.
|
||||
std::vector<std::string> input_files;
|
||||
|
||||
// Blob files potentially referenced by input_files. CompactionService
|
||||
// implementations can use this list to make the files available to the
|
||||
// remote worker.
|
||||
std::vector<std::string> input_blob_files;
|
||||
|
||||
// When present, the remote worker uses this primary-computed cutoff instead
|
||||
// of deriving one from its reconstructed Version. An absent field disables
|
||||
// blob GC on the worker for compatibility with older primaries.
|
||||
bool has_blob_gc_cutoff_file_number = false;
|
||||
uint64_t blob_gc_cutoff_file_number = 0;
|
||||
|
||||
// The primary reserves this half-open file-number range before scheduling
|
||||
// the remote compaction. A worker that creates blob files must allocate them
|
||||
// consecutively from this range.
|
||||
uint64_t blob_file_number_start = kInvalidBlobFileNumber;
|
||||
uint64_t blob_file_number_limit = kInvalidBlobFileNumber;
|
||||
int output_level = 0;
|
||||
|
||||
// db_id is used to generate unique id of sst on the remote compactor
|
||||
@@ -726,24 +623,6 @@ struct CompactionServiceInput {
|
||||
uint64_t min_manifest_file_number = 0;
|
||||
uint64_t min_manifest_file_size = 0;
|
||||
|
||||
// The primary's values. The worker opens the DB as a secondary, which
|
||||
// sanitizes them to 0 as a read-only DB. They are sent here rather than
|
||||
// re-read from the OPTIONS file so that they always arrive together with
|
||||
// preserve_time_min_seqno_floor: a preserve window without that floor would
|
||||
// bring back the kBottommostFiles compaction loop.
|
||||
uint64_t preserve_internal_time_seconds = 0;
|
||||
uint64_t preclude_last_level_data_seconds = 0;
|
||||
// The primary's lower bound for the minimal sequence number whose write time
|
||||
// is preserved: the version-carried preserve boundary for a kBottommostFiles
|
||||
// compaction, 0 otherwise.
|
||||
SequenceNumber preserve_time_min_seqno_floor = 0;
|
||||
// The primary's per-key placement decisions. The worker declines the job if
|
||||
// its own Compaction differs. proximal_level is Compaction::kInvalidLevel
|
||||
// when per-key placement is off, and 0 only from an older primary.
|
||||
int proximal_level = 0;
|
||||
int proximal_output_range_type = 0;
|
||||
SequenceNumber keep_in_last_level_through_seqno = 0;
|
||||
|
||||
// serialization interface to read and write the object
|
||||
static Status Read(const std::string& data_str, CompactionServiceInput* obj);
|
||||
Status Write(std::string* output);
|
||||
@@ -754,9 +633,7 @@ struct CompactionServiceInput {
|
||||
#endif // NDEBUG
|
||||
};
|
||||
|
||||
// CompactionServiceOutputFile is the metadata for the output SST file. Parsing
|
||||
// a serialized result sets only the fields present in it, so every member
|
||||
// needs a default value.
|
||||
// CompactionServiceOutputFile is the metadata for the output SST file
|
||||
struct CompactionServiceOutputFile {
|
||||
std::string file_name;
|
||||
uint64_t file_size{};
|
||||
@@ -764,26 +641,25 @@ struct CompactionServiceOutputFile {
|
||||
SequenceNumber largest_seqno{};
|
||||
std::string smallest_internal_key;
|
||||
std::string largest_internal_key;
|
||||
uint64_t oldest_blob_file_number = kInvalidBlobFileNumber;
|
||||
uint64_t oldest_ancestor_time = kUnknownOldestAncestorTime;
|
||||
uint64_t file_creation_time = kUnknownFileCreationTime;
|
||||
uint64_t epoch_number = kUnknownEpochNumber;
|
||||
std::string file_checksum = kUnknownFileChecksum;
|
||||
std::string file_checksum_func_name = kUnknownFileChecksumFuncName;
|
||||
uint64_t paranoid_hash{};
|
||||
bool marked_for_compaction = false;
|
||||
bool marked_for_compaction;
|
||||
UniqueId64x2 unique_id{};
|
||||
TableProperties table_properties;
|
||||
bool is_proximal_level_output = false;
|
||||
bool is_proximal_level_output;
|
||||
Temperature file_temperature = Temperature::kUnknown;
|
||||
|
||||
CompactionServiceOutputFile() = default;
|
||||
CompactionServiceOutputFile(
|
||||
const std::string& name, uint64_t size, SequenceNumber smallest,
|
||||
SequenceNumber largest, std::string _smallest_internal_key,
|
||||
std::string _largest_internal_key, uint64_t _oldest_blob_file_number,
|
||||
uint64_t _oldest_ancestor_time, uint64_t _file_creation_time,
|
||||
uint64_t _epoch_number, const std::string& _file_checksum,
|
||||
std::string _largest_internal_key, uint64_t _oldest_ancestor_time,
|
||||
uint64_t _file_creation_time, uint64_t _epoch_number,
|
||||
const std::string& _file_checksum,
|
||||
const std::string& _file_checksum_func_name, uint64_t _paranoid_hash,
|
||||
bool _marked_for_compaction, UniqueId64x2 _unique_id,
|
||||
const TableProperties& _table_properties, bool _is_proximal_level_output,
|
||||
@@ -794,7 +670,6 @@ struct CompactionServiceOutputFile {
|
||||
largest_seqno(largest),
|
||||
smallest_internal_key(std::move(_smallest_internal_key)),
|
||||
largest_internal_key(std::move(_largest_internal_key)),
|
||||
oldest_blob_file_number(_oldest_blob_file_number),
|
||||
oldest_ancestor_time(_oldest_ancestor_time),
|
||||
file_creation_time(_file_creation_time),
|
||||
epoch_number(_epoch_number),
|
||||
@@ -813,19 +688,7 @@ struct CompactionServiceOutputFile {
|
||||
// permission is able to install the result to the DB.
|
||||
struct CompactionServiceResult {
|
||||
Status status;
|
||||
// Nonzero only after validating the actual worker filter/factory order.
|
||||
uint64_t merge_before_filter_version = 0;
|
||||
// The worker declined an order mismatch before processing input records.
|
||||
bool merge_order_mismatch = false;
|
||||
std::vector<CompactionServiceOutputFile> output_files;
|
||||
|
||||
// Blob metadata generated by the remote compaction. Blob file additions
|
||||
// identify files in output_path that must be installed before the output
|
||||
// SSTs. Garbage records apply to blob files already known to the primary.
|
||||
std::vector<BlobFileAddition> blob_file_additions;
|
||||
std::vector<BlobFileGarbage> blob_file_garbages;
|
||||
uint64_t blob_compaction_version = 0;
|
||||
uint64_t blob_gc_cutoff_version = 0;
|
||||
int output_level = 0;
|
||||
|
||||
// location of the output files
|
||||
@@ -898,25 +761,13 @@ class CompactionServiceCompactionJob : private CompactionJob {
|
||||
private:
|
||||
// Get table file name in output_path
|
||||
std::string GetTableFileName(uint64_t file_number) override;
|
||||
const std::string& GetBlobOutputPath() const override;
|
||||
uint64_t NewBlobFileNumber() override;
|
||||
uint64_t GetNextBlobFileNumber() const override;
|
||||
Status RestoreNextBlobFileNumber(
|
||||
const SubcompactionProgress& subcompaction_progress) override;
|
||||
std::optional<uint64_t> GetBlobGarbageCollectionCutoffFileNumber()
|
||||
const override;
|
||||
bool IsRemoteCompaction() const override { return true; }
|
||||
Status ValidateCompactionFilterMergeOrder(
|
||||
const CompactionFilter* compaction_filter,
|
||||
CompactionFilter::MergeOrder merge_order) override;
|
||||
// Specific the compaction output path, otherwise it uses default DB path
|
||||
const std::string output_path_;
|
||||
|
||||
// Compaction job input
|
||||
const CompactionServiceInput& compaction_input_;
|
||||
|
||||
uint64_t next_blob_file_number_;
|
||||
|
||||
// Compaction job result
|
||||
CompactionServiceResult* compaction_result_;
|
||||
};
|
||||
|
||||
@@ -196,42 +196,6 @@ class MockTestFileSystem : public FileSystemWrapper {
|
||||
|
||||
enum TableTypeForTest : uint8_t { kMockTable = 0, kBlockBasedTable = 1 };
|
||||
|
||||
// Replaces the first scalar `name=value;` entry after `scope` in a serialized
|
||||
// CompactionServiceResult with `replacement`. An empty `replacement` removes
|
||||
// the entry. Returns false if there is no such entry.
|
||||
bool ReplaceResultEntry(std::string* serialized, const std::string& scope,
|
||||
const std::string& name,
|
||||
const std::string& replacement) {
|
||||
const size_t scope_pos = serialized->find(scope);
|
||||
if (scope_pos == std::string::npos) {
|
||||
return false;
|
||||
}
|
||||
// Match the whole name, so that "code" does not match "subcode".
|
||||
size_t pos = std::string::npos;
|
||||
for (const char delimiter : {'{', ';'}) {
|
||||
pos = std::min(pos, serialized->find(delimiter + name + "=", scope_pos));
|
||||
}
|
||||
if (pos == std::string::npos) {
|
||||
return false;
|
||||
}
|
||||
const size_t end = serialized->find(';', pos + 1);
|
||||
if (end == std::string::npos) {
|
||||
return false;
|
||||
}
|
||||
serialized->replace(pos + 1, end - pos, replacement);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Formats every field of `s`. A failed gtest comparison prints the `Status`
|
||||
// enums as raw characters, so tests compare these strings instead.
|
||||
std::string StatusFields(const Status& s) {
|
||||
const char* state = s.getState();
|
||||
return "code=" + std::to_string(s.code()) +
|
||||
" subcode=" + std::to_string(s.subcode()) +
|
||||
" severity=" + std::to_string(s.severity()) +
|
||||
" message=" + (state != nullptr ? state : "");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class CompactionJobTestBase : public testing::Test {
|
||||
@@ -358,10 +322,8 @@ class CompactionJobTestBase : public testing::Test {
|
||||
assert(contents.size() > 0);
|
||||
|
||||
bool first_key = true;
|
||||
std::string smallest;
|
||||
std::string largest;
|
||||
InternalKey smallest_key;
|
||||
InternalKey largest_key;
|
||||
std::string smallest, largest;
|
||||
InternalKey smallest_key, largest_key;
|
||||
SequenceNumber smallest_seqno = kMaxSequenceNumber;
|
||||
SequenceNumber largest_seqno = 0;
|
||||
uint64_t oldest_blob_file_number = kInvalidBlobFileNumber;
|
||||
@@ -823,20 +785,6 @@ TEST_F(CompactionJobTest, Simple) {
|
||||
RunCompaction({files}, {input_level}, {expected_results});
|
||||
}
|
||||
|
||||
TEST_F(CompactionJobTest, AtomicallyAllocatesFileNumberRange) {
|
||||
NewDB();
|
||||
|
||||
const uint64_t next = versions_->current_next_file_number();
|
||||
uint64_t first = 0;
|
||||
ASSERT_TRUE(versions_->TryAllocateFileNumberRange(3, &first));
|
||||
ASSERT_EQ(first, next);
|
||||
ASSERT_EQ(versions_->current_next_file_number(), next + 3);
|
||||
|
||||
ASSERT_FALSE(versions_->TryAllocateFileNumberRange(0, &first));
|
||||
ASSERT_FALSE(versions_->TryAllocateFileNumberRange(1, nullptr));
|
||||
ASSERT_EQ(versions_->current_next_file_number(), next + 3);
|
||||
}
|
||||
|
||||
TEST_F(CompactionJobTest, DISABLED_SimpleCorrupted) {
|
||||
NewDB();
|
||||
|
||||
@@ -1633,14 +1581,6 @@ TEST_F(CompactionJobTest, InputSerialization) {
|
||||
rnd.Uniform(kStrMaxLen - 1) +
|
||||
1)); // input file name should have at least one character
|
||||
}
|
||||
do {
|
||||
input.input_blob_files.emplace_back(
|
||||
rnd.RandomString(rnd.Uniform(kStrMaxLen - 1) + 1));
|
||||
} while (!rnd.OneIn(10));
|
||||
input.has_blob_gc_cutoff_file_number = true;
|
||||
input.blob_gc_cutoff_file_number = rnd64.Uniform(UINT64_MAX);
|
||||
input.blob_file_number_start = 123;
|
||||
input.blob_file_number_limit = 456;
|
||||
input.output_level = 4;
|
||||
input.has_begin = rnd.OneIn(2);
|
||||
if (input.has_begin) {
|
||||
@@ -1650,12 +1590,6 @@ TEST_F(CompactionJobTest, InputSerialization) {
|
||||
if (input.has_end) {
|
||||
input.end = rnd.RandomBinaryString(rnd.Uniform(kStrMaxLen));
|
||||
}
|
||||
input.preserve_internal_time_seconds = rnd64.Uniform(UINT64_MAX);
|
||||
input.preclude_last_level_data_seconds = rnd64.Uniform(UINT64_MAX);
|
||||
input.preserve_time_min_seqno_floor = rnd64.Uniform(UINT64_MAX);
|
||||
input.proximal_level = static_cast<int>(rnd.Uniform(8)) - 1;
|
||||
input.proximal_output_range_type = static_cast<int>(rnd.Uniform(4));
|
||||
input.keep_in_last_level_through_seqno = rnd64.Uniform(UINT64_MAX);
|
||||
|
||||
std::string output;
|
||||
ASSERT_OK(input.Write(&output));
|
||||
@@ -1664,7 +1598,6 @@ TEST_F(CompactionJobTest, InputSerialization) {
|
||||
CompactionServiceInput deserialized1;
|
||||
ASSERT_OK(CompactionServiceInput::Read(output, &deserialized1));
|
||||
ASSERT_TRUE(deserialized1.TEST_Equals(&input));
|
||||
ASSERT_EQ(deserialized1.input_blob_files, input.input_blob_files);
|
||||
|
||||
// Test mismatch
|
||||
deserialized1.output_level += 10;
|
||||
@@ -1681,54 +1614,6 @@ TEST_F(CompactionJobTest, InputSerialization) {
|
||||
ASSERT_OK(CompactionServiceInput::Read(output, &deserialized2));
|
||||
ASSERT_TRUE(deserialized2.TEST_Equals(&input));
|
||||
|
||||
std::string old_input = output;
|
||||
auto remove_field = [](const std::string& field, std::string* serialized) {
|
||||
const size_t pos = serialized->find(field + "=");
|
||||
ASSERT_NE(pos, std::string::npos);
|
||||
const size_t end = serialized->find(';', pos);
|
||||
ASSERT_NE(end, std::string::npos);
|
||||
serialized->erase(pos, end - pos + 1);
|
||||
};
|
||||
remove_field("input_blob_files", &old_input);
|
||||
remove_field("has_blob_gc_cutoff_file_number", &old_input);
|
||||
remove_field("blob_gc_cutoff_file_number", &old_input);
|
||||
remove_field("blob_file_number_start", &old_input);
|
||||
remove_field("blob_file_number_limit", &old_input);
|
||||
CompactionServiceInput deserialized_old_input;
|
||||
deserialized_old_input.input_blob_files.emplace_back("stale.blob");
|
||||
deserialized_old_input.has_blob_gc_cutoff_file_number = true;
|
||||
deserialized_old_input.blob_gc_cutoff_file_number = 123;
|
||||
deserialized_old_input.blob_file_number_start = 1;
|
||||
deserialized_old_input.blob_file_number_limit = 2;
|
||||
ASSERT_OK(CompactionServiceInput::Read(old_input, &deserialized_old_input));
|
||||
ASSERT_TRUE(deserialized_old_input.input_blob_files.empty());
|
||||
ASSERT_FALSE(deserialized_old_input.has_blob_gc_cutoff_file_number);
|
||||
ASSERT_EQ(deserialized_old_input.blob_gc_cutoff_file_number, 0);
|
||||
ASSERT_EQ(deserialized_old_input.blob_file_number_start,
|
||||
kInvalidBlobFileNumber);
|
||||
ASSERT_EQ(deserialized_old_input.blob_file_number_limit,
|
||||
kInvalidBlobFileNumber);
|
||||
|
||||
CompactionServiceInput invalid_range_input = input;
|
||||
invalid_range_input.blob_file_number_start = 456;
|
||||
invalid_range_input.blob_file_number_limit = 123;
|
||||
std::string invalid_range;
|
||||
ASSERT_OK(invalid_range_input.Write(&invalid_range));
|
||||
CompactionServiceInput parsed_invalid_range;
|
||||
ASSERT_TRUE(CompactionServiceInput::Read(invalid_range, &parsed_invalid_range)
|
||||
.IsInvalidArgument());
|
||||
|
||||
// Test malformed hex in an encoded string field
|
||||
const std::string cf_name_field = "cf_name=";
|
||||
std::string malformed_hex;
|
||||
ASSERT_OK(input.Write(&malformed_hex));
|
||||
const size_t cf_name_pos = malformed_hex.find(cf_name_field);
|
||||
ASSERT_NE(cf_name_pos, std::string::npos);
|
||||
malformed_hex.insert(cf_name_pos + cf_name_field.size(), "Z");
|
||||
CompactionServiceInput parsed_malformed_hex;
|
||||
ASSERT_TRUE(CompactionServiceInput::Read(malformed_hex, &parsed_malformed_hex)
|
||||
.IsInvalidArgument());
|
||||
|
||||
// Test missing field
|
||||
CompactionServiceInput deserialized3;
|
||||
deserialized3.output_level = 0;
|
||||
@@ -1817,7 +1702,6 @@ TEST_F(CompactionJobTest, ResultSerialization) {
|
||||
rnd.Uniform(kStrMaxLen)) /* smallest_internal_key */,
|
||||
rnd.RandomBinaryString(
|
||||
rnd.Uniform(kStrMaxLen)) /* largest_internal_key */,
|
||||
rnd64.Uniform(UINT64_MAX - 1) + 1 /* oldest_blob_file_number */,
|
||||
rnd64.Uniform(UINT64_MAX) /* oldest_ancestor_time */,
|
||||
rnd64.Uniform(UINT64_MAX) /* file_creation_time */,
|
||||
rnd64.Uniform(UINT64_MAX) /* epoch_number */,
|
||||
@@ -1827,15 +1711,6 @@ TEST_F(CompactionJobTest, ResultSerialization) {
|
||||
rnd.OneIn(2) /* marked_for_compaction */, id /* unique_id */, tp,
|
||||
false /* is_proximal_level_output */, Temperature::kHot);
|
||||
}
|
||||
result.blob_file_additions.emplace_back(123, 2, 4096, "checksum",
|
||||
rnd.RandomBinaryString(16));
|
||||
result.blob_file_additions.emplace_back(0, 0, 0, "", "");
|
||||
result.blob_file_additions.emplace_back();
|
||||
result.blob_file_garbages.emplace_back(123, 1, 2048);
|
||||
result.blob_file_garbages.emplace_back(0, 0, 0);
|
||||
result.blob_file_garbages.emplace_back();
|
||||
result.blob_compaction_version = kCompactionServiceBlobVersion;
|
||||
result.blob_gc_cutoff_version = kCompactionServiceBlobGCCutoffVersion;
|
||||
result.output_level = rnd.Uniform(10);
|
||||
result.output_path = rnd.RandomString(rnd.Uniform(kStrMaxLen));
|
||||
result.stats.num_output_records = rnd64.Uniform(UINT64_MAX);
|
||||
@@ -1854,14 +1729,6 @@ TEST_F(CompactionJobTest, ResultSerialization) {
|
||||
CompactionServiceResult deserialized1;
|
||||
ASSERT_OK(CompactionServiceResult::Read(output, &deserialized1));
|
||||
ASSERT_TRUE(deserialized1.TEST_Equals(&result));
|
||||
ASSERT_EQ(deserialized1.blob_file_additions.size(), 3);
|
||||
ASSERT_EQ(deserialized1.blob_file_additions[1].GetBlobFileNumber(), 0);
|
||||
ASSERT_EQ(deserialized1.blob_file_additions[2].GetBlobFileNumber(),
|
||||
kInvalidBlobFileNumber);
|
||||
ASSERT_EQ(deserialized1.blob_file_garbages.size(), 3);
|
||||
ASSERT_EQ(deserialized1.blob_file_garbages[1].GetBlobFileNumber(), 0);
|
||||
ASSERT_EQ(deserialized1.blob_file_garbages[2].GetBlobFileNumber(),
|
||||
kInvalidBlobFileNumber);
|
||||
|
||||
for (size_t i = 0; i < result.output_files.size(); i++) {
|
||||
for (const auto& prop :
|
||||
@@ -1909,44 +1776,11 @@ TEST_F(CompactionJobTest, ResultSerialization) {
|
||||
ASSERT_OK(CompactionServiceResult::Read(output, &deserialized2));
|
||||
ASSERT_TRUE(deserialized2.TEST_Equals(&result));
|
||||
|
||||
std::string old_result = output;
|
||||
size_t pos = old_result.find("blob_file_additions=");
|
||||
ASSERT_NE(pos, std::string::npos);
|
||||
size_t end = old_result.find(';', pos);
|
||||
ASSERT_NE(end, std::string::npos);
|
||||
old_result.erase(pos, end - pos + 1);
|
||||
pos = old_result.find("blob_file_garbages=");
|
||||
ASSERT_NE(pos, std::string::npos);
|
||||
end = old_result.find(';', pos);
|
||||
ASSERT_NE(end, std::string::npos);
|
||||
old_result.erase(pos, end - pos + 1);
|
||||
pos = old_result.find("blob_compaction_version=");
|
||||
ASSERT_NE(pos, std::string::npos);
|
||||
end = old_result.find(';', pos);
|
||||
ASSERT_NE(end, std::string::npos);
|
||||
old_result.erase(pos, end - pos + 1);
|
||||
pos = old_result.find("blob_gc_cutoff_version=");
|
||||
ASSERT_NE(pos, std::string::npos);
|
||||
end = old_result.find(';', pos);
|
||||
ASSERT_NE(end, std::string::npos);
|
||||
old_result.erase(pos, end - pos + 1);
|
||||
CompactionServiceResult deserialized_old_result;
|
||||
deserialized_old_result.blob_file_additions.emplace_back(321, 1, 1024, "",
|
||||
"");
|
||||
deserialized_old_result.blob_file_garbages.emplace_back(321, 1, 1024);
|
||||
ASSERT_OK(
|
||||
CompactionServiceResult::Read(old_result, &deserialized_old_result));
|
||||
ASSERT_TRUE(deserialized_old_result.blob_file_additions.empty());
|
||||
ASSERT_TRUE(deserialized_old_result.blob_file_garbages.empty());
|
||||
ASSERT_EQ(deserialized_old_result.blob_compaction_version, 0);
|
||||
ASSERT_EQ(deserialized_old_result.blob_gc_cutoff_version, 0);
|
||||
deserialized_old_result.status.PermitUncheckedError();
|
||||
|
||||
// Test missing field
|
||||
CompactionServiceResult deserialized3;
|
||||
deserialized3.bytes_read = 0;
|
||||
std::string to_remove = "bytes_read=123;";
|
||||
pos = output.find(to_remove);
|
||||
size_t pos = output.find(to_remove);
|
||||
ASSERT_TRUE(pos != std::string::npos);
|
||||
output.erase(pos, to_remove.length());
|
||||
ASSERT_OK(CompactionServiceResult::Read(output, &deserialized3));
|
||||
@@ -1975,102 +1809,6 @@ TEST_F(CompactionJobTest, ResultSerialization) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(CompactionJobTest, ResultSerializationMissingOrInvalidFields) {
|
||||
// Each status field differs between the written status, the destination's
|
||||
// earlier status, and `Status::OK()`, so every check below can tell which of
|
||||
// the three a parsed field came from.
|
||||
CompactionServiceResult result;
|
||||
result.status = Status(Status::kIOError, Status::kNoSpace, Status::kHardError,
|
||||
"disk full");
|
||||
CompactionServiceOutputFile file;
|
||||
file.file_name = "000123.sst";
|
||||
file.marked_for_compaction = true;
|
||||
file.is_proximal_level_output = true;
|
||||
result.output_files.push_back(file);
|
||||
std::string serialized;
|
||||
ASSERT_OK(result.Write(&serialized));
|
||||
const Status earlier(Status::kTimedOut, Status::kMutexTimeout,
|
||||
Status::kSoftError, "earlier");
|
||||
|
||||
CompactionServiceResult parsed;
|
||||
ASSERT_OK(CompactionServiceResult::Read(serialized, &parsed));
|
||||
ASSERT_EQ(StatusFields(parsed.status), StatusFields(result.status));
|
||||
ASSERT_EQ(parsed.output_files.size(), 1U);
|
||||
ASSERT_TRUE(parsed.output_files[0].marked_for_compaction);
|
||||
ASSERT_TRUE(parsed.output_files[0].is_proximal_level_output);
|
||||
|
||||
// A missing status field takes its value in `Status::OK()`, and the other
|
||||
// fields keep their written values.
|
||||
struct MissingFieldCase {
|
||||
const char* field;
|
||||
Status::Code code;
|
||||
Status::SubCode subcode;
|
||||
Status::Severity severity;
|
||||
const char* message;
|
||||
};
|
||||
const MissingFieldCase missing_field_cases[] = {
|
||||
{"code", Status::kOk, Status::kNoSpace, Status::kHardError, "disk full"},
|
||||
{"subcode", Status::kIOError, Status::kNone, Status::kHardError,
|
||||
"disk full"},
|
||||
{"severity", Status::kIOError, Status::kNoSpace, Status::kNoError,
|
||||
"disk full"},
|
||||
{"message", Status::kIOError, Status::kNoSpace, Status::kHardError, ""},
|
||||
};
|
||||
for (const MissingFieldCase& c : missing_field_cases) {
|
||||
SCOPED_TRACE(c.field);
|
||||
std::string missing_field = serialized;
|
||||
ASSERT_TRUE(ReplaceResultEntry(&missing_field, "status={", c.field, ""));
|
||||
CompactionServiceResult parsed_missing_field;
|
||||
parsed_missing_field.status = earlier;
|
||||
ASSERT_OK(
|
||||
CompactionServiceResult::Read(missing_field, &parsed_missing_field));
|
||||
const Status expected(c.code, c.subcode, c.severity, c.message);
|
||||
ASSERT_EQ(StatusFields(parsed_missing_field.status),
|
||||
StatusFields(expected));
|
||||
}
|
||||
|
||||
// A malformed or out-of-range status field fails the parse, and the
|
||||
// destination keeps its earlier status.
|
||||
struct InvalidFieldCase {
|
||||
const char* field;
|
||||
std::string entry;
|
||||
};
|
||||
const InvalidFieldCase invalid_field_cases[] = {
|
||||
{"message", "message=Z;"},
|
||||
{"code", "code=" + std::to_string(Status::kMaxCode) + ";"},
|
||||
{"subcode", "subcode=" + std::to_string(Status::kMaxSubCode) + ";"},
|
||||
{"severity", "severity=" + std::to_string(Status::kMaxSeverity) + ";"},
|
||||
};
|
||||
for (const InvalidFieldCase& c : invalid_field_cases) {
|
||||
SCOPED_TRACE(c.entry);
|
||||
std::string invalid_field = serialized;
|
||||
ASSERT_TRUE(
|
||||
ReplaceResultEntry(&invalid_field, "status={", c.field, c.entry));
|
||||
CompactionServiceResult parsed_invalid_field;
|
||||
parsed_invalid_field.status = earlier;
|
||||
const Status s =
|
||||
CompactionServiceResult::Read(invalid_field, &parsed_invalid_field);
|
||||
ASSERT_EQ(s.code(), Status::kInvalidArgument) << s.ToString();
|
||||
ASSERT_EQ(StatusFields(parsed_invalid_field.status), StatusFields(earlier));
|
||||
}
|
||||
|
||||
// A missing output-file flag reads as false.
|
||||
std::string missing_flags = serialized;
|
||||
ASSERT_TRUE(ReplaceResultEntry(&missing_flags,
|
||||
"output_files=", "marked_for_compaction", ""));
|
||||
ASSERT_TRUE(ReplaceResultEntry(
|
||||
&missing_flags, "output_files=", "is_proximal_level_output", ""));
|
||||
CompactionServiceResult parsed_missing_flags;
|
||||
ASSERT_OK(
|
||||
CompactionServiceResult::Read(missing_flags, &parsed_missing_flags));
|
||||
ASSERT_EQ(StatusFields(parsed_missing_flags.status),
|
||||
StatusFields(result.status));
|
||||
ASSERT_EQ(parsed_missing_flags.output_files.size(), 1U);
|
||||
ASSERT_EQ(parsed_missing_flags.output_files[0].file_name, "000123.sst");
|
||||
ASSERT_FALSE(parsed_missing_flags.output_files[0].marked_for_compaction);
|
||||
ASSERT_FALSE(parsed_missing_flags.output_files[0].is_proximal_level_output);
|
||||
}
|
||||
|
||||
TEST_F(CompactionJobTest, CutForMaxCompactionBytes) {
|
||||
// dynamic_file_size option should have no impact on cutting for max
|
||||
// compaction bytes.
|
||||
|
||||
@@ -10,10 +10,7 @@
|
||||
|
||||
#include "db/compaction/compaction_outputs.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "db/builder.h"
|
||||
#include "logging/logging.h"
|
||||
|
||||
namespace ROCKSDB_NAMESPACE {
|
||||
|
||||
@@ -235,32 +232,6 @@ uint64_t CompactionOutputs::GetCurrentKeyGrandparentOverlappedBytes(
|
||||
return overlapped_bytes;
|
||||
}
|
||||
|
||||
bool CompactionOutputs::PartitionerRequiresCut(
|
||||
const CompactionIterator& c_iter) const {
|
||||
assert(HasBuilder());
|
||||
if (!partitioner_) {
|
||||
return false;
|
||||
}
|
||||
if (partitioner_prefix_valid_) {
|
||||
// Fast path: no per-key copy or virtual call. A partition is requested at
|
||||
// the first key that no longer shares the established prefix. An empty
|
||||
// prefix means no further partitions (every key "starts with" it).
|
||||
return UNLIKELY(!c_iter.user_key().starts_with(partitioner_prefix_));
|
||||
}
|
||||
// Slow path: per-key callback (and copy elsewhere)
|
||||
return UNLIKELY(partitioner_->ShouldPartition(PartitionerRequest(
|
||||
last_key_for_partitioner_, c_iter.user_key(),
|
||||
current_output_file_size_)) == kRequired);
|
||||
}
|
||||
|
||||
bool CompactionOutputs::LargestUserKeyEquals(const Slice& user_key) {
|
||||
const InternalKey& largest = current_output().meta.largest;
|
||||
return largest.size() > 0 &&
|
||||
compaction_->column_family_data()
|
||||
->user_comparator()
|
||||
->EqualWithoutTimestamp(largest.user_key(), user_key);
|
||||
}
|
||||
|
||||
bool CompactionOutputs::ShouldStopBefore(const CompactionIterator& c_iter) {
|
||||
assert(c_iter.Valid());
|
||||
const Slice& internal_key = c_iter.key();
|
||||
@@ -296,8 +267,22 @@ bool CompactionOutputs::ShouldStopBefore(const CompactionIterator& c_iter) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartitionerRequiresCut(c_iter)) {
|
||||
return true;
|
||||
if (partitioner_) {
|
||||
if (partitioner_prefix_valid_) {
|
||||
// Fast path: no per-key copy or virtual call. A partition is requested at
|
||||
// the first key that no longer shares the established prefix. An empty
|
||||
// prefix means no further partitions (every key "starts with" it).
|
||||
if (UNLIKELY(!c_iter.user_key().starts_with(partitioner_prefix_))) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Slow path: per-key callback (and copy elsewhere)
|
||||
if (UNLIKELY(partitioner_->ShouldPartition(PartitionerRequest(
|
||||
last_key_for_partitioner_, c_iter.user_key(),
|
||||
current_output_file_size_)) == kRequired)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// files output to Level 0 won't be split
|
||||
@@ -388,193 +373,81 @@ bool CompactionOutputs::ShouldStopBefore(const CompactionIterator& c_iter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CompactionOutputs::PrepareNewOutputForFirstKey(
|
||||
const CompactionIterator& c_iter) {
|
||||
// A new output file starts a fresh partition-tracking window. Establish the
|
||||
// partitioner fast path from this file's first key: if the partitioner can
|
||||
// express its next boundary as "first key not sharing this prefix", cache
|
||||
// that prefix; otherwise fall back to per-key ShouldPartition(). This is the
|
||||
// only place the prefix needs to be (re)derived, since a partition boundary
|
||||
// always forces a file cut, and re-deriving on non-partition cuts just
|
||||
// recomputes the same still-valid prefix.
|
||||
if (partitioner_) {
|
||||
OptSlice prefix = partitioner_->ShouldPartitionByPrefix(c_iter.user_key());
|
||||
partitioner_prefix_valid_ = prefix.has_value();
|
||||
if (partitioner_prefix_valid_) {
|
||||
partitioner_prefix_.assign(prefix->data(), prefix->size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Status CompactionOutputs::AddToOutput(
|
||||
CompactionIterator& c_iter, const CompactionFileOpenFunc& open_file_func,
|
||||
const CompactionIterator& c_iter,
|
||||
const CompactionFileOpenFunc& open_file_func,
|
||||
const CompactionFileCloseFunc& close_file_func,
|
||||
const ParsedInternalKey& prev_iter_output_internal_key) {
|
||||
Status s;
|
||||
bool is_range_del = c_iter.IsDeleteRangeSentinelKey();
|
||||
bool cut_before;
|
||||
if (is_range_del && compaction_->bottommost_level()) {
|
||||
// At the bottommost level, a range tombstone is not by itself a reason to
|
||||
// cut: there are no grandparents to limit overlap with, and the tombstone
|
||||
// might be dropped. However, a boundary required by the SstPartitioner
|
||||
// must still be honored; otherwise AddRangeDels() would extend the
|
||||
// current file across it. No boundary can fall inside one user key, and
|
||||
// a point key there may have its seqno zeroed, so that it sorts after a
|
||||
// tombstone starting at the same user key.
|
||||
if (!HasBuilder() || LargestUserKeyEquals(c_iter.user_key()) ||
|
||||
!PartitionerRequiresCut(c_iter)) {
|
||||
return s;
|
||||
}
|
||||
cut_before = true;
|
||||
} else {
|
||||
cut_before = ShouldStopBefore(c_iter) && HasBuilder();
|
||||
// We don't consider range tombstone for bottommost level since:
|
||||
// 1. there is no grandparent and hence no overlap to consider
|
||||
// 2. range tombstone may be dropped at bottommost level.
|
||||
return s;
|
||||
}
|
||||
if (cut_before) {
|
||||
const Slice next_table_min_key = c_iter.key();
|
||||
const Slice& key = c_iter.key();
|
||||
if (ShouldStopBefore(c_iter) && HasBuilder()) {
|
||||
s = close_file_func(c_iter.InputStatus(), prev_iter_output_internal_key,
|
||||
next_table_min_key, &c_iter,
|
||||
/*post_prepare_retry=*/false, *this);
|
||||
key, &c_iter, *this);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
// reset grandparent information
|
||||
grandparent_boundary_switched_num_ = 0;
|
||||
grandparent_overlapped_bytes_ =
|
||||
GetCurrentKeyGrandparentOverlappedBytes(next_table_min_key);
|
||||
GetCurrentKeyGrandparentOverlappedBytes(key);
|
||||
if (UNLIKELY(is_range_del)) {
|
||||
// lower bound for this new output file, this is needed as the lower bound
|
||||
// does not come from the smallest point key in this case.
|
||||
range_tombstone_lower_bound_.DecodeFrom(next_table_min_key);
|
||||
range_tombstone_lower_bound_.DecodeFrom(key);
|
||||
} else {
|
||||
range_tombstone_lower_bound_.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
c_iter.PrepareOutputIfNeeded();
|
||||
if (!c_iter.status().ok() || !c_iter.Valid()) {
|
||||
s = c_iter.status();
|
||||
return s;
|
||||
}
|
||||
const Slice& key = c_iter.key();
|
||||
|
||||
// Open output file if necessary
|
||||
if (!HasBuilder()) {
|
||||
s = open_file_func(*this);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
PrepareNewOutputForFirstKey(c_iter);
|
||||
// A new output file starts a fresh partition-tracking window. Establish the
|
||||
// partitioner fast path from this file's first key: if the partitioner can
|
||||
// express its next boundary as "first key not sharing this prefix", cache
|
||||
// that prefix; otherwise fall back to per-key ShouldPartition(). This is
|
||||
// the only place the prefix needs to be (re)derived, since a partition
|
||||
// boundary always forces a file cut, and re-deriving on non-partition cuts
|
||||
// just recomputes the same still-valid prefix.
|
||||
if (partitioner_) {
|
||||
OptSlice prefix =
|
||||
partitioner_->ShouldPartitionByPrefix(c_iter.user_key());
|
||||
partitioner_prefix_valid_ = prefix.has_value();
|
||||
if (partitioner_prefix_valid_) {
|
||||
partitioner_prefix_.assign(prefix->data(), prefix->size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// c_iter may emit range deletion keys, so update `last_key_for_partitioner_`
|
||||
// here before returning below when `is_range_del` is true. Only needed in the
|
||||
// fallback mode; the prefix fast path does not use it.
|
||||
if (partitioner_ && !partitioner_prefix_valid_) {
|
||||
last_key_for_partitioner_.assign(c_iter.user_key().data_,
|
||||
c_iter.user_key().size_);
|
||||
}
|
||||
|
||||
if (UNLIKELY(is_range_del)) {
|
||||
// c_iter may emit range deletion keys, so update
|
||||
// `last_key_for_partitioner_` before returning. Only needed in the fallback
|
||||
// mode; the prefix fast path does not use it.
|
||||
if (partitioner_ && !partitioner_prefix_valid_) {
|
||||
last_key_for_partitioner_.assign(c_iter.user_key().data_,
|
||||
c_iter.user_key().size_);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
assert(builder_ != nullptr);
|
||||
const Slice& value = c_iter.value();
|
||||
bool retried_after_new_table = false;
|
||||
while (true) {
|
||||
s = current_output().validator.CanAdd(key);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
|
||||
TableBuilderAddContext add_context;
|
||||
const TableBuilderAddResult add_result =
|
||||
builder_->TryAdd(key, value, &add_context);
|
||||
|
||||
if (add_result == TableBuilderAddResult::kError) {
|
||||
s = builder_->status();
|
||||
if (s.ok()) {
|
||||
return Status::Corruption(
|
||||
"TableBuilder returned kError without a non-OK status");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
if (add_result == TableBuilderAddResult::kAdded) {
|
||||
current_output().validator.AddValidated(key, value);
|
||||
break;
|
||||
}
|
||||
|
||||
assert(add_result == TableBuilderAddResult::kRequiresNewTable);
|
||||
s = builder_->status();
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
const char* const new_table_reason =
|
||||
add_context.new_table_reason == TableBuilderNewTableReason::kNone
|
||||
? "Unspecified"
|
||||
: TableBuilderNewTableReasonToString(add_context.new_table_reason);
|
||||
const Compaction* compaction = compaction_;
|
||||
if (compaction == nullptr) {
|
||||
return Status::Corruption("Compaction output is missing compaction");
|
||||
}
|
||||
ColumnFamilyData* cfd = compaction->column_family_data();
|
||||
if (cfd == nullptr) {
|
||||
return Status::Corruption(
|
||||
"Compaction output is missing column family data");
|
||||
}
|
||||
const bool allow_data_in_errors =
|
||||
compaction->immutable_options().allow_data_in_errors;
|
||||
const std::string key_for_diagnostics =
|
||||
allow_data_in_errors ? key.ToString(/* hex */ true) : "hidden";
|
||||
if (compaction->output_level() == 0) {
|
||||
const std::string detail =
|
||||
"cf: " + cfd->GetName() + ", file_number: " +
|
||||
std::to_string(current_output().meta.fd.GetNumber()) +
|
||||
", reason: " + new_table_reason + ", key: " + key_for_diagnostics;
|
||||
return Status::Corruption(
|
||||
"TableBuilder requested a new table while producing level 0 output",
|
||||
detail);
|
||||
}
|
||||
if (retried_after_new_table || builder_->IsEmpty()) {
|
||||
const std::string detail =
|
||||
"cf: " + cfd->GetName() + ", file_number: " +
|
||||
std::to_string(current_output().meta.fd.GetNumber()) +
|
||||
", reason: " + new_table_reason + ", key: " + key_for_diagnostics;
|
||||
return Status::Corruption(
|
||||
"TableBuilder requested a new table without accepting any rows",
|
||||
detail);
|
||||
}
|
||||
|
||||
ROCKS_LOG_INFO(
|
||||
compaction->immutable_options().info_log,
|
||||
"[%s] Compaction output table builder requested a new table before "
|
||||
"key %s for file #%" PRIu64 ". reason: %s",
|
||||
cfd->GetName().c_str(), key_for_diagnostics.c_str(),
|
||||
current_output().meta.fd.GetNumber(), new_table_reason);
|
||||
|
||||
s = close_file_func(c_iter.InputStatus(), prev_iter_output_internal_key,
|
||||
key, &c_iter, /*post_prepare_retry=*/true, *this);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
|
||||
grandparent_boundary_switched_num_ = 0;
|
||||
grandparent_overlapped_bytes_ =
|
||||
GetCurrentKeyGrandparentOverlappedBytes(key);
|
||||
range_tombstone_lower_bound_.Clear();
|
||||
|
||||
s = open_file_func(*this);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
PrepareNewOutputForFirstKey(c_iter);
|
||||
retried_after_new_table = true;
|
||||
}
|
||||
|
||||
if (partitioner_ && !partitioner_prefix_valid_) {
|
||||
last_key_for_partitioner_.assign(c_iter.user_key().data_,
|
||||
c_iter.user_key().size_);
|
||||
s = current_output().validator.Add(key, value);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
builder_->Add(key, value);
|
||||
|
||||
stats_.num_output_records++;
|
||||
current_output_file_size_ = builder_->EstimatedFileSize();
|
||||
@@ -639,13 +512,10 @@ Status CompactionOutputs::AddRangeDels(
|
||||
assert(!range_del_agg.IsEmpty());
|
||||
FileMetaData& meta = current_output().meta;
|
||||
const Comparator* ucmp = icmp.user_comparator();
|
||||
InternalKey lower_bound_buf;
|
||||
InternalKey upper_bound_buf;
|
||||
Slice lower_bound_guard;
|
||||
Slice upper_bound_guard;
|
||||
InternalKey lower_bound_buf, upper_bound_buf;
|
||||
Slice lower_bound_guard, upper_bound_guard;
|
||||
std::string smallest_user_key;
|
||||
const Slice* lower_bound;
|
||||
const Slice* upper_bound;
|
||||
const Slice *lower_bound, *upper_bound;
|
||||
|
||||
// We first determine the internal key lower_bound and upper_bound for
|
||||
// this output file. All and only range tombstones that overlap with
|
||||
|
||||
@@ -22,7 +22,7 @@ class CompactionOutputs;
|
||||
using CompactionFileOpenFunc = std::function<Status(CompactionOutputs&)>;
|
||||
using CompactionFileCloseFunc =
|
||||
std::function<Status(const Status&, const ParsedInternalKey&, const Slice&,
|
||||
const CompactionIterator*, bool, CompactionOutputs&)>;
|
||||
const CompactionIterator*, CompactionOutputs&)>;
|
||||
|
||||
// Files produced by subcompaction, most of the functions are used by
|
||||
// compaction_job Open/Close compaction file functions.
|
||||
@@ -245,20 +245,6 @@ class CompactionOutputs {
|
||||
// before processing the current key in compaction iterator.
|
||||
bool ShouldStopBefore(const CompactionIterator& c_iter);
|
||||
|
||||
// Returns true iff the SST partitioner requires a new output file to start
|
||||
// at the current key. Only meaningful while an output file is open: the
|
||||
// partitioner state describes the current file.
|
||||
bool PartitionerRequiresCut(const CompactionIterator& c_iter) const;
|
||||
|
||||
// Returns true iff the current output file has a largest key and its user
|
||||
// key equals `user_key`, ignoring timestamps.
|
||||
bool LargestUserKeyEquals(const Slice& user_key);
|
||||
|
||||
// Re-establishes per-file state that depends on the first key accepted by a
|
||||
// freshly opened builder. This keeps caller-requested file cuts equivalent to
|
||||
// RocksDB's built-in file-boundary decisions for partition tracking.
|
||||
void PrepareNewOutputForFirstKey(const CompactionIterator& c_iter);
|
||||
|
||||
void Cleanup() {
|
||||
if (builder_ != nullptr) {
|
||||
// May happen if we get a shutdown call in the middle of compaction
|
||||
@@ -287,7 +273,7 @@ class CompactionOutputs {
|
||||
|
||||
// Add current key from compaction_iterator to the output file. If needed
|
||||
// close and open new compaction output with the functions provided.
|
||||
Status AddToOutput(CompactionIterator& c_iter,
|
||||
Status AddToOutput(const CompactionIterator& c_iter,
|
||||
const CompactionFileOpenFunc& open_file_func,
|
||||
const CompactionFileCloseFunc& close_file_func,
|
||||
const ParsedInternalKey& prev_iter_output_internal_key);
|
||||
@@ -311,8 +297,7 @@ class CompactionOutputs {
|
||||
const ParsedInternalKey empty_internal_key{};
|
||||
const Slice empty_key{};
|
||||
Status s = close_file_func(status, empty_internal_key, empty_key,
|
||||
nullptr /* c_iter */,
|
||||
/*post_prepare_retry=*/false, *this);
|
||||
nullptr /* c_iter */, *this);
|
||||
if (!s.ok() && status.ok()) {
|
||||
status = s;
|
||||
}
|
||||
|
||||
@@ -236,10 +236,7 @@ void CompactionPicker::GetRange(const CompactionInputFiles& inputs1,
|
||||
} else if (inputs2.empty()) {
|
||||
GetRange(inputs1, smallest, largest);
|
||||
} else {
|
||||
InternalKey smallest1;
|
||||
InternalKey smallest2;
|
||||
InternalKey largest1;
|
||||
InternalKey largest2;
|
||||
InternalKey smallest1, smallest2, largest1, largest2;
|
||||
GetRange(inputs1, &smallest1, &largest1);
|
||||
GetRange(inputs2, &smallest2, &largest2);
|
||||
*smallest =
|
||||
@@ -289,8 +286,7 @@ bool CompactionPicker::ExpandInputsToCleanCut(const std::string& /*cf_name*/,
|
||||
return true;
|
||||
}
|
||||
|
||||
InternalKey smallest;
|
||||
InternalKey largest;
|
||||
InternalKey smallest, largest;
|
||||
|
||||
// Keep expanding inputs until we are sure that there is a "clean cut"
|
||||
// boundary between the files in input and the surrounding files.
|
||||
@@ -364,8 +360,7 @@ bool CompactionPicker::FilesRangeOverlapWithCompaction(
|
||||
|
||||
// TODO: Intra L0 compactions can have the ranges overlapped, but the input
|
||||
// files cannot be overlapped in the order of L0 files.
|
||||
InternalKey smallest;
|
||||
InternalKey largest;
|
||||
InternalKey smallest, largest;
|
||||
GetRange(inputs, &smallest, &largest, Compaction::kInvalidLevel);
|
||||
if (proximal_level != Compaction::kInvalidLevel) {
|
||||
if (ioptions_.compaction_style == kCompactionStyleUniversal) {
|
||||
@@ -375,8 +370,7 @@ bool CompactionPicker::FilesRangeOverlapWithCompaction(
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
InternalKey proximal_smallest;
|
||||
InternalKey proximal_largest;
|
||||
InternalKey proximal_smallest, proximal_largest;
|
||||
GetRange(inputs, &proximal_smallest, &proximal_largest, level);
|
||||
if (RangeOverlapWithCompaction(proximal_smallest.user_key(),
|
||||
proximal_largest.user_key(),
|
||||
@@ -552,8 +546,7 @@ bool CompactionPicker::SetupOtherInputs(
|
||||
assert(vstorage->NumLevelFiles(l) == 0);
|
||||
}
|
||||
|
||||
InternalKey smallest;
|
||||
InternalKey largest;
|
||||
InternalKey smallest, largest;
|
||||
|
||||
// Get the range one last time.
|
||||
GetRange(*inputs, &smallest, &largest);
|
||||
@@ -586,8 +579,7 @@ bool CompactionPicker::SetupOtherInputs(
|
||||
CompactionInputFiles expanded_inputs;
|
||||
expanded_inputs.level = input_level;
|
||||
// Get closed interval of output level
|
||||
InternalKey all_start;
|
||||
InternalKey all_limit;
|
||||
InternalKey all_start, all_limit;
|
||||
GetRange(*inputs, *output_level_inputs, &all_start, &all_limit);
|
||||
bool try_overlapping_inputs = true;
|
||||
if (only_expand_towards_right) {
|
||||
@@ -613,8 +605,7 @@ bool CompactionPicker::SetupOtherInputs(
|
||||
if (try_overlapping_inputs && expanded_inputs.size() > inputs->size() &&
|
||||
!AreFilesInCompaction(expanded_inputs.files) &&
|
||||
output_level_inputs_size + expanded_inputs_size < limit) {
|
||||
InternalKey new_start;
|
||||
InternalKey new_limit;
|
||||
InternalKey new_start, new_limit;
|
||||
GetRange(expanded_inputs, &new_start, &new_limit);
|
||||
CompactionInputFiles expanded_output_level_inputs;
|
||||
expanded_output_level_inputs.level = output_level;
|
||||
@@ -664,8 +655,7 @@ void CompactionPicker::GetGrandparents(
|
||||
VersionStorageInfo* vstorage, const CompactionInputFiles& inputs,
|
||||
const CompactionInputFiles& output_level_inputs,
|
||||
std::vector<FileMetaData*>* grandparents) {
|
||||
InternalKey start;
|
||||
InternalKey limit;
|
||||
InternalKey start, limit;
|
||||
GetRange(inputs, output_level_inputs, &start, &limit);
|
||||
// Compute the set of grandparent files that overlap this compaction
|
||||
// (parent == level+1; grandparent == level+2 or the first
|
||||
@@ -764,7 +754,6 @@ Compaction* CompactionPicker::PickCompactionForCompactRange(
|
||||
compact_range_options.blob_garbage_collection_policy,
|
||||
compact_range_options.blob_garbage_collection_age_cutoff);
|
||||
|
||||
c->SetSkipMissingBlobFiles(compact_range_options.skip_missing_blob_files);
|
||||
RegisterCompaction(c);
|
||||
vstorage->ComputeCompactionScore(ioptions_, mutable_cf_options,
|
||||
full_history_ts_low);
|
||||
@@ -838,8 +827,7 @@ Compaction* CompactionPicker::PickCompactionForCompactRange(
|
||||
|
||||
// for BOTTOM LEVEL compaction only, use max_file_num_to_ignore to filter out
|
||||
// files that are created during the current compaction.
|
||||
if ((compact_range_options.skip_missing_blob_files ||
|
||||
compact_range_options.bottommost_level_compaction ==
|
||||
if ((compact_range_options.bottommost_level_compaction ==
|
||||
BottommostLevelCompaction::kForceOptimized ||
|
||||
compact_range_options.bottommost_level_compaction ==
|
||||
BottommostLevelCompaction::kIfHaveCompactionFilter) &&
|
||||
@@ -862,6 +850,9 @@ Compaction* CompactionPicker::PickCompactionForCompactRange(
|
||||
if (inputs_shrunk.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (inputs.size() != inputs_shrunk.size()) {
|
||||
inputs.files.swap(inputs_shrunk);
|
||||
}
|
||||
// set covering_the_whole_range to false if there is any file that need to
|
||||
// be compacted in the range of inputs[skip_input_index+1, inputs.size())
|
||||
for (size_t i = skip_input_index + 1; i < inputs.size(); ++i) {
|
||||
@@ -869,9 +860,6 @@ Compaction* CompactionPicker::PickCompactionForCompactRange(
|
||||
covering_the_whole_range = false;
|
||||
}
|
||||
}
|
||||
if (inputs.size() != inputs_shrunk.size()) {
|
||||
inputs.files.swap(inputs_shrunk);
|
||||
}
|
||||
}
|
||||
|
||||
InternalKey key_storage;
|
||||
@@ -958,8 +946,6 @@ Compaction* CompactionPicker::PickCompactionForCompactRange(
|
||||
compact_range_options.blob_garbage_collection_policy,
|
||||
compact_range_options.blob_garbage_collection_age_cutoff);
|
||||
|
||||
compaction->SetSkipMissingBlobFiles(
|
||||
compact_range_options.skip_missing_blob_files);
|
||||
TEST_SYNC_POINT_CALLBACK("CompactionPicker::CompactRange:Return", compaction);
|
||||
RegisterCompaction(compaction);
|
||||
|
||||
@@ -1317,8 +1303,7 @@ bool CompactionPicker::GetOverlappingL0Files(
|
||||
// Two level 0 compaction won't run at the same time, so don't need to worry
|
||||
// about files on level 0 being compacted.
|
||||
assert(level0_compactions_in_progress()->empty());
|
||||
InternalKey smallest;
|
||||
InternalKey largest;
|
||||
InternalKey smallest, largest;
|
||||
GetRange(*start_level_inputs, &smallest, &largest);
|
||||
// Note that the next call will discard the file we placed in
|
||||
// c->inputs_[0] earlier and replace it with an overlapping set
|
||||
|
||||
@@ -276,7 +276,7 @@ class NullCompactionPicker : public CompactionPicker {
|
||||
NullCompactionPicker(const ImmutableOptions& ioptions,
|
||||
const InternalKeyComparator* icmp)
|
||||
: CompactionPicker(ioptions, icmp) {}
|
||||
~NullCompactionPicker() override = default;
|
||||
virtual ~NullCompactionPicker() {}
|
||||
|
||||
// Always return "nullptr"
|
||||
Compaction* PickCompaction(
|
||||
|
||||
@@ -110,13 +110,6 @@ Compaction* FIFOCompactionPicker::PickTTLCompaction(
|
||||
uint64_t est_newest_key_time = newest_key_time == kUnknownNewestKeyTime
|
||||
? oldest_ancestor_time
|
||||
: newest_key_time;
|
||||
if (est_newest_key_time == kUnknownNewestKeyTime) {
|
||||
// E.g. a file written by SstFileWriter. Every key in the file was
|
||||
// written no later than the file's contents were built.
|
||||
est_newest_key_time = f->TryGetFileCreationTime();
|
||||
}
|
||||
// CheckExternalFileNotTooOld() (reject_too_old_file) mirrors this
|
||||
// estimate
|
||||
if (est_newest_key_time == kUnknownNewestKeyTime ||
|
||||
est_newest_key_time >= (current_time - mutable_cf_options.ttl)) {
|
||||
break;
|
||||
@@ -233,8 +226,7 @@ Compaction* FIFOCompactionPicker::PickSizeCompaction(
|
||||
vstorage->LevelFiles(last_level);
|
||||
|
||||
// Compute effective size and limit for comparison.
|
||||
uint64_t effective_size;
|
||||
uint64_t effective_max;
|
||||
uint64_t effective_size, effective_max;
|
||||
GetEffectiveSizeAndLimit(fifo_opts, total_size,
|
||||
vstorage->GetBlobStats().total_file_size,
|
||||
&effective_size, &effective_max);
|
||||
|
||||
@@ -393,8 +393,7 @@ void LevelCompactionBuilder::SetupOtherFilesWithRoundRobinExpansion() {
|
||||
}
|
||||
|
||||
size_t start_index = vstorage_->FilesByCompactionPri(start_level_)[0];
|
||||
InternalKey smallest;
|
||||
InternalKey largest;
|
||||
InternalKey smallest, largest;
|
||||
// Constraint 4 (No need to check again later)
|
||||
compaction_picker_->GetRange(start_level_inputs_, &smallest, &largest);
|
||||
CompactionInputFiles output_level_inputs;
|
||||
@@ -676,8 +675,7 @@ bool LevelCompactionBuilder::TryPickL0TrivialMove() {
|
||||
const std::vector<FileMetaData*>& level_files =
|
||||
vstorage_->LevelFiles(start_level_);
|
||||
|
||||
InternalKey my_smallest;
|
||||
InternalKey my_largest;
|
||||
InternalKey my_smallest, my_largest;
|
||||
for (auto it = level_files.rbegin(); it != level_files.rend(); ++it) {
|
||||
CompactionInputFiles output_level_inputs;
|
||||
output_level_inputs.level = output_level_;
|
||||
@@ -888,8 +886,7 @@ bool LevelCompactionBuilder::PickFileToCompact() {
|
||||
// Note we rely on ExpandInputsToCleanCut() to tell us whether any output-
|
||||
// level files are locked, not just the extra ones pulled in for user-key
|
||||
// overlap.
|
||||
InternalKey smallest;
|
||||
InternalKey largest;
|
||||
InternalKey smallest, largest;
|
||||
compaction_picker_->GetRange(start_level_inputs_, &smallest, &largest);
|
||||
CompactionInputFiles output_level_inputs;
|
||||
output_level_inputs.level = output_level_;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace ROCKSDB_NAMESPACE {
|
||||
// Picking compactions for leveled compaction. See wiki page
|
||||
// https://github.com/meta/rocksdb/wiki/Leveled-Compaction
|
||||
// https://github.com/facebook/rocksdb/wiki/Leveled-Compaction
|
||||
// for description of Leveled compaction.
|
||||
class LevelCompactionPicker : public CompactionPicker {
|
||||
public:
|
||||
|
||||
Loaded 100 of 775 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user