Skip to content

Refactor finalization logic to be compatible with UpdateSyncTarget #1344

@alarso16

Description

@alarso16

Consider the following situation in a dynamic state sync:

There are two Syncers, A and B. Syncer A has a long Sync, but UpdateSyncTarget is really fast. Syncer B has a short Sync, but a long UpdateSyncTarget. We end up with the following sequence:

  1. Start both syncers
  2. Syncer B finishes
  3. UpdateSyncTarget is called
  4. Syncer A finishes, escaping the sync loop
  5. Syncer B finishes its UpdateSyncTarget

Since UpdateSyncTarget can be called after Sync returns, I think we should add one more method on the syncer: Finalize(ctx, target). It handles the finalization logic for each syncer (e.g. database commits), but will also verify that the data is correct and waits until all UpdateSyncTarget's finish.

While completing a resolution for this, it may be convenient to also consider resolving #1089

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions