This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 140068 - org.netbeans.api.db.explorer.DatabaseException: ???????? ??????????
Summary: org.netbeans.api.db.explorer.DatabaseException: ???????? ??????????
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jiri Rechtacek
URL: http://statistics.netbeans.org/except...
Keywords:
: 139902 140067 140259 140261 140265 140271 140272 140373 140473 140539 141145 141911 142418 142993 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-07-15 12:38 UTC by Roman Mostyka
Modified: 2009-04-20 10:40 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 24630


Attachments
stacktrace (1.97 KB, text/plain)
2008-07-15 12:38 UTC, Roman Mostyka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Mostyka 2008-07-15 12:38:43 UTC
Build: NetBeans IDE Dev (Build 080714)
VM: Java HotSpot(TM) Client VM, 11.0-b13, Java(TM) SE Runtime Environment, 1.6.0_10-rc-b26
OS: Windows XP, 5.1, x86

User Comments: 
1. Connect to Oracle DB.
2. Disconnect after couple of minutes.

Result: DatabaseException arises.
Comment 1 Roman Mostyka 2008-07-15 12:38:48 UTC
Created attachment 64554 [details]
stacktrace
Comment 2 Roman Mostyka 2008-07-22 17:28:48 UTC
Often arising exception make bad impression of IDE.
Comment 3 David Vancouvering 2008-07-28 23:49:02 UTC
Pretty sure this is related to issue 132580
Comment 4 David Vancouvering 2008-07-28 23:50:20 UTC
*** Issue 140373 has been marked as a duplicate of this issue. ***
Comment 5 David Vancouvering 2008-07-28 23:52:41 UTC
*** Issue 141145 has been marked as a duplicate of this issue. ***
Comment 6 David Vancouvering 2008-07-28 23:53:37 UTC
*** Issue 140067 has been marked as a duplicate of this issue. ***
Comment 7 David Vancouvering 2008-07-28 23:56:57 UTC
*** Issue 139902 has been marked as a duplicate of this issue. ***
Comment 8 David Vancouvering 2008-07-28 23:57:14 UTC
*** Issue 132580 has been marked as a duplicate of this issue. ***
Comment 9 David Vancouvering 2008-07-29 18:50:21 UTC
*** Issue 140259 has been marked as a duplicate of this issue. ***
Comment 10 David Vancouvering 2008-07-29 18:51:05 UTC
*** Issue 140261 has been marked as a duplicate of this issue. ***
Comment 11 David Vancouvering 2008-07-29 18:51:26 UTC
*** Issue 140265 has been marked as a duplicate of this issue. ***
Comment 12 David Vancouvering 2008-07-29 18:51:44 UTC
*** Issue 140271 has been marked as a duplicate of this issue. ***
Comment 13 David Vancouvering 2008-07-29 18:52:04 UTC
*** Issue 140272 has been marked as a duplicate of this issue. ***
Comment 14 David Vancouvering 2008-07-29 18:58:20 UTC
*** Issue 140539 has been marked as a duplicate of this issue. ***
Comment 15 David Vancouvering 2008-07-29 19:03:29 UTC
*** Issue 141739 has been marked as a duplicate of this issue. ***
Comment 16 David Vancouvering 2008-07-29 20:50:03 UTC
*** Issue 141911 has been marked as a duplicate of this issue. ***
Comment 17 David Vancouvering 2008-07-30 20:08:36 UTC
I can reproduce with Java DB.
Comment 18 David Vancouvering 2008-07-30 21:27:55 UTC
I modified ConnectionNodeInfo.getChildren() to return an empty vector if the connection is closed, and that seems to
have solved the problem.  

Revision 77618b8e27fc

Please verify once you see it has been integrated into the main-golden build.
Comment 19 Roman Mostyka 2008-07-31 10:10:21 UTC
I still can reproduce this issue. And I see changes from the changeset.
Now if I simply connect and then disconnect everything is fine, but if I expand mode and try to look tables and then
disconnect I still get the same exception.
Comment 20 Exceptions Reporter 2008-07-31 11:11:08 UTC
This issue has already 50 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=24630
Comment 21 _ alexlamsl 2008-07-31 11:17:41 UTC
Product Version: NetBeans IDE Dev (Build 200807310201)
Java: 1.6.0_04; Java HotSpot(TM) Server VM 10.0-b19
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)

Reproduced with "Oracle Thin" against Oracle 9i.
Comment 22 _ alexlamsl 2008-07-31 11:18:16 UTC
Product Version: NetBeans IDE Dev (Build 200807310201)
Java: 1.6.0_04; Java HotSpot(TM) Server VM 10.0-b19
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)

Reproduced with "Oracle Thin" against Oracle 9i.
Comment 23 Quality Engineering 2008-07-31 15:42:52 UTC
Integrated into 'main-golden', available in build *200807311401* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/77618b8e27fc
User: David Van Couvering <davidvc@netbeans.org>
Log: #140068 - Getting "connection is no longer open" exceptions after closing a connection
This was caused by the node model trying to refresh children under the connection when the connection was no longer valid.
Comment 24 David Vancouvering 2008-07-31 17:20:09 UTC
OK, thanks.  Can you please tell me how you reliably reproduce this?  I can use Java DB, MySQL, Oracle or PostgreSQL as
a backend database.  Obviously my tests are not reliable.
Comment 25 Roman Mostyka 2008-07-31 17:37:21 UTC
I easily can reproduce this issue all the time. Here are the steps:
1. Connect to Oracle.
2. Expand connection's node. Now you see "Tables", "Views" and "Procedures" nodes.
3. Disconnect.

