Skip to content

Conversation

@pepicrft
Copy link
Contributor

@pepicrft pepicrft commented Sep 11, 2025

I noted in our logs that the timeouts happened when we tried to batch-insert cache action items into the database.

image

It turns out the larger the table is, the more expensive that operation will become because of the indexes and the foreign key, so the operation was likely being terminated by the DB.

To fix the issue I've removed the foreign key to project_id and some redundant indexes, and reduced the batch size from 100 to 20. I also removed dropped the insertion of cache events. We used them in the past to check if a cache object existed, but we moved away from that to use the storage as a source of truth, so this is no longer needed. There was still one usage, our daily Slack usage report, but we don't need it.

@pepicrft pepicrft self-assigned this Sep 11, 2025
@dosubot dosubot bot added the size:L For issues that take up to a day to implement label Sep 11, 2025
@github-actions
Copy link
Contributor

✅ CLA Check Passed

Thank you @pepicrft! Your contribution is ready to be reviewed. The CLA requirement has been satisfied.

@dosubot dosubot bot added the domain:module-cache For issues and PRs related to the Module Cache label Sep 11, 2025
@github-actions
Copy link
Contributor

✅ CLA Check Passed

Thank you @pepicrft! Your contribution is ready to be reviewed. The CLA requirement has been satisfied.

Copy link
Member

@fortmarek fortmarek left a comment

Choose a reason for hiding this comment

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

We used them in the past to check if a cache object existed, but we moved away from that to use the storage as a source of truth, so this is no longer needed.

Should we just drop that table altogether if we don't use it anymore?

Comment on lines -81 to -86
%{
type: "rich_text_section",
elements: [
%{type: "text", text: "📦 Cache events: ", style: %{bold: true}},
%{type: "text", text: format_numbers(cache_event_numbers)}
]
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be good to track how many cache hits we keep getting, but we don't need to use a table for this. In fact, we don't need that in the slack reporter at all, but would consider including it as part of posthog analytics. Not high priority, though, so for now, we can just get rid of this.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 11, 2025
@github-actions
Copy link
Contributor

✅ CLA Check Passed

Thank you @pepicrft! Your contribution is ready to be reviewed. The CLA requirement has been satisfied.

@pepicrft pepicrft merged commit 00a6b91 into main Sep 11, 2025
11 checks passed
@pepicrft pepicrft deleted the fix-db-timeouts branch September 11, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain:module-cache For issues and PRs related to the Module Cache lgtm This PR has been approved by a maintainer size:L For issues that take up to a day to implement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants