PREEMPTIVE_OS Group Lookup Wait Types in SQL Server

⏳Part of the SQL Server Wait Types Library, every wait type explained.Related deep dive: SOS_SCHEDULER_YIELD Wait TypeRelated pillar: Performance & Troubleshooting
⚡These waits are SQL Server asking Windows, and usually a domain controller, which groups an account belongs to. At background levels they are normal. When they climb, either something is asking far too often or the domain controllers are answering slowly. Run the check to see which, by count and by average time per call.

Several preemptive waits cover Windows group membership and directory calls, and this page takes them together: PREEMPTIVE_OS_NETGROUPGETUSERS, NETLOCALGROUPGETMEMBERS, NETUSERGETGROUPS, NETUSERGETLOCALGROUPS, NETUSERMODALSGET, DOMAINSERVICESOPS and DIRSVC_NETWORKOPS.

Microsoft lists them as internal use only in sys.dm_os_wait_stats, so the name is the best guide: each is the Windows function SQL Server was calling, such as NetUserGetGroups. While the call runs, the thread is in preemptive mode, outside SQL Server’s scheduler, and the time is spent in Windows and on the network. Typical callers are xp_logininfo listing a group’s members, and membership checks such as IS_MEMBER() against a Windows group.


Is It a Problem?

At background levels, no. They are worth a look in two situations. The first is volume: a job or an application calling xp_logininfo or a membership check over and over, so every call becomes another trip to a domain controller. The second is duration: slow or distant domain controllers stretch every call, and accounts that sit in a great many nested groups make each answer more expensive to work out.

Judge them over an interval rather than the cumulative totals. The baseline to monitor is the average wait per call; a steady average with a rising count is a caller problem, and a rising average is an AD latency problem.


Common Causes

  • Security audit scripts or monitoring that run xp_logininfo against every Windows group, on a schedule.
  • Application code that checks group membership on every request instead of caching the answer.
  • Domain controllers that are slow, overloaded or in another site, which stretches every call.
  • Deeply nested groups on SQL-facing accounts.

The Check To Run

Rank them against everything else with Get Wait Statistics, then read the directory waits side by side, with the average per call:

SELECT
    wait_type,
    waiting_tasks_count,
    wait_time_ms,
    CAST(wait_time_ms * 1.0 / NULLIF(waiting_tasks_count, 0) AS DECIMAL(12, 2)) AS avg_wait_ms,
    max_wait_time_ms
FROM sys.dm_os_wait_stats
WHERE wait_type IN (
    N'PREEMPTIVE_OS_NETGROUPGETUSERS', N'PREEMPTIVE_OS_NETLOCALGROUPGETMEMBERS',
    N'PREEMPTIVE_OS_NETUSERGETGROUPS', N'PREEMPTIVE_OS_NETUSERGETLOCALGROUPS',
    N'PREEMPTIVE_OS_NETUSERMODALSGET', N'PREEMPTIVE_OS_DOMAINSERVICESOPS',
    N'PREEMPTIVE_OS_DIRSVC_NETWORKOPS', N'PREEMPTIVE_OS_AUTHENTICATIONOPS',
    N'PREEMPTIVE_OS_LOOKUPACCOUNTSID', N'PREEMPTIVE_OS_DSGETDCNAME')
ORDER BY wait_time_ms DESC;

A high waiting_tasks_count with a small average points at a caller. A high average points at the domain controllers. While it is happening, sys.dm_exec_requests shows the session that is in the call, and its login and program name usually identify the job or application:

SELECT
    r.session_id,
    r.wait_type,
    r.wait_time AS wait_ms,
    s.login_name,
    s.program_name,
    t.text AS running_sql
FROM sys.dm_exec_requests AS r
JOIN sys.dm_exec_sessions AS s ON s.session_id = r.session_id
OUTER APPLY sys.dm_exec_sql_text(r.sql_handle) AS t
WHERE r.wait_type LIKE N'PREEMPTIVE_OS_%'
ORDER BY r.wait_time DESC;

Both need VIEW SERVER STATE.


What To Do

  1. Find the frequent callers, such as audit jobs or applications doing a membership check per request, and have them cache the result or run less often.
  2. For a rising average, take the numbers to whoever runs Active Directory: which domain controller the server uses, and the average time per call from the check above.
  3. Keep group nesting simple for the groups that hold SQL Server logins; every extra level is more work for each lookup.

The PREEMPTIVE_OS Security and Directory Waits

Each of these is SQL Server calling out to Windows for authentication or directory work, and many of those calls go to a domain controller. They tend to rise together when AD is slow. If one is near the top of your waits, read it next to the waits that usually matter.

  • PREEMPTIVE_OS_AUTHENTICATIONOPSAuthentication. Windows security calls made while authenticating logins and building tokens.Worth a look when it climbs
  • Group Lookup waitsGroup membership. NETGROUPGETUSERS, NETUSERGETGROUPS and the other calls that ask Windows who belongs to which group.Worth a look when it climbs. This page.
  • PREEMPTIVE_OS_LOOKUPACCOUNTSIDSID to name. Translating a security identifier into an account name, often via a domain controller.Worth a look when it climbs
  • PREEMPTIVE_OS_DSGETDCNAMEFinding a DC. Locating a domain controller before the directory question can be asked.Worth a look when it climbs
  • PREEMPTIVE_OS_LOGONUSERLogon as a stored identity. The Windows LogonUser call, used when SQL Server must log on with a stored Windows credential.Worth a look when it climbs
  • Security waitsOther security APIs. The AUTHZ and security context calls that do not have a page of their own.Worth a look when it climbs
  • Crypto waitsCryptography. Windows crypto API calls, for certificates, keys and TLS.Usually noise

Where To Go Next

If these directory waits are sitting near the top of your wait stats, these are the next places to look.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *