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 73679 - Corrupted MDR storage causes silent failure of code completion
Summary: Corrupted MDR storage causes silent failure of code completion
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 5.x
Hardware: All All
: P1 blocker (vote)
Assignee: issues@java
URL:
Keywords: UMBRELLA
: 68998 73157 74271 78861 82411 (view as bug list)
Depends on: 51069 57811 64240 68795 68805 68998 70400 70437 70624 71039 71520 71537 71705 71988 72311 73065 73690 74490 75032 75306 75368
Blocks:
  Show dependency tree
 
Reported: 2006-03-16 19:58 UTC by _ tboudreau
Modified: 2007-09-26 09:14 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IOE (1.41 KB, text/plain)
2006-03-28 11:03 UTC, Jiri Prox
Details
JBoss Seam JAR (330.87 KB, application/octet-stream)
2006-06-22 17:42 UTC, William Leonard
Details
JBoss Seam UI JAR (37.02 KB, application/octet-stream)
2006-06-22 17:43 UTC, William Leonard
Details
RegistrationInterceptorAnnotation Project (947.90 KB, application/octet-stream)
2006-06-22 17:44 UTC, William Leonard
Details
RegistrationReset Project (42.28 KB, application/octet-stream)
2006-06-22 17:45 UTC, William Leonard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2006-03-16 19:58:28 UTC
It is very frequent in the field to end up with a corrupted MDR cache.  I 
recently visited one customer site, where a developer told me that NetBeans 
code completion didn't work.  He showed me - System. produced "no suggestions".

It turned out that his MDR cache was corrupted - I was able to fix the problem 
by deleting the cache.  

I frequently get into this state myself - it's difficult to say what is the 
triggering event.  But it is much worse when a user gets into this state 
because
 - In a release build, the only indication that something is wrong is the 
flashing error icon
   - If the user did click it, they'd see a stack trace for an 
InvalidObjectException - they would have to search the web really well to 
discover that the fix was to delete $USERDIR/var/cache/mdrstorage
   - After that, code completion is simply broken, but it's not obvious that 
anything is wrong
 - A new user is likely to simply think NetBeans code completion doesn't 
actually work.  This makes a very bad impression - possibly worse than visibly 
buggy software (some indication of failure) is software that looks like it 
never worked to begin with.

MDR storage needs to be made self-repairing, regardless of whether we know all 
the root causes of this problem or not.  It is too easy for a user to randomly 
get into this situation, and no clear way to recover from it whatsoever.

I've made the (admittedly horrible) suggestion of a watchdog timer that, when 
the application is active, checks if the completions of "System." 
include "in", and deletes the MDR cache and initiates a rescan if that test 
fails.  That's horribly ugly, and a really horrible way to do it - so better 
ideas would be great (maybe the constructor of an InvalidObjectException 
triggers an integrity check?).  The one advantage of a watchdog system is that 
it is cheap to write and will solve the problem, and doesn't require large 
engineering investment in code we know will be defunct after 5.5.

I don't think this can wait for 6.0.  We are seeing it on customer visits, the 
problem happens to us when we're doing demos on stage, and users cannot 
recover from the situation.  The IDE has enough information to know when the 
storage is corrupted, and rebuild it.
Comment 1 Jan Becicka 2006-03-17 08:39:46 UTC
I cannot agree with Tims suggestion. InvalidObjectException is not detection,
that MDR is corrupted. This exception might be thrown due to incorrect usage of
Java Model APIs. BTW Some kind of rescanning is already implemented (File |
Refresh All Files)

I suppose, that Code Completion stops working, because some source is broken in
terms of javac refuses to give correct data into MDR and the storage get's
corrupted. But I beleive, that it's corrupted just for the broken file or broken
file and all files related to this file. There are many problems with javac
error recovery, which can be hardly fixed for NB 5.5.

It is even possible (and I don't blame anyone - just trying not to overlook
something), that the MDR is not corrupted, or better told it is not corrupted
fatally - it is corrupted just for the broken file. And code completion fails to
show results because e.g. it can iterate through some MDR collection and just
one Element is broken, while the others are correct - but code completion still
does not show anything. Just guessing.

Things, that must be detected:
1. Can we reproduce this bug on tinny project?
2. If Code Completion stops working, currently edited file is broken -> What
happens, when all compilation errors are fixed? -> will the code completion
start to work again?
3. When the code completion doesn't work -> does it mean that it doesn't work
just for one file? Or for all files within given project? Or within whole IDE?
4. Does File | Refresh All Files fix the problem?

BTW I added dependencies to all InvalidObjectException reports.
Comment 2 Jan Becicka 2006-03-27 12:38:12 UTC
BTW see 65815. It also can cause, that code completion does not work. The fix of
65815 is in trunk, but not in 5.5
Comment 3 Jiri Prox 2006-03-28 11:01:21 UTC
Reproducible testcase for IOE from MDR:
1) start with fresh userdir
2) open NB sources (tested with Java module)
3) open some class
4) add inner class:
   class Inner {
   
   }
