DB2 REORG command is not able to start - db2

I am trying to reorg a table in DB2 as the number of alters on a table has exceeded more than 3 times.
DB2 CALL SYSPROC.ADMIN_CMD('REORG TABLE WASADMIN.EXCHANGERATES');
It is not giving any response and looks like it is hanged . I checked the status by running the command .
db2pd -db UB602 -reorgs
but there is no active Reorg process .
Database Member 0 -- Database UB602 -- Active -- Up 0 days 02:14:45 -- Date 2018-11-26-19.34.15.256000
Table Reorg Information:
Address TbspaceID TableID PartID MasterTbs MasterTab TableName Type IndexID TempSpaceID
Table Reorg Stats:
Address TableName Start End PhaseStart MaxPhase Phase CurCount MaxCount Status Completion
What could have gone wrong?
Edit:
I checked the logs but nothing is printed. but when I am pressing ctrl+c to terminate . I get some message in the logs .
2018-11-26-20.19.53.459000+330 I1F1191 LEVEL: Event
PID : 5176 TID : 4928 PROC : db2syscs.exe
INSTANCE: DB2_01 NODE : 000 DB : UB602
APPHDL : 0-1186 APPID: *LOCAL.DB2_01.181126124159
AUTHID : DB2ADMIN HOSTNAME: BLR2DEVLP0434
EDUID : 4928 EDUNAME: db2agent (UB602) 0
FUNCTION: DB2 UDB, RAS/PD component, pdLogInternal, probe:120
START : New Diagnostic Log file
DATA #1 : Build Level, 232 bytes
Instance "DB2_01" uses "64" bits and DB2 code release "SQL11010"
with level identifier "0201010F".
Informational tokens are "DB2 v11.1.0.1527", "s1606081100", "DYN1606081100WIN64", Fix Pack "0".
DATA #2 : System Info, 1760 bytes
System: WIN32_NT BLR2DEVLP0434 10.0 AMD64 Family 6, model 78, stepping 3
CPU: total:4 online:4 Cores per socket:2 Threading degree per core:2 SIMD:Y
CPU binding: not in use
Physical Memory(MB): total:16049 free:6448 available:6448
Virtual Memory(MB): total:28849 free:19248
Swap Memory(MB): total:12800 free:12800
Information in this record is only valid at the time when this file was
created (see this record's time stamp)
2018-11-26-20.19.53.469000+330 I1195F968 LEVEL: Info
PID : 5176 TID : 4928 PROC : db2syscs.exe
INSTANCE: DB2_01 NODE : 000 DB : UB602
APPHDL : 0-1186 APPID: *LOCAL.DB2_01.181126124159
AUTHID : DB2ADMIN HOSTNAME: BLR2DEVLP0434
EDUID : 4928 EDUNAME: db2agent (UB602) 0
FUNCTION: DB2 UDB, relation data serv, sqlrr_rds_common_post, probe:1700
MESSAGE : Severe TERMINATE err at nest lvl 1, in SQL from rtn SYSPROC.ADMIN_CMD
DATA #1 : SQLCA, PD_DB2_TYPE_SQLCA, 136 bytes
sqlcaid : SQLCA sqlcabc: 136 sqlcode: -952 sqlerrml: 0
sqlerrmc:
sqlerrp : SQLRL04B
sqlerrd : (1) 0x80100003 (2) 0x00000003 (3) 0x00000000
(4) 0x00000000 (5) 0x00000000 (6) 0x00000000
sqlwarn : (1) (2) (3) (4) (5) (6)
(7) (8) (9) (10) (11)
sqlstate: 57014

To perform an offline reorg, you have to ensure that nothing is using the table before the reorg command starts to run.
If an offline reorg is not possible, check if an inplace reorg can work instead.
If there are other reasons preventing the action, consult the db2diag.log file for more details. In your question it shows only sqlcode -952 which tells us that you cancelled the job with the control-C.
You can check if there are any row-locks or table-locks on the target table by using one of many different methods. You can use dsmtop or db2top, or dsm, or a command line (db2 get snapshot for locks and then parsing the output for your table name), or by using the MON_GET_LOCKS table function or equivalents.
The documentation states "
Be sure to complete all database operations and release all locks
before you invoke REORG TABLE. This step can be done by issuing a
COMMIT after you close all cursors opened WITH HOLD, or by issuing a
ROLLBACK. After you reorganize a table, use RUNSTATS to update the
table statistics, and REBIND to rebind the packages that use this
table. The reorganize utility implicitly closes all the cursors. "

Related

SQLSTATE=23514 : Facing error on Set integrity

Can someone suggest me what is the problem, why I am not able to enable integrity, although no constraint found with name of CATEGORY.
create function FCOK_ACCOUNT_CATEGORY_C2(xmlrecord XML) returns integer language sql contains sql no external action deterministic return xmlcast(xmlquery('$d/row/c2' passing xmlrecord as "d") as integer);
reorg table FCOK_ACCOUNT_TEST inplace
db2pd -db admindb –reorg
Database Member 0 -- Database ADMINDB -- Active -- Up 10 days 03:14:17 -- Date 2021-07-26-19.28.05.648688
Table Reorg Information:
Address TbspaceID TableID PartID MasterTbs MasterTab TableName Type IndexID TempSpaceID
0x0A001F00174DF588 4 21566 n/a n/a n/a FCOK_ACCOUNT Offline 0 4
0x0A001F0027981508 3 26880 n/a n/a n/a FCOK_ACCOUNT_TEST Online 0 3
Table Reorg Stats:
Address TableName Start End PhaseStart MaxPhase Phase CurCount MaxCount Status Completion
0x0A001F00174DF588 FCOK_ACCOUNT 07/16/2021 18:38:46 07/16/2021 18:43:15 07/16/2021 18:39:40 3 IdxRecreat 0 0 Done 0
0x0A001F0027981508 FCOK_ACCOUNT_TEST 07/26/2021 18:13:16 07/26/2021 18:14:38 n/a n/a n/a 0 0 Done 0
bash-4.2$
set integrity for FCOK_ACCOUNT_TEST off;
ALTER TABLE FCOK_ACCOUNT_TEST ADD CATEGORY INTEGER generated always as (FCOK_ACCOUNT_CATEGORY_C2(XMLRECORD))
set integrity for FCOK_ACCOUNT_TEST immediate checked;
db2 "set integrity for DB2ADMIN.FCOK_ACCOUNT_TEST immediate checked"
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL3603N Integrity processing through the SET INTEGRITY statement has found
an integrity violation involving a constraint, a unique index, a generated
column, or an index over an XML column. The associated object is identified by
"DB2ADMIN.FCOK_ACCOUNT_TEST.CATEGORY". SQLSTATE=23514
bash-4.2$
bash-4.2$ db2 "select TYPE, ENFORCED from SYSCAT.TABCONST where CONSTNAME='CATEGORY'"
TYPE ENFORCED
0 record(s) selected.
bash-4.2$ db2 "select COLSEQ,COLNAME from SYSCAT.KEYCOLUSE where CONSTNAME='CATEGORY'"
COLSEQ COLNAME
0 record(s) selected.
bash-4.2$ db2 "reorg table db2admin.FCOK_ACCOUNT_TEST inplace"
SQL0668N Operation not allowed for reason code "1" on table
"DB2ADMIN.FCOK_ACCOUNT_TEST". SQLSTATE=57016

DB2 UPGRADE DB “SQL0954C Not enough storage space is available in the application heap to process the statement. SQLSTATE=57011”

I’m attempting to upgrade DB2 10.5 to 11.1 and when I’m doing the DB2 UPGRADE on my database. I’m constantly getting a
SQL0954C Not enough storage space is available in the application heap to process the statement. SQLSTATE=57011
I have increased my APPLHEAPSZ and APPL_MEMORY to match my INSTANCE_MEMORY of AUTOMATIC(2449536) (and tried various other sizes in between) and I still get the error.
If I run a DB2MTRK -a command, I can see my apph memory increase to 4.8G before throwing the error. I am by no means a DB2 expert, so I’m assuming I’m probably doing something obviously wrong. Any help would be greatly appreciated.
Try to do the following before the next attempt:
db2 update db cfg for MYDB using APPLHEAPSZ automatic APPL_MEMORY automatic SELF_TUNING_MEM ON
If they are set as described already, then try to free some memory for APPLHEAPSZ / APPL_MEMORY growth by constraining the size of bufferpools:
db2set DB2_OVERRIDE_BPF=10000
db2stop
db2start
Don't forget to reset this variable afterwards:
db2set DB2_OVERRIDE_BPF=
db2stop
db2start
If it still fails, it's good to look at the corresponding messages in the db2diag.log
Thanks for the reply, I tried this, but still no success. Here is the entry from my log:
2018-11-08-15.48.48.612000-300 I5495453F1112 LEVEL: Warning
PID : 2792 TID : 1460 PROC : db2syscs.exe
INSTANCE: DB2 NODE : 000 DB : MYDB
APPHDL : 0-8 APPID: *LOCAL.DB2.181108203254
AUTHID : DB2ADMIN HOSTNAME: WIN-5MC66HH7NA4
EDUID : 1460 EDUNAME: db2agent (MYDB) 0
FUNCTION: DB2 UDB, SQO Memory Management, SqloMemController::requestMemory, probe:50
MESSAGE : ZRC=0x8B0F0000=-1961951232=SQLO_NOMEM "No Memory Available"
DIA8300C A memory heap error has occurred.
DATA #1 : String, 36 bytes
OOM - Instance memory request failed
DATA #2 : String, 35 bytes
Logging disabled until next success
DATA #3 : unsigned integer, 8 bytes
5148573696
DATA #4 : unsigned integer, 8 bytes
0
DATA #5 : String, 13 bytes
APPL-MYDB
DATA #6 : unsigned integer, 8 bytes
6909722624
DATA #7 : unsigned integer, 8 bytes
3475243008
DATA #8 : unsigned integer, 8 bytes
9480896512
DATA #9 : unsigned integer, 8 bytes
10033299456
DATA #10: unsigned integer, 8 bytes
3825991680

How to monitor a deadlock in DB2

I am following this link and try to simulate the deadlock issue:
http://www.dba-db2.com/2012/06/how-to-monitor-a-deadlock-in-db2.html
I can see my command run successful.
After that I go to simulate a deadlock error through DbVisualiser tool. However I didnt see any file being generated to the path.
Can someone point the mistake to me?
And also, I try to read back those old 0000000.evt file, it show me something as follow:
EVENT LOG HEADER
Event Monitor name: DB2DETAILDEADLOCK
Server Product ID: SQL10059
Version of event monitor data: 12
Byte order: BIG ENDIAN
Number of nodes in db2 instance: 1
Codepage of database: 1208
Territory code of database: 1
Server instance name: db2inst1
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Database Name: MYDB
Database Path: /db2home/db2inst1/NODE0000/SQL00003/MEMBER0000/
First connection timestamp: 01/29/2018 10:00:17.694784
Event Monitor Start time: 01/29/2018 10:00:18.951331
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Database Name: MYDB
Database Path: /db2home/db2inst1/NODE0000/SQL00003/MEMBER0000/
First connection timestamp: 01/29/2018 10:12:54.382936
Event Monitor Start time: 01/29/2018 10:12:54.697223
--------------------------------------------------------------------------
This means no deadlock?
Works correctly for me (linux, Db2 v11.1). Here are some command lines with annotations. You need to have suitable authorisation/privilege for each command. I was using the instance owner account.
Disable default db2detaildeadlock monitor first and then create your own:
$ db2 "set event monitor db2detaildeadlock state=0"
DB20000I The SQL command completed successfully.
$
$ db2 "create event monitor dlmon for deadlocks write to file '/tmp'"
DB20000I The SQL command completed successfully.
$
$ db2 "set event monitor dlmon state=1"
DB20000I The SQL command completed successfully.
$
Generate a deadlock, ensure you see this SQLCODE -911 with reason code 2.
If you dont' see the reason code 2 then you don't have any deadlock but you might have a timeout and timeouts don't get recorded in the deadlock monitor.
Here I show the victim of the deadlock getting notified of rollback and you can see the correct reason code:
$ db2 +c "select * from db2inst1.dlk where a=4 with rr"
SQL0911N The current transaction has been rolled back because of a deadlock
or timeout. Reason code "2". SQLSTATE=40001
Investigate the monitor output with db2evmon and view resulting file
$ db2evmon -db mydb -evm dlmon > /tmp/db2evmon.dlmon.1
Reading /tmp/00000000.evt ...
$ view /tmp/db2evmon.dlmon.1
...<snip>
...
3) Deadlock Event ...
Deadlock ID: 2
Number of applications deadlocked: 2
Deadlock detection time: 01/03/2018 09:06:39.019854
Rolled back Appl participant no: 2
Rolled back Appl Id: *LOCAL.db2inst1.180301090546
Rolled back Appl seq number: 00001
Rolled back Appl handle: 11872
...<snip>

