Skip to content

RDS SQL Server Express: RESOURCE MONITOR and a preemptive worker consume 55% of a 2-vCPU instance with no query load; identical sibling instance is idle

0

Two RDS SQL Server Express instances, same class (db.t3.small, 2 vCPU), same storage (gp3/3000 IOPS), same schema, one holding a restored copy of the other's ~950 MB database. One sits at a flat 60-64% CPU around the clock; the other idles at ~10%. I cannot explain the difference and would appreciate ideas.

Affected:  sqlserver-ex 16.00.4185.3.v1
Control:   sqlserver-ex 15.00.4480.2.v1

The CPU is not queries

Performance Insights db.load.avg averages 0.157 AAS (max 0.59). Batch Requests/sec is 2-4. CPU is identical at 03:00 with 11 connections and at 15:00 with 114. RING_BUFFER_SCHEDULER_MONITOR puts 57-64% on the SQL Server process and 3-7% on everything else, so it is inside sqlservr.exe.

Two threads account for it

30-second delta over sys.dm_os_threads (kernel_time + usermode_time). Window is 60,000 ms across 2 vCPUs:

os_thread_id  kernel   user    total    identity
8684           5,579  12,328  17,907   RESOURCE MONITOR (a system session)
3020               0  14,922  14,922   preemptive worker, no session, no task
all others         -       -    <330

54.7% of the instance in two threads. Both are created at SQL Server startup.

Thread 8684: last_wait_type PREEMPTIVE_XE_CALLBACKEXECUTE,
             context_switch_count 1,375,272,027
Thread 3020: is_preemptive = 1, last_wait_type MEMORY_ALLOCATION_EXT

Because the work is preemptive it never lands in any session's cpu_time, which is why sys.dm_exec_requests and query-level tooling show an idle server. This took me a long time to find and may be the useful part of this post for others.

Side by side, same uptime

                                  affected    control
CPUUtilization                       62.5%       ~10%
PREEMPTIVE_XE_CALLBACKEXECUTE/s      2,403          0
MEMORY_ALLOCATION_EXT/s                671        245
context switches/s                     248         10
committed_target_kb                 413 MB     426 MB
cached plans                           1-3    22-350

The control has MORE memory available to SQL Server. Both run exactly two Extended Events sessions (hkenginexesession, system_health), neither has a user-created session, and both process a comparable number of system_health buffers (2,881 vs 2,978 over four days). Yet one fires 2,403 preemptive XE callbacks per second and the other fires zero.

Ruled out by measurement

  • Memory sizing: control has more and is healthy
  • Storage: both gp3/3000; PAGEIOLATCH_SH not significant
  • Transaction log: 81 VLFs, log_reuse_wait_desc = NOTHING, BACKUPIO and BACKUPTHREAD within 2% of control when normalised for uptime
  • CDC, Change Tracking: off on both
  • Auditing: only the RDS_DAS_* specs, audits disabled, dm_server_audit_status empty
  • SQLCLR: clr enabled = 0, no user assemblies, both CLR tasks idle
  • Triggers: a handful, low volume, none on hot tables
  • Server traces: default trace only, 769 events, identical on both
  • Parallelism: CXPACKET, CXCONSUMER, all CX waits exactly 0
  • Performance Insights collector: 21.6 s of CPU in 2h15m
  • Missing indexes and an application data-retention defect: both found and fixed, no effect on CPU
  • Plan cache collapse looks like a symptom: it falls to 1-3 plans while the condition is present and holds 22-350 while it is not, with no change in committed_target

Behaviour over time

Normal (10-18%) until early August, intermittent for a month, continuous since mid-September. A reboot clears it: CPU held 7-13% for about 18 hours with real traffic, then returned. It has also dropped to 8% unattended for three hours and come back. So it is reversible and recurring, not a one-way latch.

Questions

  1. What can drive PREEMPTIVE_XE_CALLBACKEXECUTE at ~2,400/s when only the two default XE sessions exist and neither is processing more buffers than a healthy control?
  2. What keeps RESOURCE MONITOR at ~44% of a core when sys.dm_os_sys_memory reports "Physical memory usage is steady"?
  3. Is this known on 16.00.4185.3 specifically? The unaffected control runs 15.00.4480.2.
  4. Is there a way to see what a preemptive worker with no task is doing, short of a dump?

Happy to run diagnostics and post results.

asked 2 months ago148 views

1 Answer
0

This is a fascinating and well-documented troubleshooting case. Based on the symptoms you've described—particularly the RESOURCE MONITOR thread consuming significant CPU with PREEMPTIVE_XE_CALLBACKEXECUTE wait types and a preemptive worker with MEMORY_ALLOCATION_EXT waits—here are some insights:

  1. PREEMPTIVE_XE_CALLBACKEXECUTE at high frequency: This wait type indicates Extended Events callback execution happening outside the SQL Server scheduler. Even though both instances run only the default XE sessions (hkenginexesession and system_health), the affected instance is firing callbacks at 2,400/s while the control fires zero. This suggests something is triggering excessive event captures or processing within those sessions. Check if there are differences in the XE session configurations themselves—specifically the event predicates, targets, or buffer settings. Even subtle differences in what events are being captured (especially high-frequency events like statement completions or memory allocations) could cause this behavior. The RESOURCE MONITOR thread may be spending excessive time processing these events.

  2. RESOURCE MONITOR at 44% CPU: The RESOURCE MONITOR is a system thread responsible for monitoring memory pressure, detecting deadlocks, and other health checks. When it shows high CPU with steady physical memory usage, it may be repeatedly evaluating memory conditions or processing internal notifications. The extremely high context switch count (1.375 billion) on this thread is abnormal and suggests it's being awakened very frequently—possibly by the same mechanism driving the XE callbacks. This could indicate an internal feedback loop where memory allocation events trigger XE callbacks, which in turn cause more monitoring activity.

  3. Version-specific behavior (16.00.4185.3 vs 15.00.4480.2): You're running SQL Server 2022 (16.00.4185.3) on the affected instance versus SQL Server 2019 (15.00.4480.2) on the control. This is a significant difference. SQL Server 2022 introduced numerous internal changes to memory management, Extended Events, and system monitoring. There could be a version-specific issue or behavioral change in how the RESOURCE MONITOR interacts with Extended Events in SQL Server 2022. Consider checking if there are newer cumulative updates available for your SQL Server 2022 version that might address internal performance issues. You can use the AWS CLI to check available upgrade targets for your engine version.

  4. Diagnosing the preemptive worker: Without access to memory dumps or deeper diagnostics, options are limited. However, you could try temporarily disabling the Extended Events sessions (even the default ones, if RDS permits) to see if the CPU drops. If you can stop system_health temporarily, this would confirm whether XE processing is the root cause. Additionally, monitor sys.dm_os_memory_clerks to see if any memory clerk is showing unusual activity that might correlate with the MEMORY_ALLOCATION_EXT waits.

Additional suggestions:

  • Since the behavior is reversible after reboot and recurs, consider whether there's a specific workload pattern, connection behavior, or scheduled job that triggers the condition. The fact that it started in early August and became continuous in mid-September suggests an environmental or workload change.

  • Compare the exact Extended Events session definitions between the two instances using sys.server_event_sessions and related DMVs. Even if both show the same sessions, their internal configurations might differ.

  • If you haven't already, consider upgrading the affected instance to a newer SQL Server 2022 cumulative update to rule out known issues.

  • For deeper investigation, you may need to engage AWS Support through the AWS Support Center to analyze RDS-level metrics and potentially capture diagnostics that aren't accessible through standard SQL Server DMVs.

This appears to be an internal SQL Server engine issue, possibly version-specific, where the monitoring and Extended Events subsystems are in an inefficient state. The reversible nature suggests it's not corruption but rather a runtime condition that can be triggered and cleared.
Sources
Major version upgrades for RDS for SQL Server - Amazon Relational Database Service

answered 2 months ago

EXPERT

reviewed 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.