Question & Answer
Question
ロック待機中に、特定のアプリケーションが SQL0952N やSQL30081N (selectForRecvTimeout) または -4499 (Read timeout) を返すことがあります。 これはなぜでしょう?
Cause
ロック・タイムアウト時間より短い照会タイムアウトや通信タイムアウトを設定すると、ロック・タイムアウト (SQL0911N rc=68) でなく、照会タイムアウト (SQL0952N) や通信タイムアウト (SQL30081N selectForRecvTimeout もしくは -4499 Read timeout) が返ります。
Answer
ロック・タイムアウト時間より短い照会タイムアウトや通信タイム後を設定すると、ロック・タイムアウトが返らないのは期待される結果です。
以下の手順は、どのように照会タイムアウトや通信タイムアウトが発生するかを例示しています。
locktimeout - ロック・タイムアウト構成パラメーター
DB2Jcc - IBM Data Server Driver for JDBC and SQLJ の診断ユーティリティー
サポートされるすべてのデータベース製品に共通の IBM Data Server Driver for JDBC and SQLJ のプロパティー
通信変数
[Db2] SQL0952N の原因と対処方法
[Db2] Db2 クライアントの通信タイムアウトを設定する方法
お問合せ先
技術的な内容に関して、パスポート・アドバンテージの契約のもと Db2 テクニカル・サポートへお問い合わせください。
Db2 テクニカル・サポート
以下の手順は、どのように照会タイムアウトや通信タイムアウトが発生するかを例示しています。
- SAMPLE データベースの LOCKTIMEOUT を 20 秒に設定します。
$ db2 get db cfg for sample | grep LOCK Lock timeout (sec) (LOCKTIMEOUT) = 20
- コマンド行プロセッサー (CLP) から ORG 表を排他モードでロックします。
$ db2 connect to sample $ db2 +c lock table org in exclusive mode
- Db2 に付属の JDBC テスト・プログラムから ORG 表を照会します。これはロック・タイムアウト (SQL0911N rc=68) が返ります。
$ java com.ibm.db2.jcc.DB2Jcc -url "jdbc:db2://localhost:50000/SAMPLE" -user db2inst1 -password passw0rd -sql \'select deptname from org\' [jcc][10521][13706]Command : java com.ibm.db2.jcc.DB2Jcc -url jdbc:db2://localhost:50000/SAMPLE -user db2inst1 -password ******** -sql 'select deptname from org' [jcc][10516][13709]Test Connection Successful. [jcc][10515][13711]Execution of SQL failed with error code -911. Exception: com.ibm.db2.jcc.am.SqlTransactionRollbackException: DB2 SQL Error: SQLCODE=-911, SQLSTATE=40001, SQLERRMC=68, DRIVER=3.69.24
- 同じプログラムをロック・タイムアウト (20秒) より短い照会タイムアウト (commandTimeout 10 秒) を指定して実行します。今度は照会タイムアウト (SQL0952N) が返ります。
$ java com.ibm.db2.jcc.DB2Jcc -url "jdbc:db2://localhost:50000/SAMPLE:commandTimeout=10;" -user db2inst1 -password passw0rd -sql \'select deptname from org\' [jcc][10521][13706]Command : java com.ibm.db2.jcc.DB2Jcc -url jdbc:db2://localhost:50000/SAMPLE:commandTimeout=10; -user db2inst1 -password ******** -sql 'select deptname from org' [jcc][10516][13709]Test Connection Successful. [jcc][10515][13711]Execution of SQL failed with error code -952. Exception: com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-952, SQLSTATE=57014, SQLERRMC=null, DRIVER=3.69.24
- 同じプログラムをロック・タイムアウト (20秒) より短い通信タイムアウト (blockingReadConnectionTimeout 10秒) を指定して実行します。これは通信タイムアウト (-4499 Read timed out) が返ります。
$ java com.ibm.db2.jcc.DB2Jcc -url "jdbc:db2://localhost:50000/SAMPLE:blockingReadConnectionTimeout=10;" -user db2inst1 -password passw0rd -sql \'select deptname from org\' [jcc][10521][13706]Command : java com.ibm.db2.jcc.DB2Jcc -url jdbc:db2://localhost:50000/SAMPLE:blockingReadConnectionTimeout=10; -user db2inst1 -password ******** -sql 'select deptname from org' [jcc][10516][13709]Test Connection Successful. [jcc][10515][13711]Execution of SQL failed with error code -4,499. Exception: com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2030][11211][3.69.24] A communication error occurred during operations on the connection's underlying socket, socket input stream, or socket output stream. Error location: Reply.fill() - socketInputStream.read (-1). Message: Read timed out. ERRORCODE=-4499, SQLSTATE=08001
例$ db2set DB2TCP_CLIENT_RCVTIMEOUT=10 $ db2 terminate $ db2 connect to SAMPLE user db2inst1 using passw0rd Database Connection Information Database server = DB2/AIX64 10.5.8 SQL authorization ID = DB2INST1 Local database alias = SAMPLE $ db2 "select * from org" SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "192.168.100.123". Communication function detecting the error: "selectForRecvTimeout". Protocol specific error code(s): "0", "*", "*". SQLSTATE=08001
関連情報
[Db2] パスポート・アドバンテージによく寄せられる質問locktimeout - ロック・タイムアウト構成パラメーター
DB2Jcc - IBM Data Server Driver for JDBC and SQLJ の診断ユーティリティー
サポートされるすべてのデータベース製品に共通の IBM Data Server Driver for JDBC and SQLJ のプロパティー
通信変数
[Db2] SQL0952N の原因と対処方法
[Db2] Db2 クライアントの通信タイムアウトを設定する方法
お問合せ先
技術的な内容に関して、パスポート・アドバンテージの契約のもと Db2 テクニカル・サポートへお問い合わせください。
Db2 テクニカル・サポート
[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"ARM Category":[{"code":"a8m500000008PkdAAE","label":"Connectivity"},{"code":"a8m500000008PmMAAU","label":"Performance-\u003ELocks"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]
Was this topic helpful?
Document Information
Modified date:
26 August 2023
UID
swg22010930