xa_open failure with SQLCODE=-1032

I am using a Tuxedo(v12.2.2.0.0) on Linux(x64) to access DB2 on mainframe through DB2 Connect Server(v9.7).
Now i meet a problem that the TMS_UDB can not start up。
From Tuxedo ULOG, it says:
ERROR: tpopen TPERMERR xa_open returned XAER_RMERR
I checked db2dial log it shows:
2018-XX-XX-xxxx E4387E703 LEVEL: Error
PID : 12673 TID: 139892007870912 PROC: TMS_UDB
INSTANCE: db2inst1
HOSTNAME: XXXX
FUNCTOIN: DB2 UDB, XA DTP Support, sqlxaConnect, probe: 5329
MESSAGE : XA Interface SQLCA
DATA #1 : SQLCA, PD_DB2TYPE_SQLCA, 136 bytes
sqlcaid : SQLCA sqlcabc: 136 sqlcode: -1032 sqlerrml:0
sqlerrmc:
sqlerrp : SQLJCMN
sqlerrd : (1) 0x81360012 (2) 0x00000012 (3) 0x00000000
(4) 0x00000002 (5) 0x00000004 (6) 0x00000000
sqlwarn : (1) (2) (3) (4) (5) (6)
(7) (8) (9) (10) (11)
sqlstate: 00000
Any DB2 export, how can i make it fixed ? thanks
I have verified DB2 client CONNECT command($ db2 connect to DBXX user USERxx using PASSXX), and query out data using SELECT statement.
and also have following the Tuxedo guide to set DB2 configuration items.
https://docs.oracle.com/cd/E26665_01/artrt/docs11gr1/cicsref/db2conn.html
Converting the comment thread to an answer.
For a new installation of Tuxedo where XA transactions are required (managed by Tuxedo as TP monitor) with one leg being Db2 for Z/OS, it is necessary to configure both Tuxedo and Db2-connect to support XA transactions, in addition to basic actions for Db2 connectivity and in addition to any Db2 licensing activities.
Note that Linux/AIX/Windows: command-line connections (from the workstation to Db2 for Z via Db2-connect) will only verify connectivity and userid/password access, but this will not test XA. Command-line connections are Type-1 connections (i.e they are not using distributed units of work).
The configuration details can be version specific so always consult the version-specific documentation for both Tuxedo and Db2-connect products.
For Tuxedo, the documentation page is
https://docs.oracle.com/cd/E26665_01/artrt/docs11gr1/cicsref/db2conn.html
For Db2-Connect v9.7 (later versions are also accessible from here) the page is:
https://www.ibm.com/support/knowledgecenter/en/SSEPGG_9.7.0/com.ibm.db2.luw.qb.dbconn.doc/doc/t0006168.html
Typical configuration for Db2-connect includes:
`db2 update dbm cfg using tp_mon_name TUXEDO
db2 update dbm cfg using spm_name bjaix # hostname of the node running Db2-connect
db2 update dbm cfg using max_connections 500
db2 update dbm cfg using max_coordagents 200
// You may also want to enable the Db2-connect connection-concentrator depdending on your peak concurrency needs and the available resources
db2stop
db2start`
Additional configuration of Tuxedo is required, in part referencing some of the Db2-configuration, refer to the Oracle Tuxedo documentation for details.

db2 Error sqlcode: -1224

Has anyone seen this type pf error msg before. I cannot find documentation on sql code -1224?
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQLCA Information
sqlcaid : SQLCA sqlcabc: 136 sqlcode: -1224 sqlerrml: 0
sqlerrmc:
sqlerrp : SQLJRERM
sqlerrd : (1) -2143879059 (2) 0 (3) 0
(4) 0 (5) 0 (6) 0
sqlwarn : (1) (2) (3) (4) (5) (6)
(7) (8) (9) (10) (11)
sqlstate: 55032
Always try to check IBM infocenter with such errors:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=/com.ibm.db2.luw.messages.sql.doc/doc/msql01224n.html
Short comment from my side:
A reboot could fix your problem, if you can in your environment.
If it's a production server, I suggest a db2stop and afterwards a db2start , this could also help
Normally, -1224 is a trap which comes from memory corruption.
If you run the function unfenced, try to switch to fenced.
Also, take a look at your trap files.
Also, this can happen if you have an invalid JVM level. Make sure you use a supported jdk level => move to the latest version