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

fix: Move redis cache outside of pg transaction #17509

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

tiina303
Copy link
Contributor

@tiina303 tiina303 commented Sep 18, 2023

Problem

We were doing redis updates within a PG transaction - that's a bad idea. This caused groupidentify events processing to lock up PG and when we got a lot of groupidentify events coming in that would create lag in ingestion.

There isn't really any way to guarantee consistency across the two different data sources, so we might as well do it afterwards outside of the transaction. We run into the same problem with the CH writes anyway too.

more context: https://posthog.slack.com/archives/C0185UNBSJZ/p1695056250917589?thread_ts=1695050984.560789&cid=C0185UNBSJZ

Changes

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

How did you test this code?

@tiina303 tiina303 marked this pull request as draft September 18, 2023 17:23
@tiina303 tiina303 marked this pull request as ready for review September 19, 2023 11:21
@tiina303 tiina303 requested a review from a team September 19, 2023 11:21
Copy link
Contributor

@bretthoerner bretthoerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -631,46 +631,6 @@ describe('DB', () => {
version: 2,
})
})

describe('with caching', () => {
it('insertGroup() and updateGroup() update cache', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this test is worth keeping if we changed it to calling upsertGroup, or no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this, but we don't have any tests for that yet and that seems rather low priority given our plans to move to kv store longer term

@tiina303 tiina303 merged commit 1cdcedb into master Sep 19, 2023
72 checks passed
@tiina303 tiina303 deleted the group-identify-transaction-no-redis branch September 19, 2023 13:26
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.

2 participants