And after this exception always arises.
Comment 26 David Vancouvering 2008-07-31 19:40:45 UTC
OK, can easily reproduce, thanks.
Comment 27 David Vancouvering 2008-07-31 21:11:23 UTC
OK, it looks like I got it fixed.  It's due to threading issues - a thread comes in an notices we're still connectd and
tries to refresh the children.  But meanwhile another thread disconnects, and then when the first thread tries to get
results from the DB the connection is closed.

As I mentioned in the comments to the fix, the right way is to do what I did in the MySQL code - put all database access
for a given connection on a thread that is fed by a request queue.  That way all access to the DB is serialized and you
don't run into these timing issues.
Comment 28 David Vancouvering 2008-07-31 21:13:06 UTC
e10cf9d98fba
Comment 29 David Vancouvering 2008-08-01 05:30:03 UTC
I fixed this behavior, but introduced an opposite behavior - when you create a connection, the sub-nodes (Table, View,
Procedure) show now children.  This is because the race condition now goes the other way - the sub-nodes think the
database is not connected when it is and therefore don't query the database for the children.

I am working on yet another approach.  

I am realizing the whole architecture around what a DatabaseConnection is and how it is managed in the explorer needs to
be rethought.  Normally in a multithreaded world you use a connection pool, but this places the requirement on users of
the API to close the connection when they are done with it - this is an incompatible change.  But at least within the
explorer we should serialize access to the connection.

I am trying a poor man's version of this - serializing the call to getChildren() - and we'll see if this gets us through
the current spate of bugs.
Comment 30 David Vancouvering 2008-08-02 00:03:02 UTC
9987e48e6e0a
Comment 31 Quality Engineering 2008-08-02 16:00:01 UTC
Integrated into 'main-golden', available in build *200808021401* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/e10cf9d98fba
User: David Van Couvering <davidvc@netbeans.org>
Log: #140068 - Getting "connection is no longer open" exceptions after closing a connection
Another attempt.  The Node.ChildFactory implementation is running three different threads twice to refresh the nodes.  Due to timing issues, some of these are coming through before the disconnect completes, but then are still refreshing data when the connection is closed.  So I have the children check to see if we're still connected before querying the database.

The right way to fix this is to, as Andrei has suggested, move the stuff that works with the database to a separate thread that is fed by a queue and thus we synchronize all access to the database.
Comment 32 Roman Mostyka 2008-08-04 11:17:26 UTC
Verified with build 080804.
Comment 33 David Vancouvering 2008-08-04 22:53:27 UTC
*** Issue 142418 has been marked as a duplicate of this issue. ***
Comment 34 Andrei Badea 2008-08-05 16:13:18 UTC
*** Issue 140473 has been marked as a duplicate of this issue. ***
Comment 35 Roman Mostyka 2008-08-07 13:54:02 UTC
*** Issue 142993 has been marked as a duplicate of this issue. ***
Comment 36 Exceptions Reporter 2008-10-08 16:00:35 UTC
Reopening - reproduced in NetBeans IDE 6.5 Beta (Build 200808111757)
http://statistics.netbeans.org/exceptions/detail.do?id=124946
Comment 37 David Vancouvering 2008-10-08 18:02:57 UTC
Have you tested this with the latest nightly build?  I believe this error has been fixed.

http://bits.netbeans.org/dev/nightly/latest

Please either close (if it is fixed in the nightly build) or remove the INCOMPLETE keyword after you have tested with
the nightly build.

Thanks!
Comment 38 David Vancouvering 2008-10-17 16:46:53 UTC
Still waiting to hear if anyone can reproduce with the latest nightly build.  Otherwise I may close as fixed.
Comment 39 David Vancouvering 2008-10-21 17:19:21 UTC
Still no response, so closing as fixed.
Comment 40 Roman Mostyka 2008-10-21 17:31:23 UTC
Verified.
Comment 41 Marian Mirilovic 2009-04-14 16:41:53 UTC
reproduced in NB 6.7 (20090414) ... 164 duplicates ... last few reported for post 6.5 builds
Comment 42 Jiri Rechtacek 2009-04-15 10:04:21 UTC
I'll inspect what was wrong in recent NB6.7. Probable dupl of an another problem...
Comment 43 Jiri Rechtacek 2009-04-17 13:26:35 UTC
Marian, do have any steps to reproduce it? Thanks
I tried it following the steps done by Roman Mostyka and it worked for me. No exception. The recent reports on
http://statistics.netbeans.org/exceptions/detail.do?id=24630 speak about another problem than was the original
org.netbeans.api.db.explorer.DatabaseException. It should be split on two different issues IMHO.
Comment 44 Marian Mirilovic 2009-04-20 09:01:26 UTC
I am sorry Jirka, but I am not sure which step exactly caused an exception ... I was running select queries to DB.
Comment 45 Jiri Rechtacek 2009-04-20 10:40:23 UTC
Closed it as fixed again. The duplicates from recent build should go in
http://www.netbeans.org/issues/show_bug.cgi?id=157243.