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 86942 - IDE hangs on renaming
Summary: IDE hangs on renaming
Status: VERIFIED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: Schema Tools (show other bugs)
Version: 5.x
Hardware: PC Windows XP
: P2 blocker (vote)
Assignee: Samaresh Panda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-11 15:10 UTC by Ivan Sidorkin
Modified: 2006-10-18 13:36 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
project (118.38 KB, application/x-compressed)
2006-10-11 16:06 UTC, Ivan Sidorkin
Details
thread dump (16.51 KB, text/plain)
2006-10-11 16:26 UTC, Ivan Sidorkin
Details
patch to prevent out of sync lock order (1.47 KB, patch)
2006-10-11 18:35 UTC, Chris Webster
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Sidorkin 2006-10-11 15:10:55 UTC
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
Comment 1 Nam Nguyen 2006-10-11 15:44:20 UTC
Can you please also attach thread dump.  Thanks.
Comment 2 Ivan Sidorkin 2006-10-11 16:06:51 UTC
Created attachment 35111 [details]
project
Comment 3 Ivan Sidorkin 2006-10-11 16:26:30 UTC
Created attachment 35113 [details]
thread dump
Comment 4 Nam Nguyen 2006-10-11 16:37:51 UTC
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?
Comment 5 Andrei Chistiakov 2006-10-11 17:12:21 UTC
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.
Comment 6 Nam Nguyen 2006-10-11 17:25:17 UTC
This issue is deadlock b/w AXI SchemaModelListener and background auto sync of
AXI model.  Reassign to Sam.
Comment 7 Andrei Chistiakov 2006-10-11 17:27:19 UTC
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).
Comment 8 Nam Nguyen 2006-10-11 17:38:13 UTC
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.
Comment 9 Chris Webster 2006-10-11 18:31:54 UTC
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. 



Comment 10 Chris Webster 2006-10-11 18:35:07 UTC
Created attachment 35118 [details]
patch to prevent out of sync lock order
Comment 11 Samaresh Panda 2006-10-11 22:31:42 UTC
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.
Comment 12 Samaresh Panda 2006-10-12 18:29:45 UTC
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.
Comment 13 Samaresh Panda 2006-10-12 18:48:35 UTC
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.
Comment 14 Samaresh Panda 2006-10-12 20:49:33 UTC
Fix integrated into release55_dev. Please take a look at the diff I provided
earlier.
Comment 15 htt 2006-10-13 07:32:39 UTC
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. 
Comment 16 Nam Nguyen 2006-10-13 16:48:24 UTC
The refactoring undo/redo only support the last refactoring event.  This is same
as the current behavior of NB refactoring.
Comment 17 Samaresh Panda 2006-10-13 17:55:33 UTC
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
Comment 18 Chris Webster 2006-10-14 02:27:12 UTC
diff looks good.
Comment 19 Samaresh Panda 2006-10-16 06:24:14 UTC
Integrated changes into release55.
AXIModelImpl.java: new revision: 1.1.2.42; previous revision: 1.1.2.41
Comment 20 Ivan Sidorkin 2006-10-18 13:36:26 UTC
verified in 061018_1