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 209720

Summary: Locked by DB IO Exception
Product: db Reporter: pragalathan <pragalathan>
Component: SQL EditorAssignee: Jaroslav Havlin <jhavlin>
Status: RESOLVED FIXED    
Severity: normal CC: KhArtNJava
Priority: P3 Keywords: NETFIX
Version: 7.2   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 186000
Attachments: stacktrace
proposed patch v1
stacktrace

Description pragalathan 2012-03-19 08:47:50 UTC
Build: NetBeans IDE Dev (Build 201203180400)
VM: Java HotSpot(TM) 64-Bit Server VM, 20.5-b03, Java(TM) SE Runtime Environment, 1.6.0_30-b12
OS: Linux

User Comments:
pragalathan: SQL query editor is opened and I was about to execute an SQL




Stacktrace: 
java.lang.Throwable: Locked by:
   at org.openide.filesystems.FileLock.<init>(FileLock.java:85)
   at org.openide.filesystems.MultiFileObject$MfLock.<init>(MultiFileObject.java:1681)
   at org.openide.filesystems.MultiFileObject.lock(MultiFileObject.java:712)
   at org.openide.filesystems.FileObject.getOutputStream(FileObject.java:732)
   at org.netbeans.modules.db.sql.history.SQLHistoryManager.save(SQLHistoryManager.java:155)
   at org.netbeans.modules.db.sql.execute.SQLExecuteHelper.execute(SQLExecuteHelper.java:153)
Comment 1 pragalathan 2012-03-19 08:47:52 UTC
Created attachment 116851 [details]
stacktrace
Comment 2 Exceptions Reporter 2012-06-14 22:22:49 UTC
This bug already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=186000
Comment 3 matthias42 2012-06-16 12:00:58 UTC
Created attachment 120934 [details]
proposed patch v1

The attached patch moves saving into a seperate task that is invoked with a delay of 5 seconds. As save is called anytime an sql is executed, this should save some performance.
The task implicitly serializes saving and so locking problems should be minimized.
To prevent data loss on jvm shutdown a shutdown hook is added, that checks whether there are unsave changes and flushes these out.
Comment 4 Exceptions Reporter 2012-06-26 11:29:06 UTC
Created attachment 121356 [details]
stacktrace

Clicked on View Data in the DB table context menu.
Comment 5 Jaroslav Havlin 2012-09-24 13:44:52 UTC
Thank you very much. Great job, Matthias.
I've only slightly modified the test case, because Thread.sleep can cause problems when the tests are run on a Hudson builder.
Integrated as http://hg.netbeans.org/core-main/rev/13832fcf1769
Comment 6 Quality Engineering 2012-09-25 02:18:07 UTC
Integrated into 'main-golden', will be available in build *201209250001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/13832fcf1769
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #209720: Locked by DB IO Exception