[C API] add rocksdb_set_db_options for dynamic DB option updates#14615
[C API] add rocksdb_set_db_options for dynamic DB option updates#14615mjc2-stripe wants to merge 4 commits into
Conversation
|
@xingbowang has imported this pull request. If you are a Meta employee, you can view this in D101010593. |
|
| Check | Count |
|---|---|
bugprone-argument-comment |
2 |
cert-err58-cpp |
2 |
clang-analyzer-optin.core.EnumCastOutOfRange |
4 |
concurrency-mt-unsafe |
9 |
cppcoreguidelines-avoid-non-const-global-variables |
5 |
cppcoreguidelines-pro-type-member-init |
2 |
cppcoreguidelines-special-member-functions |
1 |
| Total | 25 |
Details
db/blob/db_blob_direct_write_test.cc (1 warning(s))
db/blob/db_blob_direct_write_test.cc:127:7: warning: class 'ActiveBlobVisibilityWritableFile' defines a non-default destructor but does not define a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
db/db_wal_test.cc (1 warning(s))
db/db_wal_test.cc:117:5: warning: uninitialized record type: 'fs_stat' [cppcoreguidelines-pro-type-member-init]
db_stress_tool/db_stress_common.cc (4 warning(s))
db_stress_tool/db_stress_common.cc:22:25: warning: variable 'raw_env' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
db_stress_tool/db_stress_common.cc:22:25: warning: variable 'raw_env' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
db_stress_tool/db_stress_common.cc:25:56: warning: variable 'wbm' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
db_stress_tool/db_stress_common.cc:26:49: warning: variable 'rate_limiter' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
db_stress_tool/db_stress_test_base.cc (6 warning(s))
db_stress_tool/db_stress_test_base.cc:380:7: warning: function is not thread safe [concurrency-mt-unsafe]
db_stress_tool/db_stress_test_base.cc:4152:7: warning: function is not thread safe [concurrency-mt-unsafe]
db_stress_tool/db_stress_test_base.cc:4693:7: warning: function is not thread safe [concurrency-mt-unsafe]
db_stress_tool/db_stress_test_base.cc:4727:11: warning: function is not thread safe [concurrency-mt-unsafe]
db_stress_tool/db_stress_test_base.cc:4766:11: warning: function is not thread safe [concurrency-mt-unsafe]
db_stress_tool/db_stress_test_base.cc:5500:7: warning: function is not thread safe [concurrency-mt-unsafe]
db_stress_tool/db_stress_tool.cc (4 warning(s))
db_stress_tool/db_stress_tool.cc:41:5: warning: variable 'fault_fs_for_crash_report' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
db_stress_tool/db_stress_tool.cc:402:7: warning: function is not thread safe [concurrency-mt-unsafe]
db_stress_tool/db_stress_tool.cc:416:9: warning: function is not thread safe [concurrency-mt-unsafe]
db_stress_tool/db_stress_tool.cc:448:9: warning: function is not thread safe [concurrency-mt-unsafe]
file/random_access_file_reader_test.cc (1 warning(s))
file/random_access_file_reader_test.cc:114:21: warning: argument name 'direct_io_buffer' in comment does not match parameter name 'direct_io_buffer_context' [bugprone-argument-comment]
include/rocksdb/file_system.h (4 warning(s))
include/rocksdb/file_system.h:195:10: warning: The value '3' provided to the cast expression is not in the valid range of values for 'FileOpenContract' [clang-analyzer-optin.core.EnumCastOutOfRange]
include/rocksdb/file_system.h:195:10: warning: The value '3' provided to the cast expression is not in the valid range of values for 'FileOpenContract' [clang-analyzer-optin.core.EnumCastOutOfRange]
include/rocksdb/file_system.h:195:10: warning: The value '3' provided to the cast expression is not in the valid range of values for 'FileOpenContract' [clang-analyzer-optin.core.EnumCastOutOfRange]
include/rocksdb/file_system.h:195:10: warning: The value '3' provided to the cast expression is not in the valid range of values for 'FileOpenContract' [clang-analyzer-optin.core.EnumCastOutOfRange]
table/block_fetcher.cc (1 warning(s))
table/block_fetcher.cc:359:23: warning: argument name 'direct_io_buffer' in comment does not match parameter name 'direct_io_buffer_context' [bugprone-argument-comment]
util/coding_test.cc (3 warning(s))
util/coding_test.cc:220:8: warning: constructor does not initialize these fields: length [cppcoreguidelines-pro-type-member-init]
util/coding_test.cc:371:38: warning: initialization of 'kPrefixVarint32TestCases' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
util/coding_test.cc:386:38: warning: initialization of 'kPrefixVarint64TestCases' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
|
Hey @jaykorean! Could you please take a look at this when you get the chance? Thanks! |
| void rocksdb_set_db_options(rocksdb_t* db, int count, const char* const keys[], | ||
| const char* const values[], char** errptr) { | ||
| std::unordered_map<std::string, std::string> options_map; |
There was a problem hiding this comment.
why not have an iteration on the length of keys?
There was a problem hiding this comment.
The arrays passed in are just pointers, so there's no quick way to get the length of the array.
| const char* const values[], char** errptr) { | ||
| std::unordered_map<std::string, std::string> options_map; | ||
| for (int i = 0; i < count; i++) { | ||
| options_map[keys[i]] = values[i]; |
There was a problem hiding this comment.
potentially index out of bounds exception here - assertions required to check the length of both keys and values are same.
There was a problem hiding this comment.
Same issue here, where there's no quick way to get the length of the array
Codex Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit 5321f5f ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
Claude Code Review - OBSOLETESuperseded by a newer AI review. Expand to see the original review.✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 5321f5f SummaryClean, well-structured C API addition that correctly wraps High-severity findings (0): No high-severity findings. Full review (click to expand)Findings🔴 HIGHNone. 🟡 MEDIUMM1. Parameter naming inconsistency —
|
| Context | Supported? | Notes |
|---|---|---|
| Standard DB | Yes | Full support via DBImpl::SetDBOptions |
| StackableDB | Yes | Forwards to underlying DB |
| Secondary DB | Returns NotSupported | Expected behavior |
| Read-Only DB | Inherits base impl | May succeed or fail depending on option |
The function is purely additive (no breaking changes) and follows the exact implementation pattern of rocksdb_set_options. No symbol export changes needed beyond the standard ROCKSDB_LIBRARY_API macro already present. The Java API already has an equivalent setDBOptions binding, confirming the approach is well-established.
Positive Observations
- Correct use of
SaveErrorfor error propagation - Proper placement in
c.hbetween related functions (rocksdb_set_optionsandrocksdb_set_options_cf) - Test covers both success and error paths
- Implementation is a clean, minimal wrapper with no unnecessary complexity
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/code_review.md
Limitations:
- Claude may miss context from files not in the diff
- Large PRs may be truncated
- Always apply human judgment to AI suggestions
Commands:
/claude-review [context]— Request a code review/claude-query <question>— Ask about the PR or codebase
|
Could you fix the naming inconsistency? M1. Parameter naming inconsistency — c.cc / c.h // c.cc |
|
Please fix format |
|
@xingbowang could you ptal when you get a chance? thanks in advance :-) |
|
@xingbowang has imported this pull request. If you are a Meta employee, you can view this in D101010593. |
🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit 9a95475 ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 9a95475 SummaryClean, low-risk PR that adds a missing C API wrapper ( High-severity findings (0): No high-severity findings. Full review (click to expand)Findings🟡 MEDIUMM1. Missing
|
| Context | Does code execute? | Assumptions hold? | Action needed? |
|---|---|---|---|
| WritePreparedTxnDB | YES (via StackableDB) | YES | safe |
| ReadOnly DB | YES (returns error) | YES | safe |
| SecondaryInstance | YES (returns NotSupported) | YES | safe |
| User-defined timestamps | N/A (config API) | YES | safe |
The function is a pure pass-through wrapper. All validation, locking, and state mutation are handled by the existing DB::SetDBOptions() implementation. No new cross-component interactions are introduced.
Positive Observations
- Implementation is an exact structural match of the established
rocksdb_set_options()pattern — zero deviation - Test covers both success path (valid option
stats_dump_period_sec) and error path (invalid optionnot_a_db_option) - Header declaration is correctly placed between
rocksdb_set_optionsandrocksdb_set_options_cf, maintaining logical grouping - Function signature matches the established convention exactly
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/code_review.md
Limitations:
- Claude may miss context from files not in the diff
- Large PRs may be truncated
- Always apply human judgment to AI suggestions
Commands:
/claude-review [context]— Request a code review/claude-query <question>— Ask about the PR or codebase
Context
The C API lacks a SetDBOptions wrapper, so callers using the C bindings cannot dynamically reconfigure DB-level options at runtime without dropping down to the C++ API.
Changes
rocksdb_set_db_optionsto the C API as a wrapper aroundDB::SetDBOptionsc_test.ccovering both valid and invalid option updates