Repository navigation
Add Python bindings for native CDC - #13925
tclinkenbeard-oai merged 5 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
tclinkenbeard-oai
left a comment
There was a problem hiding this comment.
Generated by Codex.
Reviewed head: ee1fa01.
What is it trying to do?
Expose native CDC through Python: stream management, resumable consumers, asynchronous consumption and explicit acknowledgement, with owned result records and documented checkpoint/replay semantics.
Is it correct?
Yes, based on source inspection. The ctypes layouts and signatures match the C API, returned bytes are copied, repeated consumer-future retrieval preserves one Python owner, and native references protect outstanding operations after handle closure. API-version checks and lazy symbol resolution preserve ordinary non-CDC use.
The corrected restart example now waits for a fresh read version to cover the saved checkpoint before re-acknowledging. It bounds that wait, handles database locks, and does not indiscriminately retry invalid-operation errors.
Are there bugs?
I did not find any correctness bugs in this round. The previously identified restart failure is addressed in the published revision.
Are there omissions?
None that block this change. The principal remaining coverage gap is concurrent future retrieval, cancellation, and closing a consumer with an operation in flight. The ownership paths look sound, but the new tests do not directly exercise those races.
Are there better ways of doing things?
One small, nonblocking test improvement: assert that the consumer is closed immediately after the with block, before calling assert_closed(). That helper explicitly closes the consumer itself, so the current test would pass with a broken __exit__.
No broader restructuring looks necessary.
Should this CL be LGTMd?
Yes, LGTM, based on inspection of the binding ABI, ownership and error paths, checkpoint recovery, compatibility handling, and test integration. Concurrent lifecycle behavior remains the highest residual runtime risk.
At review time, clang-format, clang-tidy, and Windows Boost checks pass; platform builds and cluster tests remain pending. No current-head failure is visible. PR checks.
No builds, tests, simulations, or other validation were run in this review round.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@tclinkenbeard-oai I asked codex to review all the related PRs together and found this issue P1 when integrating with #13971 — ctypes still declares and calls the old ABI. The registration call passes seven arguments, and CdcStreamInfoStruct embeds a single key range. #13971's C registration function takes a range-array pointer/count, and its stream-info record uses a pointer/count instead of that embedded range. These are the same exported symbol names. API 800 and successful symbol lookup do not identify which layout is loaded. On a combined build, registration can reinterpret key bytes as structs; listing can interpret other fields as pointers or lengths. This can produce invalid memory access, not just a missing Python feature. Update signatures, argument construction, immutable stream-info records, copying, examples, and C-backed tests to the final multi-range API. Do not release these two heads together unchanged. |
mengxu-oai
left a comment
There was a problem hiding this comment.
lgtm. the comment is known to Trevor. He needs one of the PRs to be merged so that he can resolve the issue.
Result of foundationdb-pr-macos-m1 on macOS 14.x
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
This comment has been minimized.
This comment has been minimized.
Result of foundationdb-pr-macos on macOS 14.x
|
Summary
register_cdc_stream(name, ranges=[(begin, end), ...]), while retaining the single-rangeregister_cdc_stream(name, begin, end)form. Listed streams expose their canonical union as immutable, Python-ownedCdcKeyRangerecords.Validation
python_native_cdc_tests: passed all 8 tests, including canonical range unions, binary result ownership, gap filtering, clipped clears, acknowledgement/resume, and single-range compatibility.python_native_cdc_legacy_api_tests: passed with API version 740.python_unit_tests: passed.Compatibility
CDC requires API version 800 or later, the multi-range native CDC implementation, and cluster admission for new streams. Earlier experimental single-range CDC binaries have an incompatible ABI; drain and remove their streams and finish retired cleanup before upgrading all CDC-capable clients and servers.
Closing a consumer neither acknowledges mutations nor removes its stream. All registered ranges share one cursor and acknowledgement frontier. Results own their bytes independently of native futures, and unknown raw mutation codes remain available to callers. Single-range stream metadata retains
begin_keyandend_keyproperties; multi-range callers useranges.