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

refactor: Redshift batch export uses spmc consumer #26897

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tomasfarias
Copy link
Contributor

@tomasfarias tomasfarias commented Dec 13, 2024

Problem

Redshift batch export is not using SPMC abstractions, instead it is doing its own thing. This leads to duplication and harder to read code. The main reason it wasn't migrated is that Redshift doesn't write to a file but instead to a query that then gets executed. We can still adapt the same abstractions as all other batch exports though, so that's what we do here.

Changes

  • Create a new BatchExportWriter: RedshiftInsertBatchExportWriter. This new writer will write INSERT queries for Redshift.
  • Redshift now runs a RedshiftConsumer that flushes these queries by executing them.
  • run_consumer_loop is now run_consumer as we no longer run multiple in a loop, this may change later.
  • Also run_consumer now takes an instance of Consumer which simplifies the signature slightly.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

How did you test this code?

@tomasfarias tomasfarias changed the title refactor: Initialize consumer separate from run_consumer_loop refactor: Redshift batch export uses spmc consumer Dec 13, 2024
@tomasfarias tomasfarias force-pushed the refactor/redshift-batch-export-uses-spmc-consumer branch from 9e1e133 to 97bf04c Compare December 13, 2024 15:00
@tomasfarias tomasfarias requested a review from rossgray December 13, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant