Skip to content

Commit 7cb1280

Browse files
committed
revert order of waitingForInstances alteration and LoadOnce
1 parent 7e4d9d7 commit 7cb1280

2 files changed

Lines changed: 11 additions & 14 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/PowerDNS/lightningstream
22

3-
go 1.24.0
3+
go 1.24.13
44

55
require (
66
github.com/CrowdStrike/csproto v0.35.0

syncer/sync.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,11 @@ func (s *Syncer) syncLoop(ctx context.Context, env *lmdb.Env, r *receiver.Receiv
211211
}).Debug("Loading update")
212212
}
213213

214-
actualTxnID, localChanged, err := s.LoadOnce(
215-
ctx, env, instance, update, lastSyncedTxnID)
216-
update.Close() // releases the DecompressedSnapshotToken
217-
if err != nil {
218-
return err
219-
}
220-
221214
if update.NameInfo.Kind == snapshot.KindSnapshot {
222215
nLoads++
223-
if waitingForInstances.Contains(instance) {
224-
if s.hooks.InstanceReady == nil {
225-
s.l.WithField("other_instance", instance).Info("No longer waiting for instance")
226-
waitingForInstances.Remove(instance)
227-
}
216+
if waitingForInstances.Contains(instance) && s.hooks.InstanceReady == nil {
217+
s.l.WithField("other_instance", instance).Info("No longer waiting for instance")
218+
waitingForInstances.Remove(instance)
228219
}
229220
}
230221
if waitingForInstances.Contains(instance) && s.hooks.InstanceReady != nil {
@@ -236,6 +227,13 @@ func (s *Syncer) syncLoop(ctx context.Context, env *lmdb.Env, r *receiver.Receiv
236227
}
237228
}
238229

230+
actualTxnID, localChanged, err := s.LoadOnce(
231+
ctx, env, instance, update, lastSyncedTxnID)
232+
update.Close() // releases the DecompressedSnapshotToken
233+
if err != nil {
234+
return err
235+
}
236+
239237
// Publish a successful load
240238
s.events.UpdateLoaded.Publish(events.UpdateInfo{
241239
NameInfo: update.NameInfo,
@@ -345,7 +343,6 @@ func (s *Syncer) syncLoop(ctx context.Context, env *lmdb.Env, r *receiver.Receiv
345343
}
346344

347345
// Sleep before next check for snapshots and local changes
348-
// s.l.Debug("Waiting for a new transaction")
349346
if err := utils.SleepContext(ctx, s.c.LMDBPollInterval); err != nil {
350347
return err
351348
}

0 commit comments

Comments
 (0)