Skip to content

Commit

Permalink
Conflict resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
NormanDunbar committed May 16, 2019
2 parents aff30e0 + b46288c commit 6bb3190
Show file tree
Hide file tree
Showing 14 changed files with 961 additions and 180 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ bin/*
*.old.*
test*.*

*.zip
8 changes: 8 additions & 0 deletions ChangeLog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

_Latest updates at the top of this file._

== Version 1.05
* Minor bug fix. Changed the text _infrequently_ to _in frequently_ - a whole world of difference!
* Slight update to the CSS and layout of the Deadlock Graph table - hiding the top left cell.


== Version 0.1.4
* Minor bug fixes - some text needed grammar changes. Also, for 'frequently' read 'infrequently' in the bitmap indexes explanation.


== Version 0.1.3
Another enhancement release.
Expand Down
6 changes: 3 additions & 3 deletions DeadlockAnalysis.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<Option output="bin/Debug/DeadlockAnalysis" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Option parameters="C:\Users\hisg494\CodeBlocks\SourceCode\DeadlockAnalysys\test.trc" />
<Option compiler="gnu_gcc_compiler3264bit_tdm-gcc-64" />
<Option parameters="E:\SourceCode\DeadlockAnalysys\test.trc" />
<Compiler>
<Add option="-g" />
<Add directory="include" />
Expand All @@ -30,7 +30,7 @@
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Option parameters="C:\Users\hisg494\CodeBlocks\SourceCode\DeadlockAnalysys\test.trc" />
<Option parameters="E:\SourceCode\DeadlockAnalysys\test.trc" />
<Compiler>
<Add option="-O2" />
<Add directory="include" />
Expand Down
9 changes: 9 additions & 0 deletions DeadlockAnalysis.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ th {
width: 10%;
}

/*
* Used to hide the top left cell in the Deadlock Graph table.
*/
.th_background {
background: rgb(95%, 95%, 80%);
border-top: 1px solid rgb(95%, 95%, 80%);
border-left: 1px solid rgb(95%, 95%, 80%);
}

.th_small {
width: 12%;
}
Expand Down
562 changes: 562 additions & 0 deletions Unix/ReadMe.html

Large diffs are not rendered by default.

Binary file added Unix/ReadMe.pdf
Binary file not shown.
77 changes: 77 additions & 0 deletions Unix/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
= CollectDeadlockTraces.sh
Norman Dunbar <[email protected]>
:revnumber: v1.0
:revdate: March 6 2019


*What is it?*

CollectDeadlockTraces.sh is a script to run under a bash shell to:


*What does it do?*

* Locate the alert.log for the current Oracle database environment;
* Scan it for deadlocks - ORA-00060 - and obtain the created trace file's name;
* List any trace files which are not found in the diagnostics area;
* Extract a list of deadlock trace files which still exist;
* Tar them all together;
* Compress the resulting tar file with gzip.


*How do I run it?*

Just execute it. You might need to allow execution by:

chmod ug+x collectDeadlockTraces.sh

Now you can execute it!


*Give me an example*

A test run looks remarkably like the following, for a system that suffered badly from deadlocks caused by using bitmap indexes on an OLTP system, Sigh!

[source]
----
$ ./collectDeadlockTraces.sh

DIAG currently set to /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx

Checking alert log...
MISSING: /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_10158780.trc
...
...
MISSING: /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_9175774.trc

Collecting ...
-rw-r----- 1 oracle asmadmin 1694112 Mar 2 06:05 /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_14025328.trc
-rw-r----- 1 oracle asmadmin 1515803 Mar 2 06:05 /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_15860432.trc
...
...
-rw-r----- 1 oracle asmadmin 1897975 Feb 11 10:55 /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_7602800.trc
-rw-r----- 1 oracle asmadmin 1147204 Feb 27 09:34 /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_9437892.trc

Tarring (and feathering) the files...

Zipping xxxxxxxx_deadlocks.tar ...

Finished: 'xxxxxxxx_deadlocks.tar.gz' is ready for collection.
----

*OK, now what?*

