How to fix Error 5851 on Windows Server 2025 / Windows 11

Troubleshooting Guide: SQL Server Error 5851 – AccessCheckResult Quota Violation

Why This Error Happens

Error 5851 occurs when SQL Server’s internal security cache (used to validate repeated access check results) becomes misaligned, typically because the configured memory quota for the AccessCheckResult cache is smaller than the number of buckets allocated for it. This usually stems from a corrupted Resource Governor configuration, an improperly applied memory-related trace flag, or a plan cache/security cache inconsistency following an in-place upgrade to SQL Server 2025. In most cases, this is triggered after manual registry edits, aggressive memory-constrained configurations, or a botched failover cluster resource update on Windows Server 2025.

Step-by-Step Resolution Guide

Step 1: Verify Current Memory and Cache Configuration

  • Open SQL Server Management Studio (SSMS) and run DBCC MEMORYSTATUS to inspect the “Access Check Result Cache” section.
  • Check for a mismatch between “Buckets” and “Quota” values in the output.
  • Review sys.dm_os_memory_cache_counters to confirm abnormal entries for CACHESTORE_XPROC or USERSTORE_TOKENPERM.

Step 2: Clear and Rebuild the Security Cache

  • Run the following command to flush the stale cache entries:
  DBCC FREESYSTEMCACHE('TokenAndPermUserStore')
  • If the issue persists, restart the SQL Server service to force a full cache reinitialization:
  Restart-Service -Name 'MSSQLSERVER' -Force
  • Confirm no linked processes (SSRS, SSAS) are holding open connections that could repopulate corrupted cache data.

Step 3: Audit and Reset Resource Governor Settings

  • Navigate to Management > Resource Governor in SSMS.
  • Run ALTER RESOURCE GOVERNOR RESET STATISTICS; to clear any invalid pool-to-quota mappings.
  • If a custom resource pool was recently modified, revert it using:
  ALTER RESOURCE POOL [default] WITH (MAX_MEMORY_PERCENT = 100);
  ALTER RESOURCE GOVERNOR RECONFIGURE;

Step 4: Validate Windows Server Memory Allocation Policies

  • Open Local Group Policy Editor (gpedit.msc) on Windows Server 2025 and check Computer Configuration > Administrative Templates > System > Memory Allocation for any conflicting “Lock Pages in Memory” settings tied to the SQL Server service account.
  • Ensure the SQL Server service account has the Lock Pages in Memory and Perform Volume Maintenance Tasks rights properly assigned via secpol.msc.
  • Reboot the server if policy changes were applied, as SQL Server caches security tokens at startup.

Step 5: Apply the Latest Cumulative Update (CU)

  • Check your current build number using:
  SELECT @@VERSION;
  • Compare against the latest SQL Server 2025 Cumulative Update release notes from Microsoft’s official Servicing page.
  • Download and install the latest CU, as this specific quota-vs-bucket mismatch is addressed in several hotfixes related to the security cache subsystem.

Alternative or Verification Steps

  • After applying fixes, re-run DBCC MEMORYSTATUS and confirm the “Quota” value is now equal to or greater than “Buckets” under the AccessCheckResult section with no Error 5851 in the SQL Server Error Log.
  • If the error persists after a CU update, as a temporary workaround, enable Trace Flag 174 at startup (-T174) to increase the token/permission cache size ceiling until a permanent configuration fix is validated.