SQL Serverログオン不可が頻発(Error: 17189, Severity: 16, State: 1.)

悠 高島 81 Reputation points
2020-09-01T01:21:10.083+00:00

【環境】
Microsoft Windows Server 2012 R2 Standard

DBサーバーに対しSQL Serverの最大サーバメモリは、4096(MB)を設定しております。
---systeminfo---
物理メモリの合計: 8,191 MB
利用できる物理メモリ: 1,168 MB
仮想メモリ: 最大サイズ: 13,162 MB
仮想メモリ: 利用可能: 3,419 MB
仮想メモリ: 使用中: 9,743 MB


【質問内容】
データベースアクセス時にDBコネクションが確立できないことが頻発しています。

利用しているAPIはSQLConnectです。

sql_rtn = SQLConnect (edp->hdbc,
                  (SQLTCHAR *) dsn, (SQLSMALLINT) strlen(dsn),
                  (SQLTCHAR *) user, (SQLSMALLINT) strlen(user),
                  (SQLTCHAR *) pass, (SQLSMALLINT)strlen(pass));

4/20-8/21間事象が16回発生しております。頻度は大体1週間に1~2回発生していま
すが、間隔は不定期で2日連続で発生することもあります。

ODBCコネクション確立できない場合出力エラーログ:

Function=[SQLConnect] Code=[SQL_ERROR] Nativ=[26] Status=[08001] msg=[Microsoft][ODBC Driver 11 for SQL Server]Client unable to establish connection because an error was encountered during handshakes before login. Common causes include client attempting to connect to an unsupported version of SQL Server, server too busy to accept new connections or a resource limitation (memory or maximum allowed connections) on the server.
Function=[SQLConnect] Code=[SQL_ERROR] Nativ=[233] Status=[08001] msg=[Microsoft][ODBC Driver 11 for SQL Server]Shared Memory Provider: パイプの他端にプロセスがありません。
Function=[SQLConnect] Code=[SQL_ERROR] Nativ=[26] Status=[08001] msg=[Microsoft][ODBC Driver 11 for SQL Server]Client unable to establish connection
Function=[SQLConnect] Code=[SQL_ERROR] Nativ=[233] Status=[08001] msg=[Microsoft][ODBC Driver 11 for SQL Server]Client unable to establish connection due to prelogin failure


事象が発生する際のSqlserverのイベントログに下記のエラーが出力されています。
---アプリケーションログ---
エラー 2020/08/12 19:10:13 MSSQLSERVER 17189 ログオン SQL Server は、新しいログインまたは接続を処理するスレッドを起動できませんでした (エラー コード 0xc0000000)。関連する可能性のある問題の情報については、SQL Server エラー ログと Windows イベント ログを確認してください。 [クライアント: <local machine>]


SQL SERVERのエラーログはイベントログに出力されるていることと同じようです。

2020-08-12 19:10:13.36 Logon エラー: 17189、重大度: 16、状態: 1。
2020-08-12 19:10:13.36 Logon SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems. [クライアント: <local machine>]


事象が発生に関する原因と、回避策、根本原因の調査方法をお教えください。

以上、よろしくお願いいたします。

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,895 questions
0 comments No comments
{count} votes

Accepted answer
  1. NOBTA 86 Reputation points
    2020-09-01T08:53:26.72+00:00

    エラー 17189 は、SQL Server が新規接続を処理するためのスレッドが作成できなかった場合に発生しうるエラーであり、一般的に スレッド数が SQL Server の上限に達した場合、SQL Server で利用可能なメモリが不足している場合に、発生する可能性があるエラーだと思います。
    ほかの方からのアドバイスにもありますが、max server memory を増やし、エラー 17189 が解消するかを確認してみると良いかもしれません。
    なお、本現象の対処方法として、SQL Server サービスを再起動されておりますでしょうか?
    また、アプリケーション側の実装として、SQL Server へ確立したセッションを処理完了後にクローズしておりますでしょうか?
    上記が正しく処理できていない場合、類似の現象が発生する可能性があるので、動的管理ビュー [sys.dm_exec_connections] でユーザーセッションが増加していないかなどについても確認してみると良いかもしれません。

    dm_exec_connections (Transact-sql)
    https://learn.microsoft.com/ja-jp/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-connections-transact-sql?view=sql-server-ver15

    ---
    2020-08-12 19:10:13.36 Logon エラー: 17189、重大度: 16、状態: 1。
    2020-08-12 19:10:13.36 Logon SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems. [クライアント: <local machine>]
    ---

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. m 4,271 Reputation points
    2020-09-01T04:04:50.377+00:00

    My Reply:

    Hi @悠 高島 ,

    You need to change the max server memory to 6G, and then increase the max worker thread.
    Actually the best memory configuration for SQL is that there is only SQL on this server, and then the memory of the server is reduced by the memory required by the OS, and the rest is all for SQL

    I. Increase SQL max server memory
    max server memory: 6G

    II. Increase max worker thread
    T_SQL:
    sp_configure 'show advanced options',1
    reconfigure with override
    go
    sp_configure 'max worker thread',2048
    reconfigure with override
    go

    More information:
    Troubleshooting 17189,
    server-memory-server-configuration-options,
    configure-the-max-worker-threads-server-configuration-option

    If the reply is helped, please do “Accept Answer”.
    BR,
    Mia


  2. 悠 高島 81 Reputation points
    2020-09-02T00:49:52.437+00:00

    Hello.

    Thank you for your answer.It's very helpful.

    Sorry I doubled down on my post.

    Please refer to this URL.

    https://learn.microsoft.com/en-us/answers/questions/82659/sql-server-logon-failure-occurs-frequently-error-1.html

    I'm currently checking the log in reference to your opinion.

    Thank you.
    ------
    投稿してくださったみなさん、ありがとうございます。
    あやまって同じ投稿を二重にしてしまいましたので、以後はそちらをご参照ください。

    https://learn.microsoft.com/en-us/answers/questions/82659/sql-server-logon-failure-occurs-frequently-error-1.html

    以上、よろしくお願いします。

    0 comments No comments