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 151513 - Error message appears by attempt to add column to an index
Summary: Error message appears by attempt to add column to an index
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All Mac OS X
: P2 blocker (vote)
Assignee: David Vancouvering
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-27 18:52 UTC by Roman Mostyka
Modified: 2008-10-31 20:23 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot of error message. (12.07 KB, image/jpeg)
2008-10-27 18:54 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-10-27 18:52:34 UTC
1. Connect to some DB.
2. Exapnd "Indexes" node, rightclick some index and choose "Add Column".
3. Choose some column and press Enter.

Result: Error message appears, but column is added.
Comment 1 Roman Mostyka 2008-10-27 18:54:31 UTC
Created attachment 72708 [details]
Screenshot of error message.
Comment 2 David Vancouvering 2008-10-28 20:42:02 UTC
I've seen this too, but it's not reliably reproducible.  The real pain is that there is no stack trace in the log file. 

My first step is to get the darn thing to print a stack trace and then we'll see what we shall see...
Comment 3 David Vancouvering 2008-10-28 23:54:15 UTC
4a4a8c34ffd3

The problem was that the method call to add the column was happening on the event thread - actually a bad idea for a
database operation, so it was good that this was detected.

I moved the operation into the task thread, and I can't reproduce any more, anyway, but since it's random I'm not sure.
 Roman, please verify.
Comment 4 David Vancouvering 2008-10-30 05:06:41 UTC
I fixed this for "Add Column" but not for "Add Column to Index", it appears.
Comment 5 David Vancouvering 2008-10-30 06:03:18 UTC
299f2490cfa5
Comment 6 Roman Mostyka 2008-10-30 17:57:05 UTC
Verified with build 081030.
Comment 7 Quality Engineering 2008-10-31 04:46:34 UTC
Integrated into 'main-golden', will be available in build *200810310201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/299f2490cfa5
User: David Van Couvering <davidvc@netbeans.org>
Log: #151513: Error message appears by attempt to add column to an index
Comment 8 Andrei Badea 2008-10-31 16:32:51 UTC
Why is calling addColumn() in the event thread a bad idea, when all it does (TableNodeInfo.addColumn()) is
notifyChange(), which should schedule a refresh of the nodes in a background thread?
Comment 9 David Vancouvering 2008-10-31 18:39:45 UTC
Which changeset are you talking about Andrei?  There is no call to addColumn() in the changeset for this fix.

Comment 10 Andrei Badea 2008-10-31 20:07:10 UTC
I was reacting to your comment in desc4. Adding the column in the event thread doesn't seem to matter here, because
(according to TableNodeInfo.addColumn()) adding a column means refreshing the column nodes, which should happen in a
background thread. So I wonder how exactly the problem reported by Roman occurred.
Comment 11 David Vancouvering 2008-10-31 20:23:04 UTC
Oh, I see.  Well, what the code actually does is call NodeInfo.refreshChildren(), and refreshChildren() calls
initChildren(), and IndexNodeInfo.initChildren() calls testDatabaseConnection(), which calls getJDBCConnection(test),
which can't be called on the event thread.

Now, perhaps it shouldn't call refreshChildren() and instead call notifyChange().  But the action was doing a *ton* of
work with the database on the event thread, so I moved it all to a RequestProcessor thread, including the call to
refreshChildren().  I could probably have fixed the bug by either calling notifyChange() or putting the call to
refreshChildren() on a background thread, but I thought it better to put the whole thing on a background thread while I
was at it.

Now that I'm thinking further about this, I suspect there are other places where we call refreshChildren() on the event
thread, and they'll get the same exception.

I'll talk to Rob about this, it would be good to should fix this in a more centralized place rather than having all the
actions need to know they need to call refreshChildren() on a background thread.