Skip to content

Commit

Permalink
store: Fix duration tracking during copying
Browse files Browse the repository at this point in the history
  • Loading branch information
lutter committed Apr 2, 2021
1 parent 436da11 commit b414c33
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions store/postgres/src/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ impl TableState {
}

fn record_progress(
&self,
&mut self,
conn: &PgConnection,
elapsed: Duration,
first_batch: bool,
Expand All @@ -391,8 +391,7 @@ impl TableState {

// This conversion will become a problem if a copy takes longer than
// 300B years
let elapsed = i64::try_from(elapsed.as_millis()).unwrap_or(0);
let duration_ms = self.duration_ms + elapsed;
self.duration_ms += i64::try_from(elapsed.as_millis()).unwrap_or(0);

if first_batch {
// Reset started_at so that finished_at - started_at is an
Expand All @@ -408,7 +407,7 @@ impl TableState {
let values = (
cts::next_vid.eq(self.next_vid),
cts::batch_size.eq(self.batch_size),
cts::duration_ms.eq(duration_ms),
cts::duration_ms.eq(self.duration_ms),
);
update(
cts::table
Expand Down

0 comments on commit b414c33

Please sign in to comment.