Friday, July 13, 2012


Find actual Physical CPU count, Cores in a server running Linux

Environment:

> cat /etc/*-release | grep -i linux
SUSE Linux Enterprise Server 10 (x86_64)

The well-known command…

-- In the below example, the /proc/cpuinfo shows processor listing starting from 0 and goes upto 15. So, a total count of 16. So from the below example, how do we figure out the actual count of physical CPU, cores, hyper threading, etc.

> cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           X5570  @ 2.93GHz
stepping        : 5
cpu MHz         : 2926.103
cache size      : 8192 KB
physical id     : 1
siblings        : 8
core id         : 0
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx rdtscp lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr dca popcnt lahf_lm
bogomips        : 5857.34
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

.
.
.
.
.
.

processor       : 15
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           X5570  @ 2.93GHz
stepping        : 5
cpu MHz         : 2926.103
cache size      : 8192 KB
physical id     : 0
siblings        : 8
core id         : 3
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx rdtscp lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr dca popcnt lahf_lm
bogomips        : 5852.07
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:


-- Things to look out for
- processor count – 16 in our case
- siblings – 8 in our case
- cores – 4 in our case
- flags – look for "ht" in flags for hyper threading

-- Calculation

physical cpu = processor count/ siblings
physical cpu = 16/8 = 2 CPU (We have a 2 CPU machine)

cores = number of individual cores in a single cpu
cores = cpu cores = 4

               
                So it is a 2 CPU, 4 core machine with ht enabled.
                2 CPU * 4 Cores * 2(ht enabled) = 16 CPU in /proc/cpuinfo


-- To do a quick check directly from command line

- How many physical processors are there?

> grep 'physical id' /proc/cpuinfo | sort | uniq | wc -l
2

- How many virtual processors are there?

> grep processor /proc/cpuinfo | wc -l
16

Thursday, July 5, 2012

ORA-08102: index key not found


ORA-08102: index key not found

Environment:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
SUSE Linux Enterprise Server 10 (x86_64)

Issue :
One of our developers reported that he is getting an error when he was trying to DELETE data from a table.

Error Message:

SQL> delete from purchase;
delete from purchase
            *
ERROR at line 1:
ORA-08102: index key not found, obj# 77136, file 18, block 291 (2)



-- Find out the object referenced in the error message.

SQL> select OWNER,OBJECT_NAME,SUBOBJECT_NAME,CREATED,last_ddl_time from dba_objects  where object_id=77136;

OWNER
------------------------------
OBJECT_NAME
--------------------------------------------------------------------------------
SUBOBJECT_NAME                 CREATED   LAST_DDL_
------------------------------ --------- ---------
SNIADM
IX7_PURCHASE
MAR2012_SP2                    27-JUN-12 27-JUN-12


This is an index named IX7_PURCHASE and it’s a partitioned index and sub-partition MAR2012_SP2 is what is causing the issue.

-- I tried to rebuild the index

SQL> alter index SNIADM.IX7_PURCHASE rebuild online;
alter index SNIADM.IX7_PURCHASE rebuild online
                       *
ERROR at line 1:
ORA-14086: a partitioned index may not be rebuilt as a whole

Oops! It’s a partitioned index and hence the rebuild cannot be as a whole. This is what the error message means.

> oerr ora 14086
14086, 00000, "a partitioned index may not be rebuilt as a whole"
// *Cause:  User attempted to rebuild a partitioned index using
//          ALTER INDEX REBUILD statement, which is illegal
// *Action: Rebuild the index a partition at a time (using
//          ALTER INDEX REBUILD PARTITION) or drop and recreate the
//          entire index


-- Then I tried to rebuild the index at the subpartition level where the problem occurred.

SQL> alter index SNIADM.IX7_PURCHASE rebuild subpartition MAR2012_SP2 TABLESPACE SNI_IDX2 online;

Index altered.

The delete from the table failed again with the same error message.

-- Then I tried to rebuild all subpartitions of the index by using the following statement output spooled to a SQL file.

select 'alter index '||index_owner||'.'||index_name||' rebuild subpartition '||subpartition_name||' tablespace '||tablespace_name||' online;' from dba_ind_subpartitions where index_name='IX7_PURCHASE';

The delete from the table failed again with the same error message.

-- Then I dropped and recreated the index. This fixed the issue.


I need to explore if there is a better way or recommended way to fix this issue. If anyone else knows a better way, please suggest.


Tuesday, July 3, 2012

expdp/ impdp – When impdp is hung..



We use expdp/impdp often as part of backup strategy, data movement, refresh requests, etc. Here is one situation I encountered when trying to import data into a database using impdp.
 
Environment: Oracle 11.2.0.2 on Suse Linux 10 SP2
The import was hung and it was WAITING !!


Identifiy the impdp process at the session level and see what it is waiting on..
 
 

SQL> col username for a15
SQL> col program for a30
SQL> set lines 200
SQL> col machine for a25
SQL> select inst_id,username,machine,program,sid,serial#,status,sql_id,SQL_HASH_VALUE,last_call_et from gv$session where username is not null and username <>'SYS' order by 10;

   INST_ID USERNAME        MACHINE                   PROGRAM                               SID    SERIAL# STATUS   SQL_ID        SQL_HASH_VALUE LAST_CALL_ET
---------- --------------- ------------------------- ------------------------------ ---------- ---------- -------- ------------- -------------- ------------
         1 DBSNMP          nelsdb20                emagent@nelsdb20 (TNS V1-V3)             99         17 INACTIVE                            0           56
         2 DBSNMP          nelsdb21                emagent@nelsdb21 (TNS V1-V3)            226      10053 INACTIVE                            0           75
         1 SSCADM          nelsdb20                oracle@nelsdb20 (DW00)                   40        841 ACTIVE   9035v672ffr0x     3303496733         1085
         2 DBSNMP          nelsdb21                emagent@nelsdb21 (TNS V1-V3)            163         13 INACTIVE                            0       322465
 


 
 
SQL> select event from v$session_wait where sid=40;
 
EVENT
----------------------------------------------------------------
statement suspended, wait error to be cleared
 
SQL> SELECT NAME,STATUS, TIMEOUT, ERROR_NUMBER, ERROR_MSG FROM DBA_RESUMABLE;
 
NAME                       STATUS       TIMEOUT       ERROR_NUMBER  ERROR_MSG
--------------------------- ---------   --------      ------------  -----------------------------------------------------------------
SYS.SYS_IMPORT_SCHEMA_01.1 SUSPENDED       7200              1652   ORA-01652: unable to extend temp segment by 128 in tablespace SSC
SYS.SYS_IMPORT_SCHEMA_01   NORMAL          7200
 
 
The error points to unavailability of free space in the tablespace.  The impdp goes on a resumable state in this case and simply waits.
 
Once space is added to the tablespace, the process automatically picks up and the impdp completes.