Bug 93668 - Search indexes not rebuild
Summary: Search indexes not rebuild
Status: CLOSED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-04 12:42 EDT by Dirk Baeumer CLA
Modified: 2005-06-10 06:08 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2005-05-04 12:42:33 EDT
N20050504-1000

I have a workspace where I reference external plug-ins via the PDE container
form my Eclipse installation. When I updated my eclipse installation form
N20050503-0010 to N20050504-1000 the search indices didn't get rebuild although
the content of core.resources did change. As a result I don't see the new types
which got added in internal.core.resources.mapping. Browsing to this package
shows that is exists and that the types are there.
Comment 1 Dirk Baeumer CLA 2005-05-04 12:43:14 EDT
To clarify: I don't see the types in the all type dialog which now queries them
from the index.
Comment 2 Kent Johnson CLA 2005-05-05 11:39:20 EDT
Reproduced.

The index for the jar file was not rebuilt.

Its timestamp has definitely changed so it should have been rebuilt... 
investigating.
Comment 3 Kent Johnson CLA 2005-05-05 11:55:48 EDT
If the plugins are imported as binary projects with linked content -> it works 
fine.

But I'm able to reproduce when the jar file is added to search by PDE, so that 
it shows up in the External Plug-in Libraries.
Comment 4 Kent Johnson CLA 2005-05-05 14:04:01 EDT
Dirk, how is the jar attached in your workspace?

Did you add it to Java Search using PDE?
Comment 5 Kent Johnson CLA 2005-05-05 16:38:51 EDT
I think we should also check consistency of indexes/builds after startup when 
you open the search dialog, as we do now with the open type dialog.
Comment 6 Kent Johnson CLA 2005-05-05 17:02:02 EDT
Jerome/Philippe : where do we detect external jar file changes? Or do we?

Cause it looks like we never reindex them.
Comment 7 Dirk Baeumer CLA 2005-05-06 05:10:06 EDT
I simply get the jars via the PDE container. I don't use the PDE magic for
adding stuff to the Java search.
Comment 8 Kent Johnson CLA 2005-05-06 12:46:27 EDT
It appears that an optimization to SetClasspathOperation is causing us to miss 
the changes to the external jar files.

We have 2 choices:

1. Take out the optimization

2. Or start recording the timestamp of the jar file in savedIndexNames.txt so 
we can rebuild the index ourselves when we first open it on startup.


My preference is to do #2 unless the optimization is causing problems 
elsewhere.
Comment 9 Kent Johnson CLA 2005-05-09 10:48:51 EDT
The optimization needs to be 'improved'

The builder & index manager rely on callbacks that external jar files have 
changed.
Comment 10 Jerome Lanneluc CLA 2005-05-10 06:06:27 EDT
Actually the optimization is not the culprit. I just verified that the problem
existed in 3.0 as well.
Comment 11 Jerome Lanneluc CLA 2005-05-11 06:26:54 EDT
Lowering priority since this is not a regression.
Comment 12 Kent Johnson CLA 2005-05-11 10:40:34 EDT
It may not be a regression BUT we would have never shipped 3.0 with this bug 
if we knew about it.
Comment 13 Philipe Mulet CLA 2005-05-11 13:17:07 EDT
We want to investigate a fix for 3.1rc1, I agree it is bad.
Comment 14 Jerome Lanneluc CLA 2005-05-18 10:35:27 EDT
Changed JavaCore#initializeAfterLoad() to force a refresh of all external jars.
Note this method needs to be called by JDT UI first to see the index beeing rebuild.
Also changed JavaBuilder#build(...) to refresh the external jars of the project
(only in the case of a full build triggered by the user).

Added regression tests ExternalJarsDeltaTests#testExternalJarChanged5() and
testExternalJarChanged6().
Comment 15 Dirk Baeumer CLA 2005-05-18 10:55:39 EDT
Jerome,

may be I am misunderstanding but IMO rebuilding the search indexes shouldn't be
coupled to initializeAfterLoad since there will be no guarantee that this method
will be called. My understanding is that this method is optional.
Comment 16 Jerome Lanneluc CLA 2005-05-18 11:03:01 EDT
There are now several ways to refresh external jars:
- refresh action
- full build
- initializeAfterLoad
All these actions have the nice characteristic that they don't run on startup
but later on. If JDT Core would force the refresh of external jars, it could
only be on startup. This would cause classpath resolution, and we would be back
to the state we had in 3.1 M6.
Comment 17 Dirk Baeumer CLA 2005-05-18 11:42:06 EDT
Are you saying that you never detect this case which makes the whole story of
PDE plug-in containers questionable. Shouldn't PDE then at least try to detect
this an trigger some action when they resolve the class path ?. 

I am a little bit affraid of putting all this into initializeAfterLoad since
this will result in the fact that we will not call it since it will be to
expensive as well. How expensive will the whole initializeAfterLoad now be ?
Comment 18 Jerome Lanneluc CLA 2005-05-18 12:03:36 EDT
We never detect automatically that external jars have changed whether they come
from the PDE container, the JRE container, a variable, or even if they are on
the raw classpath. This is true since at least 3.0.

The cost of initializeAfterLoad(...) will not be increased by this addition (or
this will not be noticeable).
Comment 19 Philipe Mulet CLA 2005-05-18 12:19:04 EDT
Kent - talking with Jerome, we need you to also protect both indexes and build
states reading with timestamp. There could be situations where
#initializeAfterLoad() wouldn't run (headless mode, or before jdt/ui opens).
Also if doing so, I wonder if a full build would need to force a refresh, since
it would likely occur for free, wouldn't it ?
Comment 20 Kent Johnson CLA 2005-05-18 12:37:04 EDT
I don't follow... why is a refresh necessary?

If the builder/indexer start detecting jar file timestamp changes, then the 
full build or rebuild of index files will happen whenever the user does a 
search or build... could be 10 minutes after startup.

What would be picked up by a refresh? What new/deleted resources did the 
workspace not know about?
Comment 21 Jerome Lanneluc CLA 2005-05-18 12:49:30 EDT
The external jars refresh will create Java deltas for jars that have changed,
and clients could benefit from these deltas.
Comment 22 Kent Johnson CLA 2005-05-18 13:29:53 EDT
What other clients are there?

And if the builder/indexer is responsible for detecting changes, why aren't 
these other clients also responsible?
Comment 23 Kent Johnson CLA 2005-05-18 13:37:09 EDT
Checked with JohnA & since the resource tree does not include external jar 
files, the default refresh doesn't find them & doesn't issue any deltas for 
them.

How are clients informed when they changed?
Comment 24 Philipe Mulet CLA 2005-05-18 18:03:51 EDT
The platform doesn't know about external JARs, which is the sole reason for this
issue to exist.

The normal way to discover JAR changes, is to perform a Java model refresh
operation (not platform). This broadcasts Java deltas as normal Java operations
for client of Java model APIs. Jerome hooked invocation of refresh in
#initializeAfterLoad API and full build.

If you do protect the build state, then he could remove the invocation from full
build. If you protect the indexes, these could be recreated lazily, but the
purpose of #initializeAfterLoad is to catch early situations where quite a few
tasks are required before giving full control to user. But, #initializeAfterLoad
is only optional, and is just a hint from client to indicate that now is an
appropriate time to perform inits (should still remain bound initialization
effort in normal cases). 

Having indexes be only recreated after 2 hours in the session (after being idle
for a long time) isn't very useful... unless we believe users will never use any
search/codeassist.
Comment 25 Kent Johnson CLA 2005-05-19 10:37:45 EDT
So who should the builder/indexer tell when they detect an external jar file 
has changed?

And will this cause an infinite loop if the builder/indexer remain clients of 
this notification?
Comment 26 Philipe Mulet CLA 2005-06-06 14:50:50 EDT
+1 for RC2
Comment 27 Kent Johnson CLA 2005-06-06 16:48:24 EDT
Added timestamps for external jars to the build state.

Will now check on every incremental build if any external jar file has been 
replaced.

Moving to Jerome so he can change the DelatProcessor to notice that a CLEAN 
build has started and perform a workspace wide refresh of external jars so 
index files are also rebuilt.
Comment 28 Kent Johnson CLA 2005-06-06 16:50:30 EDT
I left the call in the JavaBuilder.build method until the DeltaProcessor 
changes are made.

Also the DeltaProcessor is still nulling out the build state in 
checkExternalArchiveChanges()
Comment 29 Jerome Lanneluc CLA 2005-06-07 06:09:40 EDT
Removed the call that was nulling out the delta state in DeltaProcessor.
Removed the call to force a refresh on full build in JavaBuilder. The
DeltaProcessor was actually alreay handling the case.
Updated ExternalJarDeltaTests#testExternalJarChange6().
Comment 30 Maxime Daniel CLA 2005-06-07 13:39:23 EDT
Verified for 3.1 RC2 using build N20050607-0010 +JDT/Core HEAD.
Comment 31 Olivier Thomann CLA 2005-06-07 13:41:26 EDT
Verified.
Comment 32 Frederic Fusier CLA 2005-06-10 06:08:51 EDT
Verified for 3.1 RC2 using build I20050610-0010