Skip to content

Commit 01e6dd5

Browse files
committed
store: Do not assume that copies start at vid == 0
1 parent 4b4d583 commit 01e6dd5

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

store/postgres/src/copy.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -525,25 +525,24 @@ impl TableState {
525525
&mut self,
526526
conn: &mut PgConnection,
527527
elapsed: Duration,
528-
first_batch: bool,
529528
) -> Result<(), StoreError> {
530529
use copy_table_state as cts;
531530

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

536-
if first_batch {
537-
// Reset started_at so that finished_at - started_at is an
538-
// accurate indication of how long we worked on a table.
539-
update(
540-
cts::table
541-
.filter(cts::dst.eq(self.dst_site.id))
542-
.filter(cts::entity_type.eq(self.batch.dst.object.as_str())),
543-
)
544-
.set(cts::started_at.eq(sql("now()")))
545-
.execute(conn)?;
546-
}
535+
// Reset started_at so that finished_at - started_at is an accurate
536+
// indication of how long we worked on a table if we haven't worked
537+
// on the table yet.
538+
update(
539+
cts::table
540+
.filter(cts::dst.eq(self.dst_site.id))
541+
.filter(cts::entity_type.eq(self.batch.dst.object.as_str()))
542+
.filter(cts::duration_ms.eq(0)),
543+
)
544+
.set(cts::started_at.eq(sql("now()")))
545+
.execute(conn)?;
547546
let values = (
548547
cts::next_vid.eq(self.batch.next_vid),
549548
cts::batch_size.eq(self.batch.batch_size.size),
@@ -591,11 +590,9 @@ impl TableState {
591590
}
592591

593592
fn copy_batch(&mut self, conn: &mut PgConnection) -> Result<Status, StoreError> {
594-
let first_batch = self.batch.next_vid == 0;
595-
596593
let duration = self.batch.run(conn)?;
597594

598-
self.record_progress(conn, duration, first_batch)?;
595+
self.record_progress(conn, duration)?;
599596

600597
if self.finished() {
601598
self.record_finished(conn)?;

0 commit comments

Comments
 (0)