@@ -69,15 +69,6 @@ const (
69
69
repairBatchSize = 1_000_000
70
70
)
71
71
72
- // queryLoopXactID performs pg_current_xact_id() in a server-side loop in the
73
- // database in order to increment the xact_id.
74
- var queryLoopXactID = fmt .Sprintf (`DO $$
75
- BEGIN
76
- FOR i IN 1..%d LOOP
77
- PERFORM pg_current_xact_id(); ROLLBACK;
78
- END LOOP;
79
- END $$;` , repairBatchSize )
80
-
81
72
var livingTupleConstraints = []string {"uq_relation_tuple_living_xid" , "pk_relation_tuple" }
82
73
83
74
func init () {
@@ -573,8 +564,7 @@ func (pgd *pgDatastore) repairTransactionIDs(ctx context.Context, outputProgress
573
564
574
565
for i := 0 ; i < counterDelta ; i ++ {
575
566
batchCount := min (repairBatchSize , counterDelta - i )
576
-
577
- if _ , err := conn .Exec (ctx , queryLoopXactID ); err != nil {
567
+ if _ , err := conn .Exec (ctx , queryLoopXactID (batchCount )); err != nil {
578
568
return err
579
569
}
580
570
@@ -596,6 +586,17 @@ func (pgd *pgDatastore) repairTransactionIDs(ctx context.Context, outputProgress
596
586
return nil
597
587
}
598
588
589
+ // queryLoopXactID performs pg_current_xact_id() in a server-side loop in the
590
+ // database in order to increment the xact_id.
591
+ func queryLoopXactID (batchSize int ) string {
592
+ return fmt .Sprintf (`DO $$
593
+ BEGIN
594
+ FOR i IN 1..%d LOOP
595
+ PERFORM pg_current_xact_id(); ROLLBACK;
596
+ END LOOP;
597
+ END $$;` , batchSize )
598
+ }
599
+
599
600
// RepairOperations returns the available repair operations for the datastore.
600
601
func (pgd * pgDatastore ) RepairOperations () []datastore.RepairOperation {
601
602
return []datastore.RepairOperation {
0 commit comments