fix(arrow_stream): propagate errors instead of panicking on connection setup#910
Open
ricardo-valero wants to merge 1 commit into
Open
Conversation
…n setup new_record_batch_iter used .unwrap() throughout, which masked the underlying r2d2/Postgres connection error as `Error(None)` and panicked the thread when TLS handshake or other setup failed. Mirror the error handling in get_arrow by adding #[throws(ConnectorXOutError)] and propagating with ?. Adds From impls on ConnectorXOutError for each *ArrowStream* transport error variant so ? can wrap them. Updates the Python and C++ callers to handle the new Result return type. Fixes sfu-db#909
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #909 —
return_type=\"arrow_stream\"panicked atconnectorx/src/get_arrow.rs:318:22(or:355for cursor) withPostgresPoolError(Error(None))whenever the initial Postgres connection setup failed (notably withsslmode=require), while the equivalentreturn_type=\"arrow\"succeeded.The root cause is that
new_record_batch_iterused.unwrap()everywhere, panicking the thread and masking the wrapped r2d2 error.get_arrowalready returned errors via#[throws(ConnectorXOutError)]and?; this change brings the streaming path in line.Changes
connectorx/src/get_arrow.rs—new_record_batch_iteris now#[throws(ConnectorXOutError)]; every.unwrap()becomes?. Returns are typed throughlet iter: Box<dyn RecordBatchIterator>so the unsizing coercion is explicit.connectorx/src/errors.rs— addsFrom<…>impls onConnectorXOutErrorfor each*ArrowStream*transport error so?can wrap them.connectorx-python/src/arrow.rs— propagates the newResultwith?(the surrounding function already returnsConnectorXPythonError, which has aFrom<ConnectorXOutError>).connectorx-cpp/src/lib.rs— keeps current behavior with an explicit.unwrap()(FFI boundary; same as the surrounding code).connectorx-python/connectorx/tests/test_postgres.py— adds a TLS arrow_stream regression test and an explicit “bad host raises” test that exercises the error path.Test plan
cargo check+cargo build --all-featureson the workspacecargo test --lib(no unit tests defined for this module)POSTGRES_URL_TLS) —test_postgres_tls_arrow_streamandtest_postgres_tls_arrow_stream_bad_host_raisessslmode=requireto confirm the panic is replaced with aRuntimeErrorcarrying the underlying r2d2 message