Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-4308

Deadlock in DB Editor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 11.2
    • 12.1
    • db - Code
    • None

    Description

      Observed on Windows was, that netbeans froze after closing the SQL editor window. With visualvm a threaddump could be generated (attached). The relevant part:

      "AWT-EventQueue-0" #24 prio=6 os_prio=0 cpu=21437.50ms elapsed=1431.16s tid=0x000000002acf8000 nid=0x4cf0 in Object.wait()  [0x000000002ce59000]
         java.lang.Thread.State: WAITING (on object monitor)
              at java.lang.Object.wait(java.base@11.0.4/Native Method)
              - waiting on <no object reference available>
              at java.lang.Object.wait(java.base@11.0.4/Object.java:328)
              at org.openide.util.Task.waitFinished(Task.java:110)
              - waiting to re-lock in wait() <0x00000000e5da9c40> (a org.openide.util.RequestProcessor$Task)
              at org.openide.util.RequestProcessor$Task.waitFinished(RequestProcessor.java:1672)
              at org.openide.text.DocumentOpenClose.waitForCloseFinish(DocumentOpenClose.java:283)
              at org.openide.text.DocumentOpenClose.isDocumentLoadedOrLoading(DocumentOpenClose.java:289)
              at org.openide.text.CloneableEditorSupport.isDocumentLoaded(CloneableEditorSupport.java:1202)
              at org.openide.text.EditorSupportLineSet$SupportLine.show(EditorSupportLineSet.java:82)
              at org.netbeans.modules.db.sql.loader.SQLExecutionLoggerImpl$Hyperlink.goToLine(SQLExecutionLoggerImpl.java:275)
              at org.netbeans.modules.db.sql.loader.SQLExecutionLoggerImpl$Hyperlink.outputLineSelected(SQLExecutionLoggerImpl.java:260)
              at org.netbeans.core.output2.OutputTab.caretPosChanged(OutputTab.java:401)
              at org.netbeans.core.output2.OutputPane.caretPosChanged(OutputPane.java:52)
              at org.netbeans.core.output2.ui.AbstractOutputPane.maybeSendCaretEnteredLine(AbstractOutputPane.java:580)
              at org.netbeans.core.output2.ui.AbstractOutputPane.stateChanged(AbstractOutputPane.java:556)
              at javax.swing.text.DefaultCaret.fireStateChanged(java.desktop@11.0.4/DefaultCaret.java:812)
              at javax.swing.text.DefaultCaret.changeCaretPosition(java.desktop@11.0.4/DefaultCaret.java:1283)
              at javax.swing.text.DefaultCaret.handleSetDot(java.desktop@11.0.4/DefaultCaret.java:1182)
              at javax.swing.text.DefaultCaret.setDot(java.desktop@11.0.4/DefaultCaret.java:1163)
              at javax.swing.text.DefaultCaret.setDot(java.desktop@11.0.4/DefaultCaret.java:1060)
              at javax.swing.text.DefaultCaret$Handler.propertyChange(java.desktop@11.0.4/DefaultCaret.java:1883)
              at java.beans.PropertyChangeSupport.fire(java.desktop@11.0.4/PropertyChangeSupport.java:341)
              at java.beans.PropertyChangeSupport.firePropertyChange(java.desktop@11.0.4/PropertyChangeSupport.java:333)
              at java.beans.PropertyChangeSupport.firePropertyChange(java.desktop@11.0.4/PropertyChangeSupport.java:266)
              at java.awt.Component.firePropertyChange(java.desktop@11.0.4/Component.java:8728)
              at javax.swing.text.JTextComponent.setDocument(java.desktop@11.0.4/JTextComponent.java:456)
              at org.netbeans.core.output2.OutputPane.setDocument(OutputPane.java:109)
              at org.netbeans.core.output2.ui.AbstractOutputTab.setDocument(AbstractOutputTab.java:58)
              at org.netbeans.core.output2.OutputTab.setDocument(OutputTab.java:166)
              at org.netbeans.core.output2.OutputTab.closed(OutputTab.java:341)
              at org.netbeans.core.io.ui.IOWindow$IOWindowImpl.removeTab(IOWindow.java:357)
              at org.netbeans.core.io.ui.IOWindow.remove(IOWindow.java:98)
              at org.openide.windows.IOContainer.remove(IOContainer.java:139)
              at org.netbeans.core.output2.Controller.performCommand(Controller.java:356)
              at org.netbeans.core.output2.Controller.eventDispatched(Controller.java:83)
              at org.netbeans.core.output2.IOEvent.dispatch(IOEvent.java:256)
              at org.netbeans.core.output2.NbIO.post(NbIO.java:271)
              at org.netbeans.core.output2.NbIO.post(NbIO.java:260)
              at org.netbeans.core.output2.NbIO.closeInputOutput(NbIO.java:100)
              at org.netbeans.modules.db.sql.loader.SQLExecutionLoggerImpl.close(SQLExecutionLoggerImpl.java:99)
              at org.netbeans.modules.db.sql.loader.SQLEditorSupport.closeLogger(SQLEditorSupport.java:487)
              - locked <0x00000000ccf40d10> (a java.lang.Object)
              - locked <0x00000000ccf3f7b0> (a org.netbeans.modules.db.sql.loader.SQLEditorSupport)
              at org.netbeans.modules.db.sql.loader.SQLEditorSupport.notifyClosed(SQLEditorSupport.java:251)
              at org.openide.text.CloneableEditor.closeLast(CloneableEditor.java:341)
              - locked <0x00000000ccf7a0a0> (a [Z)
              at org.netbeans.modules.db.sql.loader.SQLCloneableEditor.closeLast(SQLCloneableEditor.java:588)
              [...]
      
         Locked ownable synchronizers:
              - None
      
      "org.openide.text Document Processing" #135 daemon prio=1 os_prio=-2 cpu=31.25ms elapsed=97.70s tid=0x000000003ee8c800 nid=0x4514 waiting for monitor entry  [0x0000000060dae000]
         java.lang.Thread.State: BLOCKED (on object monitor)
              at org.openide.text.CloneableEditorSupport.getUndoRedo(CloneableEditorSupport.java:326)
              - waiting to lock <0x00000000ccf3f7b0> (a org.netbeans.modules.db.sql.loader.SQLEditorSupport)
              at org.openide.text.DocumentOpenClose$DocumentClose.readLockedRun(DocumentOpenClose.java:992)
              at org.openide.text.DocumentOpenClose$DocumentClose.run(DocumentOpenClose.java:939)
              at org.netbeans.editor.BaseDocument.render(BaseDocument.java:1402)
              at org.openide.text.DocumentOpenClose$DocumentClose.run(DocumentOpenClose.java:958)
              at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
              at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
              at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
              at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
      
         Locked ownable synchronizers:
              - None
      

      So the SQLEditorSupport monitor is held by the EDT, during the closing operation a task is created that is dispatched to a request processor, that task needs to acquire the monitor on SQLEditorSupport and the processing in the EDT waits for the task to finish.

      Possible solution: remove the synchronization in SQLEditorSupport#closeLogger. The cirtical part (ensuring logger is not closed while it could be acquired) is protected by the finer grained oggerLock` and thus the monitor of SQLEditorSupport is not needed.

      Attachments

        1. threaddump.txt
          57 kB
          Matthias Bläsing

        Activity

          People

            matthiasblaesing Matthias Bläsing
            matthiasblaesing Matthias Bläsing
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m