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 148489 - Message appears all the time and prevents from work
Summary: Message appears all the time and prevents from work
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: MySQL (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: David Vancouvering
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2008-09-26 14:00 UTC by Roman Mostyka
Modified: 2008-09-30 13:18 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE's log file. (78.84 KB, text/plain)
2008-09-26 14:01 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-09-26 14:00:32 UTC
1. Add connection to MySQL DB, but uncheck "Save Password" checkbox.
2. Disconnect, then connect, specify valid password and click "OK".

Result: "Unable to add connection. Connection already exists." message appears and then it starts to appears all the
time and only one way to stop it is to restart NetBeans.
Comment 1 Roman Mostyka 2008-09-26 14:01:03 UTC
Created attachment 70672 [details]
IDE's log file.
Comment 2 Rob Englander 2008-09-26 15:50:14 UTC
David, you beat me to it.  You're fast so early in the morning.
Comment 3 Rob Englander 2008-09-26 15:55:28 UTC
Don't know why my comment changed the TM.  I'm putting it back.
Comment 4 David Vancouvering 2008-09-26 19:49:30 UTC
The repeating error message is because the logic to add a connection is fired again and again, each time causing the
same exception.

If I have it right, the loop is caused by this:

- We run the DatabaseConnection.doConnect() method on a request processor thread

- This fires the "connected" property change event

- This calls the property change listener in ConnectUsingDriverAction.java, in the PropertyChangeListener.

- Here, when the event is "connected" we first call "fireConnectionFinished" and then attempt to add the connection to
the RootNodeInfo

- the attempt to add the connection fails with a "connection already exists"

- The "connected" property change event then invokes the next listener, which is ConnectionNodeInfo.  This listener
tries to attach the CNI to the new active JDBC connection.  This includes calling getSpecification

- getSpecification() notices that there is no connection (it never got set up) and calls createJDBCConnection() to open
the connection

- This fires the "connected" property change, which sends us around the circle again

- meanwhile fireConnectionFinished causes ConnectionNodeInfo.finishConnect() to be called, which calls
createSpecification() which then notices the connection is not valid and thus calls createJDBCConnection()

, which create a *whole new connection" to the database
Comment 5 David Vancouvering 2008-09-26 19:51:23 UTC
Sorry, some typos in the last comment.  I'll rewrite here, fixing the typos so it's more clear:

The repeating error message is because the logic to add a connection is fired again and again, each time causing the
same exception.

If I have it right, the loop is caused by this:

- We run the DatabaseConnection.doConnect() method on a request processor thread

- This fires the "connected" property change event

- This calls the property change listener in ConnectUsingDriverAction.java.

- Here, when the event is "connected" we first call "fireConnectionFinished" and then attempt to add the connection to
the RootNodeInfo

- the attempt to add the connection fails with a "connection already exists"

- The "connected" property change event then invokes the next listener, which is ConnectionNodeInfo.  This listener
tries to attach the CNI to the new active JDBC connection.  This includes calling getSpecification

- getSpecification() notices that there is no connection (it never got set up) and calls createJDBCConnection() to open
the connection

- This fires the "connected" property change, which sends us around the circle again

Comment 6 David Vancouvering 2008-09-26 22:10:58 UTC
Sigh, can't reproduce on my machine.  Why is it all these things are happening for Roman and not for me?
Comment 7 Roman Mostyka 2008-09-29 10:54:46 UTC
Probably because I have magic machine. :)
Comment 8 David Vancouvering 2008-09-29 17:53:05 UTC
411fdef62a9c

The reason this reared its ugly head I am pretty sure is because we are now holding on to existing infos across
connect/disconnect.  The NewConnectionFromDriver action added a connection listener but never removed it.  This was fine
before when we deleted the CNI on a disconnect, but now that the CNI is retained, the listener attached to it is also
retained.  This meant it fired when the user reconnects and tries to add the connection, but the connection is already
added.

Then the connection listener for the connect action fires, and the DriverSpecification detects the connection is null,
and tries to create it, and we get into the infinite loop scenario; this won't happen now that I remove the old
connection listener from the NewConnectionFromDriver dialog.

It makes me think we have the risk of some other memory leaks across multiple connect/disconnects; I'll ask Roman to see
if there is some memory testing he can do.
Comment 9 Quality Engineering 2008-09-30 06:09:38 UTC
Integrated into 'main-golden', will be available in build *200809300201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/411fdef62a9c
User: David Van Couvering <davidvc@netbeans.org>
Log: #148489: Message appears all the time and prevents from work
Also a little cleanup of logging and message formatting
Comment 10 Roman Mostyka 2008-09-30 13:18:23 UTC
Verified with build 080930.
Good job, David.