過去1年間、次のエラー(または別のリソースガバナーグループのバリエーション)で多くの異なるクエリが同時に失敗するという状況に悩まされています。これを実行するには、リソースプールの「デフォルト」にシステムメモリが不足していますクエリ。
最近、私たちはそれをますます頻繁に遭遇しています。問題の原因と解決方法に関するアイデアはありますか?
@@ versionは次を返します:
Microsoft SQL Server 2012(SP3)(KB3072779)-11.0.6020.0(X64)2015年10月20日15:36:27 Copyright(c)Microsoft Corporation Enterprise Edition:Core-based Licensing(64-bit)on Windows NT 6.1(Build 7601 :サービスパック1)
まったく同時に発生するエラーの例:
Error: 701, Severity: 17, State: 54.
There is insufficient system memory in resource pool 'default' to run this query.
Error: 701, Severity: 17, State: 123.
There is insufficient system memory in resource pool 'dm' to run this query.
Error: 701, Severity: 17, State: 89.
There is insufficient system memory in resource pool 'default' to run this query.
Error: 701, Severity: 17, State: 123.
There is insufficient system memory in resource pool 'default' to run this query.
Error: 701, Severity: 17, State: 123.
There is insufficient system memory in resource pool 'default' to run this query.
Error: 701, Severity: 17, State: 123.
There is insufficient system memory in resource pool 'dm' to run this query.
Error: 701, Severity: 17, State: 123.
ログのメモリ値:
Buffer Pool Value
---------------------------------------- ----------
Database 8489253
Simulated 1367796
Target 9508783
Dirty 868368
In IO 1744
Latched 6720
Page Life Expectancy 12
Procedure Cache Value
---------------------------------------- ----------
TotalProcs 435
TotalPages 22156
InUsePages 9414
Global Memory Objects Pages
---------------------------------------- ----------
Resource 5696
Locks 497346
XDES 3161
DirtyPageTracking 32
SETLS 32
SubpDesc Allocators 68
SE SchemaManager 2481
SE Column Metadata Cache 6414
SE Column Metadata Cache Store 6
SQLCache 442
Replication 2
ServerGlobal 72
XP Global 2
SortTables 3
Query Memory Objects (internal) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 492067
Current Max 492067
Future Max 492067
Physical Max 16549102
Next Request 0
Waiting For 0
Cost 0
Timeout 0
Wait Time 0
Small Query Memory Objects (internal) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 25898
Current Max 25898
Future Max 25898
Remote Query Memory Objects (internal) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 8274551
Current Max 8274551
Query Memory Objects (default) Value
---------------------------------------- ----------
Grants 22
Waiting 2
Available 0
Current Max 14706463
Future Max 13657740
Physical Max 15954870
Next Request 482
Waiting For 723
Cost 6
Timeout 157
Wait Time 484
Small Query Memory Objects (default) Value
---------------------------------------- ----------
Grants 3
Waiting 0
Available 122428
Current Max 122880
Future Max 122880
Remote Query Memory Objects (default) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 7977435
Current Max 7977435
Query Memory Objects (fm) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 49206
Current Max 49206
Future Max 49206
Physical Max 1654911
Next Request 0
Waiting For 0
Cost 0
Timeout 0
Wait Time 0
Small Query Memory Objects (fm) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 2589
Current Max 2589
Future Max 2589
Remote Query Memory Objects (fm) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 827455
Current Max 827455
Query Memory Objects (dm) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 477304
Current Max 477304
Future Max 477304
Physical Max 16052629
Next Request 0
Waiting For 0
Cost 0
Timeout 0
Wait Time 0
Small Query Memory Objects (dm) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 25121
Current Max 25121
Future Max 25121
Remote Query Memory Objects (dm) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 8026314
Current Max 8026314
Query Memory Objects (J) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 477304
Current Max 477304
Future Max 477304
Physical Max 16052629
Next Request 0
Waiting For 0
Cost 0
Timeout 0
Wait Time 0
Small Query Memory Objects (J) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 25121
Current Max 25121
Future Max 25121
Remote Query Memory Objects (J) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 8026314
Current Max 8026314
Query Memory Objects (c) Value
---------------------------------------- ----------
Grants 2
Waiting 0
Available 0
Current Max 303105
Future Max 269810
Physical Max 1643300
Next Request 0
Waiting For 0
Cost 0
Timeout 0
Wait Time 0
Small Query Memory Objects (c) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 14200
Current Max 14200
Future Max 14200
Remote Query Memory Objects (c) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 821650
Current Max 821650
Query Memory Objects (d8) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 472388
Current Max 472388
Future Max 472388
Physical Max 15887138
Next Request 0
Waiting For 0
Cost 0
Timeout 0
Wait Time 0
Small Query Memory Objects (d8) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 24862
Current Max 24862
Future Max 24862
Remote Query Memory Objects (d8) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 7943569
Current Max 7943569
Query Memory Objects (d4) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 472388
Current Max 472388
Future Max 472388
Physical Max 15887138
Next Request 0
Waiting For 0
Cost 0
Timeout 0
Wait Time 0
Small Query Memory Objects (d4) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 24862
Current Max 24862
Future Max 24862
Remote Query Memory Objects (d4) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 7943569
Current Max 7943569
Query Memory Objects (b) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 49206
Current Max 49206
Future Max 49206
Physical Max 1654911
Next Request 0
Waiting For 0
Cost 0
Timeout 0
Wait Time 0
Small Query Memory Objects (b) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 2589
Current Max 2589
Future Max 2589
Remote Query Memory Objects (b) Value
---------------------------------------- ----------
Grants 0
Waiting 0
Available 827455
Current Max 827455
Optimization Queue (internal) Value
---------------------------------------- ----------
Overall Memory 144834560000
Target Memory 4526080000
Last Notification 0
Timeout 6
Early Termination Factor 5
Small Gateway (internal) Value
---------------------------------------- ----------
Configured Units 128
Available Units 128
Acquires 0
Waiters 0
Threshold Factor 380000
Threshold 380000
Medium Gateway (internal) Value
---------------------------------------- ----------
Configured Units 32
Available Units 32
Acquires 0
Waiters 0
Threshold Factor 12
Threshold -1
Big Gateway (internal) Value
---------------------------------------- ----------
Configured Units 1
Available Units 1
Acquires 0
Waiters 0
Threshold Factor 8
Threshold -1
Optimization Queue (default) Value
---------------------------------------- ----------
Overall Memory 140489523200
Target Memory 4390297600
Last Notification 0
Timeout 6
Early Termination Factor 5
Small Gateway (default) Value
---------------------------------------- ----------
Configured Units 128
Available Units 124
Acquires 4
Waiters 0
Threshold Factor 380000
Threshold 380000
Medium Gateway (default) Value
---------------------------------------- ----------
Configured Units 32
Available Units 32
Acquires 0
Waiters 0
Threshold Factor 12
Threshold 91464533
Big Gateway (default) Value
---------------------------------------- ----------
Configured Units 1
Available Units 1
Acquires 0
Waiters 0
Threshold Factor 8
Threshold -1
Optimization Queue (fm) Value
---------------------------------------- ----------
Overall Memory 14483456000
Target Memory 452608000
Last Notification 0
Timeout 6
Early Termination Factor 5
Small Gateway (fm) Value
---------------------------------------- ----------
Configured Units 128
Available Units 128
Acquires 0
Waiters 0
Threshold Factor 380000
Threshold 380000
Medium Gateway (fm) Value
---------------------------------------- ----------
Configured Units 32
Available Units 32
Acquires 0
Waiters 0
Threshold Factor 12
Threshold -1
Big Gateway (fm) Value
---------------------------------------- ----------
Configured Units 1
Available Units 1
Acquires 0
Waiters 0
Threshold Factor 8
Threshold -1
Optimization Queue (dm) Value
---------------------------------------- ----------
Overall Memory 140489523200
Target Memory 4390297600
Last Notification 0
Timeout 6
Early Termination Factor 5
Small Gateway (dm) Value
---------------------------------------- ----------
Configured Units 128
Available Units 128
Acquires 0
Waiters 0
Threshold Factor 380000
Threshold 380000
Medium Gateway (dm) Value
---------------------------------------- ----------
Configured Units 32
Available Units 32
Acquires 0
Waiters 0
Threshold Factor 12
Threshold -1
Big Gateway (dm) Value
---------------------------------------- ----------
Configured Units 1
Available Units 1
Acquires 0
Waiters 0
Threshold Factor 8
Threshold -1
Optimization Queue (J) Value
---------------------------------------- ----------
Overall Memory 140489523200
Target Memory 4390297600
Last Notification 0
Timeout 6
Early Termination Factor 5
Small Gateway (J) Value
---------------------------------------- ----------
Configured Units 128
Available Units 128
Acquires 0
Waiters 0
Threshold Factor 380000
Threshold 380000
Medium Gateway (J) Value
---------------------------------------- ----------
Configured Units 32
Available Units 32
Acquires 0
Waiters 0
Threshold Factor 12
Threshold -1
文字制限のため、ここに全文: http://Pastebin.com/WCAtRBdP
あなたが投稿した出力から私は見ることができます
MEMORYCLERK_SQLQERESERVATIONS 39874 (MB)
値は38Gと巨大です。 SQL Serverの操作(ソートおよびハッシュ)が大量のメモリを要求する理由
SQLRESERVATIONSとは
クエリの実行中に並べ替え操作とハッシュ操作に割り当てられるSQL Serverメモリ。 38 Gがソートとハッシュ操作に必要なものだと本当に思いますか。これが問題です。
リソースガバナー構成を確認する
CREATE WORKLOAD GROUP [fm] WITH(GROUP_MAX_REQUESTS=0,
IMPORTANCE=HIGH,
REQUEST_MAX_CPU_TIME_SEC=0,
REQUEST_MAX_MEMORY_GRANT_PERCENT=100,
REQUEST_MEMORY_GRANT_TIMEOUT_SEC=0,
MAX_DOP=8) USING [fm]
GO
REQUEST_MAX_MEMORY_GRANT_PERCENT = 100を見るだけで、これは私には非常に間違った構成のようです。 BOLドキュメント によると
REQUEST_MAX_MEMORY_GRANT_PERCENT = value単一の要求がプールから取得できるメモリの最大量を指定します。このパーセンテージは、MAX_MEMORY_PERCENTで指定されたリソースプールサイズに関連しています
つまり、このワークロードでクエリが実行されると、他のユーザーにメモリを枯渇させることで、その実行のためのメモリ許可としてほぼALL
メモリを要求できます。そして、これは間違いなくOOMエラーを引き起こす可能性があります。
さらにマイクロソフトが言うことは
他の同時クエリが実行されている場合、サーバーは十分な空きメモリを確保できない可能性があるため、70より大きい値を設定することはお勧めしません。これにより、クエリのタイムアウトエラー8645が発生する可能性があります
の出力も共有できますか
select total_request_count,blocked_task_count,max_request_grant_memory_kb,requested
from sys.dm_resource_governor_workload_groups
SELECT mg.granted_memory_kb, mg.session_id, t.text, qp.query_plan
FROM sys.dm_exec_query_memory_grants AS mg
CROSS APPLY sys.dm_exec_sql_text(mg.sql_handle) AS t
CROSS APPLY sys.dm_exec_query_plan(mg.plan_handle) AS qp
ORDER BY 1 DESC OPTION (MAXDOP 1)
USE master
GO
;WITH cte
AS ( SELECT RP.pool_id ,
RP.Name ,
RP.min_memory_percent ,
RP.max_memory_percent ,
CAST (RP.max_memory_kb / 1024. / 1024.
AS NUMERIC(12, 2)) AS max_memory_gb ,
CAST (RP.used_memory_kb / 1024. / 1024.
AS NUMERIC(12, 2)) AS used_memory_gb ,
CAST (RP.target_memory_kb / 1024. / 1024.
AS NUMERIC(12,2)) AS target_memory_gb,
CAST (SI.committed_target_kb / 1024. / 1024.
AS NUMERIC(12, 2)) AS committed_target_kb
FROM sys.dm_resource_governor_resource_pools RP
CROSS JOIN sys.dm_os_sys_info SI
)
SELECT c.pool_id ,
c.Name ,
c.min_memory_percent ,
c.max_memory_percent ,
c.max_memory_gb ,
c.used_memory_gb ,
c.target_memory_gb ,
CAST(c.committed_target_kb *
CASE WHEN c.committed_target_kb <= 8 THEN 0.7
WHEN c.committed_target_kb < 16 THEN 0.75
WHEN c.committed_target_kb < 32 THEN 0.8
WHEN c.committed_target_kb <= 96 THEN 0.85
WHEN c.committed_target_kb > 96 THEN 0.9
END * c.max_memory_percent /100 AS NUMERIC(12,2))
AS [Max_for_InMemory_Objects_gb]
FROM cte c
編集:
投稿した出力から
total_request_count blocked_task_count max_request_grant_memory_kb
-------------------- ------------------ ---------------------------
553 0 18000
1633564 0 19344744
0 0 0
89509 0 23448232
2073 0 8032
24999 0 4485384
861807 0 3149248
236419 0 32241240
293 0 32241240
1735195 0 1889544
これで、ワークグループが処理する非常に多くのリクエストがあることがわかり、19Gから32Gまでのすべての範囲を要求したメモリの量を確認できます。これは、大量のメモリ許可を要求するクエリがメモリから他のメモリを奪い、メモリを記録することが問題になる可能性がありますワークグループは共有されません。
あなたも見ることができます
granted_memory_kb session_id
-------------------- ----------
19344744 210
セッションID 210には19Gのメモリが付与されています。これは失敗です。このようなクエリが5〜10個実行された場合のシナリオを検討してください。
の出力も追加できますか
select pool_id,cache_memory_kb,used_memory_kb,out_of_memory_count,used_memgrant_kb from sys.dm_resource_governor_resource_pools
列ストアインデックスの最初の実装である2012を使用しています。さらに分析を行ったところ、列ストアインデックスが作成されていて、サーバーにメモリの負荷がかかっていると、クラッシュが常に発生することがわかりました。これらの列ストアインデックスが削除され、エラーは発生しなくなりました。