Skip to content

Commit

Permalink
NOw handles multiple trace files on the command line.
Browse files Browse the repository at this point in the history
  • Loading branch information
NormanDunbar committed Jan 16, 2019
1 parent 21bbea3 commit 7401cc7
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 27 deletions.
90 changes: 86 additions & 4 deletions DeadlockAnalysis.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
body {font: 90% Verdana, Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
background: rgb(95%,95%,80%);
color: black;
}

/*
body {
background: ivory;
color: maroon;
}
*/

table, th, td {
border: 1px solid bisque;
border: 1px solid rgb(85%,85%,70%);
padding-left: 4px;
padding-right: 4px;
padding-top: 2px;
Expand All @@ -15,7 +24,7 @@ table, th, td {
table {
border-collapse: collapse;
background: beige;
font-family: "courier new","lucida console",mono;
/*font-family: "courier new","lucida console",mono;*/
font-size: smaller;
/* If "fixed" is not used, the widths are ignored. Sigh */
/* So the <table> is hard coded as <table style="width:95%"> which I don't like. */
Expand All @@ -31,8 +40,7 @@ pre {
}

th {
background: burlywood;
color: maroon;
background: rgb(90%,90%,75%);
}

.number {
Expand Down Expand Up @@ -138,3 +146,77 @@ li {
font-family: "courier new";
}


/*
* Sidebar stuff to stay on screen during scrolling.
*/
/*-------------------------------------------------------------*
* This really screws IR5.5 - it scrolls and has huge gaps :o( *
* Also, having a fixed position navigation box, gives a dark *
* line when the content is scrolled. A bottom border which is *
* the same colour as the background fixes that ! (ND) *
*-------------------------------------------------------------*/

div {
display: block;
}

div#entry {
padding-left: 15%;
}

div#sidebar {
position: fixed;
top: 8;
left: 4;
width: 10%;
margin: 0 0 0 2%;
text-align: center;
border-bottom: 1px solid rgb(95%,95%,80%);
}

#sidebar h4 {
border: 1px solid rgb(73%,73%,58%);
border-bottom: none;
background: rgb(90%,90%,75%);
}

#sidebar ul {
list-style: none;
margin: 0;
padding: 0 0 2em;
border: 1px solid rgb(73%,73%,58%);
background: beige;
}

#sidebar h4, #sidebar ul {
margin: 0 6px 0 0;
}

#sidebar li {
padding: 0.5em 0;
line-height: 1em;
border-bottom: 1px solid rgb(84%,84%,69%);
}

#sidebar a {
text-decoration: none;
padding: 0 0.25em;
border: 1px solid rgb(84%,84%,69%);
background: rgb(95%,95%,80%);
position: relative; top: 1em;
}

#sidebar a:link {
color: rgb(20%,40%,0%);
}

#sidebar a:visited {
color: rgb(58%,68%,40%);
}

#sidebar a:hover {
color: rgb(10%,20%,0%);
background: #FFF;
}

