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.
build 061010 jdk 1.6 - open attached project - open OTA_TravelItinerary.xsd - in Schema view select Elements->CancellationStatus - in context menu for CancellationStatus select Refactor->Rename - type new name, press Next button. Press Do Refactor button - rename ItineraryRef - rename OTA_TravelItineraryRS - rename OTA_TravelItineraryReadRQ - try to rename TPA_Extension after pressing Do Refactor IDE shows Refactoring dialog and hangs
Can you please also attach thread dump. Thanks.
Created attachment 35111 [details] project
Created attachment 35113 [details] thread dump
I cannot reproduce this with the test case: basically I did refactor rename on each of the global elements from top to bottom. Is this right? What is the test case reproducibility?
I've also reproduced this issue. Although I couldn't reproduce it with arbitrary OTA schema, I did reproduce the issue using the attached project and OTA schema opened from there.
This issue is deadlock b/w AXI SchemaModelListener and background auto sync of AXI model. Reassign to Sam.
My guess is that the issue is reproducible exactly on TPA_Extension node because of quite a big number (49) of usages found for it. Issue occurence depends on the moment when 'Do Refactor' is pushed and how long it takes to display the diagram. Looks like the issue appears if 'Do Refactor' is pressed during the diagram is being displayed with animation effect (while the animation is in progress).
Just comment. This issue is independent of refactoring. Based on this stack, my guess is we might be able to reproduce the issue by writing AXI model unit test that loop through for more than 2 secs keep mutating schema model.
The issue here is that AXIModel sync locks the schema model during it's sync. Howwever, this lock ordering is different than the lock ordering during event firing. A schema model fires events, which requires that AXI model locks to change it's need sync status. The fix should be something like the diff I attached, where the schema model sync is run before the AXIModel is locked. See attached patch. Also, A unit test like the following would surface the issue: Start schema model transaction - Thread 1 create some change to schema model - Thread 1 Create a listener and add to schema model - the listener will sleep for 3 seconds Create AXImodel - Thread 1 end schema model transaction - Thread 1 -- will sleep while notifying listeners AXIModel.sync - Thread 2 - axi model will be locked, and this thread will wait to lock the schema model. Once the long listener wakes up, the axi model will be called to update the sync status, which will require acquiring a lock on axi but this will not be possible as AXI is locked in thread 2. Hence the deadlock. I am attaching a patch for a potential fix, but please create this scenario as a unit test first.
Created attachment 35118 [details] patch to prevent out of sync lock order
There are two issues here. 1. Deadlock: we can fix it in our code. The fix is, not to run autosync for AXIModel if schema model is in sync or in transaction. 2. CPU is 100% occupied, even after the fix. This is related to issue http://www.netbeans.org/issues/show_bug.cgi?id=75588, we filed earlier. I do not think the http://www.netbeans.org/issues/show_bug.cgi?id=75588 has been resolved completely. After my fix, I can see that IDE is unresponsive for quite some time.
Fix integrated: http://xml.netbeans.org/source/browse/xml/axi/src/org/netbeans/modules/xml/axi/impl/AXIModelImpl.java?r1=1.1.2.31.2.6&r2=1.1.2.31.2.7 Unit test (SyncDeadlockTest) has also been added. However, as I said earlier, the IDE still appears hanging. This is due to http://www.netbeans.org/issues/show_bug.cgi?id=75588.
You'll see a message "Refactoring Completed" at the bottom left corner of the IDE . CPU will be 100% occupied for about 10-15min. If you wait for 10-15min., the IDE comes back to normalcy. I can see a lot of debug messages being printed on the console.
Fix integrated into release55_dev. Please take a look at the diff I provided earlier.
Verified in 'patch' build 061012_7 (from release55_dev). Observed neither deadlock nor IDE hang; however, not sure whether this is already known: after successfully renaming TPA_Extension, backtrack and attempt a few Undo [Rename]. Pick any element (that was renamed) and invoke Refactoring > Undo [Rename] -> the Undo applies to TPA_Extension. Pick any other renamed elements and invoke Refactoring -> the only option is Redo [Rename]. Select it and observe that again it is TPA_Extension that is re-renamed. Seems Refactoring retains only the 'rename' activity on the last item.
The refactoring undo/redo only support the last refactoring event. This is same as the current behavior of NB refactoring.
It appears that the last fix created a new sideeffect which was described in http://www.netbeans.org/issues/show_bug.cgi?id=86941. Integrated another fix in release55_dev: http://xml.netbeans.org/source/browse/xml/axi/src/org/netbeans/modules/xml/axi/impl/AXIModelImpl.java?r1=1.1.2.31.2.7&r2=1.1.2.31.2.8
diff looks good.
Integrated changes into release55. AXIModelImpl.java: new revision: 1.1.2.42; previous revision: 1.1.2.41
verified in 061018_1