Skip to content

Commit 79c8823

Browse files
ancientwizarddjzort
authored andcommitted
Error Detecton "BARKING" during threads / forking and OciSessionEnd()
a balance between detecton, reporting and making the issue worse.
1 parent 3e856da commit 79c8823

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

Oracle.xs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ ora_ping(dbh)
410410
/*later I will replace this with the actual OCIPing command*/
411411
/*This will work if the DB goes down, */
412412
/*If the listener goes down it is another case as the Listener is needed to establish the connection not maintain it*/
413-
/*so we should stay connected but we cannot get nay new connections*/
413+
/*so we should stay connected but we cannot get any new connections*/
414414
{
415415
/* RT 69059 - despite OCIPing being introduced in 10.2
416416
* it is not available in all versions of 10.2 for AIX

dbdcnx.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,17 +1042,37 @@ cnx_detach(pTHX_ imp_dbh_t * imp_dbh)
10421042

10431043
sword status = OCI_SUCCESS;
10441044

1045-
// GLOBAL Perl END's may cause these to SEGV doe to filehandles (just a guess).
1046-
// The person thay left off the logging in the first place should have provided a clue
1047-
// assuming thay knew what the issue was.
1045+
// GLOBAL Perl END's may cause these to SEGV due to filehandles (just a guess).
1046+
// Also forking can cause duplicate closings of a session. A preexisting handle in
1047+
// the parent is duplicated in the child. The first process to call SessionEnd
1048+
// wins, each successive call returns OCI_ERROR.
1049+
//
1050+
// The prior author included a comment about errors but was not specific and choose to ignore them.
1051+
//
10481052
// I thought I was being clever by adding the logging to these OCI calls;
1049-
// or at least help to debug the original SEGV issue.
1053+
// to help debug the original SEGV issue. Best guess is the logging relies on
1054+
// the filehandles being valid and they are not always valid, hence the SEGV
1055+
// within Perl's IO printing.
1056+
//
1057+
// The OCI calls are successful but the logging is not. I don't like silent failures
1058+
// so we'll use a more direct approach to handle this; keeping Perl and it's state
1059+
// out of the picture.
10501060

10511061
// OCISessionEnd_log_stat( imp_dbh, imp_dbh->svchp, imp_dbh->errhp, imp_dbh->seshp, OCI_DEFAULT, status );
10521062
// OCIServerDetach_log_stat( imp_dbh, imp_dbh->srvhp, imp_dbh->errhp, OCI_DEFAULT, status );
10531063

1054-
OCISessionEnd( imp_dbh->svchp, imp_dbh->errhp, imp_dbh->seshp, OCI_DEFAULT );
1055-
OCIServerDetach( imp_dbh->srvhp, imp_dbh->errhp, OCI_DEFAULT );
1064+
if (( status = OCISessionEnd( imp_dbh->svchp, imp_dbh->errhp, imp_dbh->seshp, OCI_DEFAULT )) != OCI_SUCCESS
1065+
&& status != OCI_ERROR )
1066+
{
1067+
// by printing the pointers I could see the children and parent were
1068+
// using the same handles. The first is successful, the rest fail. (seems reasonable enough)
1069+
fprintf( stderr, "OCISessionEnd() failed: %d %p %p %p pid=%d\n", status, imp_dbh->svchp, imp_dbh->errhp, imp_dbh->seshp, getpid());
1070+
}
1071+
1072+
if (( status = OCIServerDetach( imp_dbh->srvhp, imp_dbh->errhp, OCI_DEFAULT )) != OCI_SUCCESS )
1073+
{
1074+
fprintf( stderr, "OCIServerDetach() failed: %d pid=%d\n", status, getpid());
1075+
}
10561076

10571077
#ifdef ORA_OCI_112
10581078
}

0 commit comments

Comments
 (0)