Issue Details (XML | Word | Printable)

Key: DERBY-3701
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Kathey Marsden
Reporter: Kathey Marsden
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

java.lang.Exception: DRDA_UnableToAccept.S:Unable to accept connections and client hang if tracing is turned on but traceDirectory does not exist

Created: 02/Jun/08 02:36 PM   Updated: 30/Jun/09 04:12 PM
Return to search
Component/s: Network Server
Affects Version/s: 10.3.2.1, 10.3.3.0, 10.4.1.3, 10.5.1.1
Fix Version/s: 10.3.3.1, 10.4.2.0, 10.5.1.1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works derby-3701_diff.txt 2008-06-04 06:40 PM Kathey Marsden 12 kB
Text File Licensed for inclusion in ASF works derby-3701_try1_diff.txt 2008-06-03 09:24 PM Kathey Marsden 3 kB
Java Source File Licensed for inclusion in ASF works DerbyIssue.java 2008-06-02 02:37 PM Kathey Marsden 2 kB
HTML File Licensed for inclusion in ASF works releaseNote.html 2008-08-25 03:46 PM Rick Hillegas 5 kB
HTML File Licensed for inclusion in ASF works releaseNote.html 2008-08-06 05:52 PM Rick Hillegas 5 kB
HTML File Licensed for inclusion in ASF works releaseNote.html 2008-06-09 06:12 PM Kathey Marsden 5 kB
HTML File Licensed for inclusion in ASF works releaseNote.html 2008-06-06 09:40 PM Kathey Marsden 5 kB
Issue Links:
Reference

Issue & fix info: Release Note Needed
Bug behavior facts: Regression
Resolution Date: 11/Jun/08 03:44 PM


 Description  « Hide
Attempting to connect to network server if derby.drda.traceAll is set to true and derby.drda.traceDirectory is set to a non-existent directory causes the following exception on the console when the client attempts to connect and causes the client to hang.
java.lang.Exception: DRDA_UnableToAccept.S:Unable to accept connections.
        at org.apache.derby.impl.drda.NetworkServerControlImpl.consolePropertyMessageWork(NetworkServerControlImpl.java:
3172)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.consolePropertyMessage(NetworkServerControlImpl.java:1829
)
        at org.apache.derby.impl.drda.ClientThread.run(ClientThread.java:116)


See attached program DerbyIssue.java for reproducible test case.
This is a regression. It did not occur with 10.3.1.4.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kathey Marsden added a comment - 02/Jun/08 03:55 PM
This issue seems to have been caused by the fix for DERBY-3110

Kathey Marsden added a comment - 02/Jun/08 05:03 PM
It used to be (before DERBY-3110) that if the directory didn't exist the System properties to turn on tracing would just silently be ignored. I think we should at least log a message to derby.log if the directory is not found. Then perhaps as a future trunk improvement, we can attempt to create the directory if it doesn't exist. Thoughts?




Kathey Marsden added a comment - 03/Jun/08 09:24 PM
Attached is my first attempt at fixing this issue. No tests yet. It logs the exception when it tries to turn on tracing when establishing the connection. The problem is we get this exception for every connection, which seems like a lot of output. Before DERBY-3310 the behavior was the same except there was no logging of the exception which was wrong as well.

Any thoughts on how to handle this better?

Dag H. Wanvik added a comment - 04/Jun/08 01:20 AM
Well, it seems better with a lot of output than silently doing nothing, so it seems an improvement to me..
Trace was requested, after all.
I think the directory should be created if permissions are in place, though.

Kathey Marsden added a comment - 04/Jun/08 12:39 PM
Do you think we should attempt to create the trace directory, even for release branches or make that change only on the trunk?


Kathey Marsden added a comment - 04/Jun/08 06:40 PM
Attached is a ptch derby-3701_diff.txt which resolves this issue on trunk. We will now attempt to create the trace directory if it does not exist and will no longer hang if the trace file cannot be accessed. I added tests to NetworkServerControlApiTest. Running tests now.



Myrna van Lunteren added a comment - 04/Jun/08 10:43 PM
I keep going back and forth on your question. I think - as Dag said on the list - if the permissions are in place we should create the dirs.
But should this be backported? Or should we just give an error message in those earlier versions?
Either way will change the behavior, and might be an unwelcome surprise to people who have set this in their application.
But of course not having a connection is worse, that does need to get fixed.
I think maybe a compromise would be to have the stack print to derby.log in older versions. It would still mean more disk space used but not as much as if the full tracing would get created.

Dag H. Wanvik added a comment - 05/Jun/08 03:59 PM
+1 to Myrna's compromise, creating the directory is new behavior, which would presumably necessitate a change in the docs as well, not just a release note, so better reserve that for trunk.

Kathey Marsden added a comment - 05/Jun/08 04:31 PM
Before I check this into the trunk, I would appreciate review. The exception handling is kind of messy since we need to throw an exception when NetworkServerControl.trace(true) fails but only log an exception if tracing fails on making a connection. I did this by adding a parameter to Session.initTrace to determine whether to throw the exception or not. I'd appreciate feedback on whether that's ok.




Mamta A. Satoor added a comment - 06/Jun/08 06:29 PM
Kathey, i went through the patch and just have couple comments.

For DssTrace.java, there is following code in the diff file,
                Exception e = pae.getException();
                if (e instanceof SecurityException)
- throw (SecurityException)pae.getException();
+ throw (SecurityException) e;
                else
- throw (IOException) pae.getException();
+ throw (IOException) e;

Do we need to know what kind of exception it is before we throw it? In other words, could we just do?
                Exception e = pae.getException();
+ throw e;
- if (e instanceof SecurityException)
- throw (SecurityException)pae.getException();
- else
- throw (IOException) pae.getException();


Also, I wonder if it will be good to test that /trace/Server1.trace does not exist after making a Connection in xtestTraceSystemPropertiesNoPermission test.

Other than that, the patch looks good to me.

Kathey Marsden added a comment - 06/Jun/08 08:18 PM
Thanks Mamta for looking at the patch. I'll make the change in DssTrace.
For the test we don't have permission to read that directory so can't tell whether it created the file or not unfortunately.

Kathey

Kathey Marsden added a comment - 06/Jun/08 09:40 PM
Attached is a release note for this issue. I intend to backport the change, less the directory creation to 10.4 and 10.3.


Dag H. Wanvik added a comment - 07/Jun/08 01:28 AM
Maybe it would be good to say that any intervening directories in the given path will be created as well (I tried and they did on Solaris anyway). This may not be obvious to some users, cf. the -p option in many Unix mkdir(1) commands.

Knut Anders Hatlen added a comment - 08/Jun/08 05:34 PM
Is the exists check necessary in the code below? In Sun's class library at least, File.mkdirs() first calls File.exists() and does nothing if the directory exists. Since mkdirs() doesn't throw IOException, I believe it should be safe in other JVMs as well.

+ if (!PrivilegedFileOps.exists(traceDirectory))
+ {
+ PrivilegedFileOps.mkdirs(traceDirectory);
+ }

mkdirs()'s javadoc has an invalid HTML tag (<code> true </true>). Fixed in revision 664524.

The indentation in Session.java seems to be off. Probably a wrong tab size setting in your IDE. Fixed in revision 664530.

Kathey Marsden added a comment - 09/Jun/08 06:12 PM
Attaching updated releaseNote to indicate that intervening directories will also be created (per Dag's suggestion).

Rick Hillegas added a comment - 06/Aug/08 05:52 PM
Changed an uppercase begin-bold tag to lowercase so that it would match the corresponding lowercase end-bold tag and pass the lint tool for release notes: org.apache.derbyBuild.ReleaseNoteReader

Rick Hillegas added a comment - 25/Aug/08 01:48 PM
Hi Kathey,

Knut was wondering on DERBY-3820 whether the release note correctly describes the behavior on 10.4 and 10.3. According to your earlier comments, you reworked the patch for those branches. The release note also seems to be talking about branches rather than releases. For instance, the behavior for 10.3 seems to me to be the behavior for the 10.3 branch, not the latest 10.3 release we have produced. It might be more useful to customers if the note talked about releases rather than branches. Thanks.

Myrna van Lunteren added a comment - 25/Aug/08 03:19 PM - edited
If I understand correctly, the backport to older branches still represents a change from earlier behavior of older releases off those branches in that now a warning/error message will come to derby.log (although the dirs still do not get created).

The one reason why I think we might want to have a release note mentioning that is that derby.log can get really big that way.

Rick Hillegas added a comment - 25/Aug/08 03:46 PM
Thanks for the explanation, Myrna. I'm inlined to include this release note in the 10.4.2 issues list. Attaching a new version of releaseNote.html. This version clarifies the distinction between branches and releases.

Knut Anders Hatlen added a comment - 25/Aug/08 04:16 PM
Thanks, the changes (and the explanation) made it much clearer to me.