Skip to content

Commit a2316b9

Browse files
authored
Fix error during_commit tracking in auto-commit transactions (#49)
After `RUN` has successfully been sent, the server might commit the transaction at any time (but no later than when the result stream has been fully consumed). Therefore, any disconnect (i/o error) that occurs after an auto-commit's `RUN` has been sent must be considered to have happened `during_commit`. This most notably affects `Neo4jError::is_retryable`.
1 parent ea939eb commit a2316b9

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- Fix `connection_acquisition_timeout` config not being applied to limit fetching of routing tables.
3131
- Fix the driver handling cluster network partitioning poorly by accepting the first routing table regardless whether
3232
it contains a writer or not.
33+
- Fix auto-commit such that any connectivity error after sending the `RUN` message is considered to have happened `during_commit`.
3334

3435

3536
## 0.2.0

neo4j/src/driver/record_stream.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,13 @@ impl<'driver> RecordStream<'driver> {
9696
let mut res = self.connection.borrow_mut().run(parameters, callbacks);
9797
if self.auto_commit {
9898
res = res.and_then(|_| self.connection.borrow_mut().write_all(None));
99-
res = match res.and_then(|_| self.pull(true)) {
100-
Err(e) => {
101-
let mut listener = self.listener.borrow_mut();
102-
listener.state = RecordListenerState::Done;
103-
return Err(e);
104-
}
105-
Ok(res) => Ok(res),
99+
if let Err(e) = res {
100+
let mut listener = self.listener.borrow_mut();
101+
listener.state = RecordListenerState::Done;
102+
return Err(e);
106103
}
107-
} else {
108-
res = self.pull(true);
109104
}
105+
res = res.and_then(|_| self.pull(true));
110106

111107
if let Err(e) = res.and_then(|_| {
112108
// read until only response(s) to PULL is/are left

neo4j/src/driver/session/retry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub trait RetryPolicy {
121121
///
122122
/// The policy will return a [`RetryError::Neo4jError`] if the work function returns a
123123
/// non-retryable [`Neo4jError`].
124-
/// It will return a [`RetryError::Timeout`] the policy would start another attempt, but the time
124+
/// It will return a [`RetryError::Timeout`] if the policy would start another attempt, but the time
125125
/// since the end of the first attempt exceeds the maximum retry time.
126126
#[derive(Debug, Clone, Copy)]
127127
pub struct ExponentialBackoff {

0 commit comments

Comments
 (0)