Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: replace GetManagedAgentCount query with aggregate table#19636

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
deansheather merged 3 commits intomainfromdean/remove-get-managed-agent-count-query
Aug 29, 2025

Conversation

deansheather
Copy link
Member

@deansheatherdeansheather commentedAug 29, 2025
edited
Loading

  • Removes GetManagedAgentCount query
  • Adds new tableusage_events_daily which stores aggregated usage events by the type and UTC day
  • Adds trigger to update the values in this table when a new row is inserted intousage_events
  • Adds a migration that addsusage_events_daily rows for existing data inusage_events
  • Adds tests for the trigger
  • Adds tests for the backfill query in the migration

Since theusage_events table is unreleased currently, this migration will do nothing on real deployments and will only affect preview deployments such as dogfood.

Closescoder/internal#943

- Removes GetManagedAgentCount query- Adds new table `usage_events_daily` which stores aggregated usage  events by the type and UTC day- Adds trigger to update the values in this table when a new row is  inserted into `usage_events`- Adds a migration that adds `usage_events_daily` rows for existing data  in `usage_events`Since the `usage_events` table is unreleased currently, this migrationwill do nothing on real deployments and will only affect previewdeployments such as dogfood.
@deansheatherdeansheather added the cherry-pick/v2.26Needs to be cherry-picked to the 2.26 release branch labelAug 29, 2025
RETURNS TRIGGER AS $$
BEGIN
-- Check for supported event types and throw error for unknown types
IF NEW.event_type NOT IN ('dc_managed_agents_v1') THEN
Copy link
Member

Choose a reason for hiding this comment

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

My main worry with this is that if some bad code spams insertion of unknown usage events we could end up creating some serious DB load. IIRC you make it fairly difficult to even do that though, so I guess this is OK?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I imagine it would generate a lot of load anyway if something like that was happening. This upsert should be fairly quick since it's using the primary key.

I also don't know how else I'd handle this other than a cronjob, which would also generate a lot of load if there was a lot of rows, and would require a new Go package to handle doing it every once in a while.

Copy link
Member

Choose a reason for hiding this comment

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

reminder to check migration number before merge

deansheather reacted with thumbs up emoji
@deansheatherdeansheather merged commit39bf3ba intomainAug 29, 2025
26 checks passed
@deansheatherdeansheather deleted the dean/remove-get-managed-agent-count-query branchAugust 29, 2025 17:39
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 29, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@cstyancstyanAwaiting requested review from cstyan

@ethanndicksonethanndicksonAwaiting requested review from ethanndickson

Assignees

@deansheatherdeansheather

Labels
cherry-pick/v2.26Needs to be cherry-picked to the 2.26 release branch
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

bug: GetManagedAgentCount is called > 100k times per day and creates lots of DB load
2 participants
@deansheather@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp