Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(store): Remove panic from rewind and truncate #5233

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions store/postgres/src/deployment_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,14 +1328,14 @@ impl DeploymentStore {
) -> Result<StoreEvent, StoreError> {
let conn = self.get_conn()?;

// Unwrap: If we are reverting then the block ptr is not `None`.
let block_ptr_from = Self::block_ptr_with_conn(&conn, site.cheap_clone())?.unwrap();
let block_ptr_from = Self::block_ptr_with_conn(&conn, site.cheap_clone())?;

// Sanity check on block numbers
if block_ptr_from.number <= block_ptr_to.number {
let from_number = block_ptr_from.map(|ptr| ptr.number);
if from_number <= Some(block_ptr_to.number) {
constraint_violation!(
"truncate must go backwards, but would go from block {} to block {}",
block_ptr_from.number,
from_number.unwrap_or(0),
block_ptr_to.number
);
}
Expand All @@ -1352,14 +1352,14 @@ impl DeploymentStore {
) -> Result<StoreEvent, StoreError> {
let conn = self.get_conn()?;

// Unwrap: If we are reverting then the block ptr is not `None`.
let block_ptr_from = Self::block_ptr_with_conn(&conn, site.cheap_clone())?.unwrap();
let block_ptr_from = Self::block_ptr_with_conn(&conn, site.cheap_clone())?;

// Sanity check on block numbers
if block_ptr_from.number <= block_ptr_to.number {
let from_number = block_ptr_from.map(|ptr| ptr.number);
if from_number <= Some(block_ptr_to.number) {
constraint_violation!(
"rewind must go backwards, but would go from block {} to block {}",
block_ptr_from.number,
from_number.unwrap_or(0),
block_ptr_to.number
);
}
Expand Down
Loading