Skip to content

Commit ac7ce8e

Browse files
committed
Fix supersede checksum calculation
1 parent 10bf018 commit ac7ce8e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

crates/core/src/sync/checksum.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use core::{
22
fmt::Display,
33
num::Wrapping,
4-
ops::{Add, AddAssign},
4+
ops::{Add, AddAssign, Sub, SubAssign},
55
};
66

77
use num_traits::float::FloatCore;
@@ -60,6 +60,20 @@ impl AddAssign for Checksum {
6060
}
6161
}
6262

63+
impl Sub for Checksum {
64+
type Output = Self;
65+
66+
fn sub(self, rhs: Self) -> Self::Output {
67+
Self(self.0 - rhs.0)
68+
}
69+
}
70+
71+
impl SubAssign for Checksum {
72+
fn sub_assign(&mut self, rhs: Self) {
73+
self.0 -= rhs.0;
74+
}
75+
}
76+
6377
impl From<u32> for Checksum {
6478
fn from(value: u32) -> Self {
6579
Self::from_value(value)

crates/core/src/sync/operations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ INSERT OR IGNORE INTO ps_updated_rows(row_type, row_id) VALUES(?1, ?2)",
8181
// Superseded (deleted) a previous operation, add the checksum
8282
let supersede_checksum = Checksum::from_i32(supersede_statement.column_int(1));
8383
add_checksum += supersede_checksum;
84-
op_checksum += supersede_checksum;
84+
op_checksum -= supersede_checksum;
8585

8686
// Superseded an operation, only skip if the bucket was empty
8787
// Previously this checked "superseded_op <= last_applied_op".

0 commit comments

Comments
 (0)