File tree 1 file changed +12
-11
lines changed
Filter options
pkg/retrieval/engine/postgres/snapshot 1 file changed +12
-11
lines changed
Original file line number Diff line number Diff line change @@ -76,7 +76,6 @@ type PhysicalInitial struct {
76
76
dbMark * dbmarker.Config
77
77
dockerClient * client.Client
78
78
scheduler * cron.Cron
79
- scheduleOnce sync.Once
80
79
promotionMutex sync.Mutex
81
80
}
82
81
@@ -188,10 +187,18 @@ func (p *PhysicalInitial) Name() string {
188
187
// Run starts the job.
189
188
func (p * PhysicalInitial ) Run (ctx context.Context ) (err error ) {
190
189
// Start scheduling after initial snapshot.
191
- defer func () {
192
- p .scheduleOnce .Do (p .startScheduler (ctx ))
193
- }()
190
+ defer p .startScheduler (ctx )()
191
+
192
+ if p .options .SkipStartSnapshot {
193
+ log .Msg ("Skip taking a snapshot at the start" )
194
+
195
+ return nil
196
+ }
194
197
198
+ return p .run (ctx )
199
+ }
200
+
201
+ func (p * PhysicalInitial ) run (ctx context.Context ) (err error ) {
195
202
select {
196
203
case <- ctx .Done ():
197
204
if p .scheduler != nil {
@@ -204,12 +211,6 @@ func (p *PhysicalInitial) Run(ctx context.Context) (err error) {
204
211
default :
205
212
}
206
213
207
- if p .options .SkipStartSnapshot {
208
- log .Msg ("Skip taking a snapshot at the start" )
209
-
210
- return nil
211
- }
212
-
213
214
p .dbMark .DataStateAt = extractDataStateAt (p .dbMarker )
214
215
215
216
// Snapshot data.
@@ -304,7 +305,7 @@ func (p *PhysicalInitial) startScheduler(ctx context.Context) func() {
304
305
305
306
func (p * PhysicalInitial ) runAutoSnapshot (ctx context.Context ) func () {
306
307
return func () {
307
- if err := p .Run (ctx ); err != nil {
308
+ if err := p .run (ctx ); err != nil {
308
309
log .Err (errors .Wrap (err , "failed to take a snapshot automatically" ))
309
310
310
311
log .Msg ("Interrupt automatic snapshots" )
You can’t perform that action at this time.
0 commit comments