* Download the generated `xxxxxxxx_deadlocks.tar.gz` file;
* Gunzip it (On Windows, https://www.7-zip.org/download.html[`7zip`] is useful for this);
* Untar it (https://www.7-zip.org/download.html[`7zip`] again);
* Run `DeadlockAnalysis` against the resulting pile of trace files;
* Open the generated HTML files in your favourite browser, or use Internet Explorer, and examine why the deadlocks occurred.


*What are all those Xs about?*

They replace the `instance name` and `Oracle_SID` for the database I was testing this code on. It's a small way to protect the innocent and/or guilty and to avoid database names escaping into the wilds where miscreants _might_ wish to attack them.

*Enjoy*.


113 changes: 113 additions & 0 deletions Unix/collectDeadlockTraces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/bin/bash
#-------------------------------------------------------------------------
# A script to scan the PNET01P1 alert log for deadlock entries, from there
# to extract a list of trace file names for said deadlocks. Then, for the
# trace files that still exist, to collect them together in a tar.gz file
# for subsequent SFTPing for further processing.
#-------------------------------------------------------------------------
# You will need to ensure that DIAG is correctly set, either in the shell
# or in this code, to point at where the 'alert' and 'trace' directories
# for the database live, within the diagnostics area.
#
# DIAG=/u01/app/oracle/diag/rdbms/ORACLE_INSTANCE/$ORACLE_SID
#-------------------------------------------------------------------------
# Execution is easy:
#
# 1. Create a working directory.
# 2. Change into it.
# 3. Execute this code.
# 4. Pick up the file $ORACLE_SID_deadlocks.tar.gz.
#-------------------------------------------------------------------------
# History:
#
# 18/09/2018 NDunbar Created.
# 06/03/2019 NDunbar Modified to attempt to create DIAG, and validate it
# to be sure we are in the right location.
#-------------------------------------------------------------------------


# Variables.
TRACELIST=CollectedTraceFiles.txt
TARFILE=${ORACLE_SID}_deadlocks.tar
ZIPFILE="$TARFILE".gz

# Test DIAG exists
if [ ! -v DIAG ]
then
# Try to creat DIAG.
DIAG=${ORACLE_BASE}/diag/rdbms/${ORACLE_SID}/${ORACLE_SID}
fi

echo DIAG currently set to ${DIAG}

# Is DIAG a directory?
if [ ! -d ${DIAG} ]
then
echo ${DIAG} is not a directory.
exit 1
fi

# Is it the correct directory?
if [ ! -d ${DIAG}/trace ]
then
echo ${DIAG} is not an Oracle diagnostic directory.
exit 1
fi

# Wipe out any existing data.
> "$TRACELIST"
rm "$ZIPFILE" >/dev/null 2>&1


# Scan the alert log for unique deadlock trace file names
echo " "
echo Checking alert log...

grep "^ORA-00060:" ${DIAG}/trace/alert_${ORACLE_SID}.log |\
awk -F"." '{print $2}' |\
awk -F" " '{print $5 ".trc"}' |\
sort -u |\
while read traceFile
do
if [ -f "$traceFile" ]
then
echo $traceFile >> "${TRACELIST}"
else
echo MISSING: "$traceFile"
fi
done


# We have a list of existing trace files, collect them together.
echo " "
echo "Collecting ..."

cat "${TRACELIST}" |\
while IFS='' read -r tracefile || [[ -n "$tracefile" ]]
do
ls -l "$tracefile"
chmod o+r "$tracefile"
cp "$tracefile" /tmp/
chmod o-r "$tracefile"
done

# Create the tar file and gzip it.
echo " "
echo Tarring \(and feathering\) the files...

BACK_THERE=`pwd`
cd /tmp
tar -cf "${BACK_THERE}"/"${TARFILE}" ./${ORACLE_SID}*.trc
rm /tmp/${ORACLE_SID}*.trc
cd "${BACK_THERE}"

echo " "
echo Zipping "${TARFILE}" ...
gzip -9 "${TARFILE}"


# Finished.
echo " "
echo Finished: \'"${ZIPFILE}"\' is ready for collection.
echo " "

2 changes: 1 addition & 1 deletion doc/DeadlockAnalysis.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ The trace file summary is displayed at the start of the report. It simply shows
=== Deadlock Summary
image::images/deadlockSummary.png[]

Each deadlock has it's own sections in the report. There is a summary, the graph and details of the waiting sessions for each deadlock.
Each deadlock has its own sections in the report. There is a summary, the graph and details of the waiting sessions for each deadlock.

The deadlock summary lists overall details of the particular deadlock itself. Here you will find:

Expand Down
Loading

0 comments on commit 6bb3190

Please sign in to comment.