File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed
pkg/retrieval/engine/postgres/snapshot Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,6 @@ type PhysicalInitial struct {
7676 dbMark * dbmarker.Config
7777 dockerClient * client.Client
7878 scheduler * cron.Cron
79- scheduleOnce sync.Once
8079 promotionMutex sync.Mutex
8180}
8281
@@ -188,10 +187,18 @@ func (p *PhysicalInitial) Name() string {
188187// Run starts the job.
189188func (p * PhysicalInitial ) Run (ctx context.Context ) (err error ) {
190189 // 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+ }
194197
198+ return p .run (ctx )
199+ }
200+
201+ func (p * PhysicalInitial ) run (ctx context.Context ) (err error ) {
195202 select {
196203 case <- ctx .Done ():
197204 if p .scheduler != nil {
@@ -204,12 +211,6 @@ func (p *PhysicalInitial) Run(ctx context.Context) (err error) {
204211 default :
205212 }
206213
207- if p .options .SkipStartSnapshot {
208- log .Msg ("Skip taking a snapshot at the start" )
209-
210- return nil
211- }
212-
213214 p .dbMark .DataStateAt = extractDataStateAt (p .dbMarker )
214215
215216 // Snapshot data.
@@ -304,7 +305,7 @@ func (p *PhysicalInitial) startScheduler(ctx context.Context) func() {
304305
305306func (p * PhysicalInitial ) runAutoSnapshot (ctx context.Context ) func () {
306307 return func () {
307- if err := p .Run (ctx ); err != nil {
308+ if err := p .run (ctx ); err != nil {
308309 log .Err (errors .Wrap (err , "failed to take a snapshot automatically" ))
309310
310311 log .Msg ("Interrupt automatic snapshots" )
You can’t perform that action at this time.
0 commit comments