Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable importer leader election #1899

Closed
steven-sheehy opened this issue Apr 27, 2021 · 0 comments · Fixed by #2124
Closed

Enable importer leader election #1899

steven-sheehy opened this issue Apr 27, 2021 · 0 comments · Fixed by #2124
Assignees
Labels
enhancement Type: New feature P2 parser Area: File parsing
Milestone

Comments

@steven-sheehy
Copy link
Member

steven-sheehy commented Apr 27, 2021

Problem
The importer supports leadership election via configmap locks using Spring Cloud Kubernetes. Despite this, there are still probably race conditions that would cause the database to get out of sync if leader election was enabled. Consider the below scenario:

  1. Last file in DB is T1
  2. Pod A marked unready while downloading T4, T3 is in queue, and in the middle of parsing T2
  3. B elected leader and sees T1 as last and starts downloading T2
  4. A finishes parsing T2

Solution
Test multiple importer pods and ensure data processing remains consistent when primary pod is both killed and marked unready. Make changes as necessary to ensure consistency. This is what should occur:

  • if A imports T2 successfully, then B downloads T2-T4, B discards T2, A discards T3-T4
  • If A imports T2 unsuccessfully, then B downloads T2-T4, B imports T2, A discards T2-T4
  • If A and B are processing T2 simultaneously during either scenario, one of them will insert first and the other will fail with an unique constraint violation and be discarded on the next poll.

Tasks:

  • Add @Leader around parsers
  • Add a stream file existence check inside each parser and discard if it exists
  • Set values-prod.yaml to 2 importer replicas

Alternatives

Additional Context

@steven-sheehy steven-sheehy added the enhancement Type: New feature label Apr 27, 2021
@steven-sheehy steven-sheehy added P2 parser Area: File parsing labels May 17, 2021
@steven-sheehy steven-sheehy added this to the Mirror 0.36.0 milestone Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type: New feature P2 parser Area: File parsing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant