PREEMPTIVE_OS_PIPEOPS Wait Type in SQL Server

PREEMPTIVE_OS_PIPEOPS is recorded when a thread calls out to Windows functions that work with pipes, and in DBA reality that means one thing almost every time: xp_cmdshell. SQL Server launches the external command and reads its output through a pipe; the entire runtime of that command accumulates under this wait.

The PREEMPTIVE_ prefix means the thread has left SQL Server’s cooperative scheduling and is under Windows’ control, so its state shows as RUNNING even while it just waits for the external process.

Is It a Problem?

The wait mechanics are not; the wait is exactly as long as whatever the shelled-out command takes. The questions it raises are operational. Large amounts of this wait mean significant work is being done through xp_cmdshell, which occupies a SQL Server worker thread for the duration, serialises anything waiting on that command, and is a standing security review item besides.

A slow shelled command inside a stored procedure makes the whole procedure slow, and the wait profile will show you exactly that.

Common Causes

  • xp_cmdshell calls running file operations, robocopy jobs, legacy batch integrations, or certificate and BCP tooling.
  • Long-running or hung external commands, a hung network copy shows up as one enormous wait.
  • Agent job steps or procedures that shell out in a loop, once per file or per row.

What To Do

  1. Find the callers: sys.dm_exec_requests filtered to this wait type shows the sessions and their SQL text live.
  2. Ask whether the shell-out should exist. Most xp_cmdshell usage predates better options: Agent CmdExec/PowerShell steps, external ETL tooling, or application-side code all avoid burning SQL worker threads.
  3. If it must stay, make the external command fast and bounded: timeouts, error handling, and no per-row loops.
  4. Review the security posture: xp_cmdshell enabled means the SQL Server service account’s OS rights are reachable from T-SQL. Our security surface-area check flags it for that reason.

How To See It

Rank it against everything else with Get-WaitStatistics. Sustained high values are an inventory of your shell-out habits; trace them and modernise the worst ones.


Part of the SQL Server Wait Types Library.
Related deep dive: SOS_SCHEDULER_YIELD Wait Type.

Comments

Leave a Reply

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