Skip to content

MDM Windows push perf fixes - #46917

Merged
getvictor merged 34 commits into
mainfrom
43773-osquery-perf
Jun 8, 2026
Merged

MDM Windows push perf fixes#46917
getvictor merged 34 commits into
mainfrom
43773-osquery-perf

Conversation

@getvictor

@getvictor getvictor commented Jun 5, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #46567

Loadtest feedback: reducing the number of UPDATE mdm_windows_enrollments e SET e.has_pending_commands writes.

Checklist for submitter

Testing

Database migrations

  • Checked schema for all modified table for columns that will auto-update timestamps during migration.
  • Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Windows MDM enrolled devices to correctly track pending commands. Acknowledged commands are now properly removed from the pending list, and the system accurately reflects command status after device acknowledgment. Command cleanup for processed requests is now more efficient.

getvictor added 26 commits June 1, 2026 19:23
Relax the Windows MDM DMClient poll schedule in-session, gated on the host's
fleetd (orbit) version and reconciled against a persisted applied-state column.

- getPollScheduleCommands: desired-relaxed (orbit >= 1.56.0, via GetHostOrbitInfo)
  vs applied (mdm_windows_enrollments.poll_schedule_relaxed). Emits one Replace on
  .../Poll/IntervalForFirstSetOfRetries (60 relax / 1 restore) only when they differ.
- windowsMDMHostSupportsSync: missing/unlinked host or unknown version => not-capable
  (stay on the fast poll, the safe default).
- Migration 20260601204606 adds poll_schedule_relaxed TINYINT(1) NOT NULL DEFAULT 0.
- Datastore setter + enrolled-device SELECT + interface + regenerated mock.
- Tests: TestGetPollScheduleCommands, testMDMWindowsPollScheduleRelaxed, migration test.
…dm-wake

# Conflicts:
#	server/datastore/mysql/schema.sql
#	server/service/microsoft_mdm_test.go
…dm-wake

# Conflicts:
#	server/datastore/mysql/schema.sql
# Conflicts:
#	server/datastore/mysql/microsoft_mdm.go
#	server/datastore/mysql/microsoft_mdm_test.go
#	server/datastore/mysql/schema.sql
The merge from main reintroduced the old recompute-on-ack assertion above the
updated soft-dequeue + per-session refresh assertions.
@getvictor
getvictor requested a review from Copilot June 5, 2026 16:36
@getvictor

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@getvictor
getvictor requested a review from Copilot June 5, 2026 16:59
@getvictor

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@getvictor

Copy link
Copy Markdown
Member Author

/agentic_review

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 5, 2026

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2eecab2

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/datastore/mysql/microsoft_mdm.go`:
- Around line 349-357: The recompute currently triggered by
MDMWindowsRefreshHasPendingCommands (which calls
recomputeMDMWindowsHasPendingCommandsByEnrollmentIDs) should run only when there
are no non-poll pending commands left, not when the full pending-command set is
empty; update the callers that currently run the recompute after
MDMWindowsGetPendingCommands returns zero rows so they instead inspect the
returned rows and trigger recompute only if none of the rows are a poll-schedule
Replace (i.e., filter out poll-schedule/poll commands by their command
type/target and treat those as excluded), and apply the same change to the other
call sites that use MDMWindowsGetPendingCommands before calling
recomputeMDMWindowsHasPendingCommandsByEnrollmentIDs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bad51649-b612-46d7-a33b-bfd05b1b9f44

📥 Commits

Reviewing files that changed from the base of the PR and between f19c9a6 and 2eecab2.

📒 Files selected for processing (11)
  • server/datastore/mysql/mdm.go
  • server/datastore/mysql/microsoft_mdm.go
  • server/datastore/mysql/microsoft_mdm_test.go
  • server/datastore/mysql/migrations/tables/20260605151542_AddAckedAtToWindowsMDMCommandQueue.go
  • server/datastore/mysql/migrations/tables/20260605151542_AddAckedAtToWindowsMDMCommandQueue_test.go
  • server/datastore/mysql/schema.sql
  • server/fleet/datastore.go
  • server/fleet/microsoft_mdm.go
  • server/mock/datastore_mock.go
  • server/service/microsoft_mdm.go
  • server/service/microsoft_mdm_test.go

Comment thread server/datastore/mysql/microsoft_mdm.go
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.62745% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.03%. Comparing base (ed50c8a) to head (571ee23).

Files with missing lines Patch % Lines
...260606051849_AddAckedAtToWindowsMDMCommandQueue.go 64.70% 4 Missing and 2 partials ⚠️
server/service/microsoft_mdm.go 57.14% 5 Missing and 1 partial ⚠️
server/datastore/mysql/microsoft_mdm.go 78.94% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #46917      +/-   ##
==========================================
- Coverage   67.04%   67.03%   -0.01%     
==========================================
  Files        2867     2864       -3     
  Lines      225117   225059      -58     
  Branches    11743    11578     -165     
==========================================
- Hits       150926   150869      -57     
+ Misses      60521    60515       -6     
- Partials    13670    13675       +5     
Flag Coverage Δ
backend 68.74% <68.62%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@getvictor
getvictor marked this pull request as ready for review June 5, 2026 18:35
@getvictor
getvictor requested a review from a team as a code owner June 5, 2026 18:35

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

ksykulev
ksykulev previously approved these changes Jun 5, 2026

@ksykulev ksykulev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me.
Just need to merge main and re-number the migration and it's good to go.

# Conflicts:
#	server/datastore/mysql/schema.sql
@getvictor

Copy link
Copy Markdown
Member Author

@ksykulev merged with main. Ready for re-approval.

@getvictor
getvictor merged commit cd5c44d into main Jun 8, 2026
42 checks passed
@getvictor
getvictor deleted the 43773-osquery-perf branch June 8, 2026 14:34
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.

Windows MDM push (device wake) via fleetd

3 participants