Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 69b4d40

Browse filesBrowse files
committed
fix: keep taking snapshots by schedule (#187)
1 parent e0dacf9 commit 69b4d40
Copy full SHA for 69b4d40

File tree

1 file changed

+12
-11
lines changed
Filter options

1 file changed

+12
-11
lines changed

‎pkg/retrieval/engine/postgres/snapshot/physical.go

Copy file name to clipboardExpand all lines: pkg/retrieval/engine/postgres/snapshot/physical.go
+12-11Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff 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.
189188
func (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

305306
func (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")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.