45 changes: 26 additions & 19 deletions src/DeadlockAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void usage(int errorCode, string errorText) {
cerr << '\n'
<< programName << ": ERROR: " << errorText << "\n'\n"
<< "USAGE:\n"
<< "\t" << programName << " tracefile_name >report_name\n"
<< "\t" << programName << " tracefile_name [tracefile_name ...] \n"
<< endl;

std::exit(errorCode);
Expand All @@ -101,6 +101,10 @@ void usage(int errorCode, string errorText) {

//==============================================================================
// MAIN()
//------------------------------------------------------------------------------
// Start here. There should be one or more parameters representing a trace file
// to be analysed. Each will be analysed and a report created for it, in the
// same location as the trace file itself.
//==============================================================================
int main(int argc, char *argv[])
{
Expand All @@ -113,30 +117,33 @@ int main(int argc, char *argv[])
<< endl;

// There must be a single parameter.
if (argc != 2) {
usage(ERR_INVALID_PARAMS, "No tracefile name supplied");
if (argc < 2) {
usage(ERR_INVALID_PARAMS, "No tracefile name(s) supplied");
}

// One parameter received, it's a trace file name, or better be ...
cerr << "Extraction begins...\n";
oraTraceFile traceFile(argv[1]);
// Parameter(s) received, analyse each as a trace file.
for (auto t = 1; t < argc; t++) {
cerr << argv[t] << '\n';
oraTraceFile traceFile(argv[t]);

if (!traceFile.good()) {
usage(ERR_INVALID_TRACEFILE, "Cannot open tracefile " + string(argv[1]));
}
if (!traceFile.good()) {
usage(ERR_INVALID_TRACEFILE, "\tCannot open tracefile " + string(argv[1]));
}

// Do we have any deadlocks? Parse the file to find out.

// Do we have any deadlocks? Parse the file to find out.
cerr << "\tThere was/were " << traceFile.parse()
<< " deadlock(s) found.\n";

cerr << "There was/were " << traceFile.parse()
<< " deadlock(s) found.\n"
<< "Extraction complete.\n" << endl;
// Build the report.
oraDeadlockReport reportFile(&traceFile);
if (reportFile.good()) {
reportFile.report();
} else {
usage(ERR_INVALID_REPORTFILE, "Cannot create report file " + reportFile.reportName());
}

// Build the report.
oraDeadlockReport reportFile(&traceFile);
if (reportFile.good()) {
reportFile.report();
} else {
usage(ERR_INVALID_REPORTFILE, "Cannot create report file " + reportFile.reportName());
cerr << "Done.\n" << endl;
}

return 0;
Expand Down
28 changes: 25 additions & 3 deletions src/oraDeadlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,32 @@ bool oraDeadlock::extractRowsWaited()
(dictionary objn - 5004374, file - 1024, block - 243391200, slot - 0)
Session 2156: obj - rowid = 004C5C56 - AATFxWAQAAOgdi7AAA
(dictionary objn - 5004374, file - 1024, block - 243390651, slot - 0)
or, sometimems:
Rows waited on:
Session 97: no row
Session 1536: obj - rowid = 0001301E - AAMSDGAAFAOF0/UAAA
(dictionary objn - 77854, file - 5, block - 236408788, slot - 0)
*/

while (mTraceFile->good()) {
// Session 272: obj - rowid = 004C5C56 - AATFxWAQAAOgakFAAA
string traceLine = mTraceFile->readLine();

// The Rows waited on end at a one-space line.
if (traceLine == " ") {
break;
}

// Should be something like these:
// Session 97: no row
// Session 272: obj - rowid = 004C5C56 - AATFxWAQAAOgakFAAA

// Session Number of waiting session.
auto pos = traceLine.find(":");
unsigned tempNumber = stoi(traceLine.substr(9, pos -1));

// Find the waiter session.
// Find the oraBlockerWaiter for the session.
auto thisWaiter = waiterBySession(tempNumber);

//auto waiterPair = mWaiters.find(tempNumber);
Expand All @@ -264,7 +275,18 @@ bool oraDeadlock::extractRowsWaited()
return false;
}

// Rowid waited on.
// Fill in the waiter's details.

// Rowid waited on, or No Row.
if (traceLine.find("no row") != string::npos) {
// No *row* waited for.
thisWaiter->setRowidWait("No row waited for");

// There isn't a following line for this waiter, so
// process the next waiting session's row.
continue;
}

string tempString = traceLine.substr(traceLine.length() -18, 18);
thisWaiter->setRowidWait(tempString);

Expand Down
1 change: 1 addition & 0 deletions src/oraDeadlockReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ oraDeadlockReport::oraDeadlockReport(oraTraceFile *traceFile):
mTraceFile(traceFile)
{
string traceName = traceFile->traceName();
cerr << "\tReport file: " << traceName << '\n';
auto pos = traceName.find_last_of('.');

// Strip off the current extension and replace it with html.
Expand Down
2 changes: 1 addition & 1 deletion src/oraTraceFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ unsigned oraTraceFile::findAllDeadlocks()
while (mIFS->good()) {
// Look for another deadlock.
if (findDeadlock()) {
cerr << "Found a new deadlock at line " << mLineNumber << endl;
cerr << "\tFound a deadlock at line " << mLineNumber << endl;
deadlockCount++;

// Create a new deadlock and get it to extract its own details.
Expand Down

0 comments on commit 7401cc7

Please sign in to comment.