5) wait for the sources to be parsed
6) delete inner class
7) place caret to different position
8) write class In and invoke CC
9) write rest of the word Inner
-> IOE

the steps 6) - 8) should be performed quicky to avoid parsing the sources.
If the exception does not occurre try opening more NB modules.

Tested with NB 5.0 fcs , 6.0 200627030859
Linux, WinXP
JDK 1.6.0b77, 1.5.0_06
Comment 4 Jiri Prox 2006-03-28 11:03:47 UTC
Created attachment 29442 [details]
IOE
Comment 5 Jan Becicka 2006-03-28 11:10:21 UTC
Is the MDR storage corrupted after IOE? Does Code Completion stop working after IOE?
Comment 6 Jiri Prox 2006-03-28 11:27:05 UTC
The CC is working, this is only a way how to get an exception from MDR.
I've posted it here since this is umbrella for InvalidObjectException reports.
Comment 7 Tomas Hurka 2006-03-28 11:58:27 UTC
Next time please create separate issue and attach _whole_ message.log not just exception. message.log 
can contain valuable information to track down this type of bug. Thanks.
Comment 8 Jan Becicka 2006-03-28 12:40:11 UTC
The issue jiriprox described is similar to issue 70437. It is not critical. Dan
will look at it.
Comment 9 Daniel Prusa 2006-03-28 14:37:59 UTC
InvalidObjectException mentioned above fixed in trunk. A check for jmi object
validity was missing in the related source code. This exception is not somehow
extraordinary and should not break mdr storage consistency.

/cvs/java/editor/src/org/netbeans/modules/editor/java/JMIUtils.java
new revision: 1.48; previous revision: 1.47
Comment 10 Jan Becicka 2006-03-30 16:11:56 UTC
*** Issue 73157 has been marked as a duplicate of this issue. ***
Comment 11 Jan Becicka 2006-04-14 08:38:33 UTC
I guess, that issue 75032 is the root cause. Just guessing.
Comment 12 Jan Becicka 2006-05-04 14:44:32 UTC
*** Issue 74271 has been marked as a duplicate of this issue. ***
Comment 13 Jan Becicka 2006-06-07 12:24:31 UTC
Checking in FileScanner.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/scanning/FileScanner.java,v
 <--  FileScanner.java
new revision: 1.27; previous revision: 1.26
done

The problem was in different timezones: when preparsed storage was created in
different timezone, it's timestamp was not >= than timestamp of jar.
Thanks to thurka and psuchomel for identifying the problem.

Comment 14 Jiri Prox 2006-06-12 15:30:30 UTC
Verified in 200606081800, can be merged to 5.5 branch.
Comment 15 Jan Becicka 2006-06-14 10:10:33 UTC
Checking in FileScanner.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/scanning/FileScanner.java,v
 <--  FileScanner.java
new revision: 1.26.28.1; previous revision: 1.26
done
Comment 16 Jiri Prox 2006-06-19 14:56:43 UTC
Verified. NB 5.5 200606160200 
Comment 17 William Leonard 2006-06-22 17:41:35 UTC
I just tested this on the 20060619 build and I can still corrupt the MDR storage
following these steps (sorry, they're complicated, but reproducable):

1) Download and install JBoss 4.0.4 GA and add the JBoss Server to NetBeans.
2) Create 2 class libraries using the attached jar files:
   - JBossSeam - jboss-seam.jar
   - JBossSeamUI - jboss-seam-ui.jar

3) Unzip the attached RegistrationInterceptorAnnotation.zip and open the
project. Allow the classpath scanning to finish. Close the project and close
NetBeans.

4) Delete the project folder (regisration).

5) Unzip the attached RegistrationReset.zip
6) Start NetBeans and open the Registration project again.
7) Open User.java and try to add an annotation @Name at the top of the class
file. You'll get the InvalidObjectException and code completion will no longer work.
Comment 18 William Leonard 2006-06-22 17:42:50 UTC
Created attachment 31318 [details]
JBoss Seam JAR
Comment 19 William Leonard 2006-06-22 17:43:21 UTC
Created attachment 31319 [details]
JBoss Seam UI JAR
Comment 20 William Leonard 2006-06-22 17:44:29 UTC
Created attachment 31320 [details]
RegistrationInterceptorAnnotation Project
Comment 21 William Leonard 2006-06-22 17:45:13 UTC
Created attachment 31321 [details]
RegistrationReset Project
Comment 22 William Leonard 2006-06-22 18:52:33 UTC
Opened as issue 78916 instead.
Comment 23 Jan Becicka 2006-07-13 12:55:30 UTC
*** Issue 68998 has been marked as a duplicate of this issue. ***
Comment 24 Jan Becicka 2006-07-13 13:29:31 UTC
*** Issue 78861 has been marked as a duplicate of this issue. ***
Comment 25 Jan Becicka 2006-08-11 12:26:35 UTC
*** Issue 82411 has been marked as a duplicate of this issue. ***
Comment 26 Quality Engineering 2007-09-20 09:55:58 UTC
Reorganization of java component