cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Fiol BonnĂ­n <antonio.f...@gmail.com>
Subject Re: Strange caching issue: need to reload twice
Date Mon, 07 Nov 2005 12:03:49 GMT
> 2005/11/3, Sylvain Wallez <sylvain@apache.org>:
> > Hmm... could this be related to the refresh delay of the directory
> > generator[1]?
> >
> > What happens if you add <map:parameter name="refreshDelay" value="0"/>
> > in the <generate type="directory"> ?
>
> Sylvain, we tested value="0", and got the same effect.
>
> Going slightly further, we tried with value="-1", and amazingly
> enough, it worked.
>
> AFAICS, this must be a bug somewhere, as Cocoon is not refreshing at
> the first attempt even after an amount of time far longer than one
> second (except with value="-1"). We have little knowledge on Cocoon
> internals, but we were looking into the DirectoryGenerator (and
> DirValidity) and found nothing strange.


Hello,

I finally found something strange in DirectoryGenerator that could
explain the bug. In DirValidity we added some traces:

        public int isValid() {
            if (System.currentTimeMillis() <= expiry) {
                logger.debug(this + ": isValid() ==> 1 (not expired)");
                return 1;
            }

            expiry = System.currentTimeMillis() + delay; /* *****
SHOULD THIS LINE BE REMOVED? !!! ***** */
            int len = files.size();
            for (int i = 0; i < len; i++) {
                File f = (File)files.get(i);
                if (!f.exists()) {
                    logger.debug(this + ": isValid() ==> -1 (file
"+f+" removed)");
                    return -1; // File was removed
                }

                long oldDate = ((Long)fileDates.get(i)).longValue();
                long newDate = f.lastModified();

                if (oldDate != newDate) {
                    logger.debug(this + ": isValid() ==> -1 (different
dates for "+f+": "+oldDate+"!="+newDate+")");
                    return -1;
                }
            }

            // all content is up to date: update the expiry date
            expiry = System.currentTimeMillis() + delay;
            logger.debug(this + ": isValid() ==> 1 (all valid)");
            return 1;
        }


I think the tagged line should be removed. I can't see why it is
there, and I think it is responsible for the harm. When reloading
after changing a file, we get:

[sitemap.generator.directory]
org.apache.cocoon.generation.DirectoryGenerator$DirValidity@f4d063
Expiry: 1131363743861 - Delay: 1000: isValid() ==> -1 (different dates
for /home/fiol/ficheros-intranet/compartido/paginas/actualidad/resumen-noticias:
1131037742000!=1131363738000)
[sitemap.generator.directory]
org.apache.cocoon.generation.DirectoryGenerator$DirValidity@f4d063
Expiry: 1131363743861 - Delay: 1000: isValid() ==> 1 (not expired)

So apparently isValid is called twice, with inconsistent results
(first is OK, second is wrong, unless *I* am wrong ;-).

Aside from that, is the recycle method called before calling
generate() if cache is invalid? Supposing it is not, how is the
DirValidity refreshed with new files? More specifically, how are old
ones removed? There is no point in the code where this.validity is
made null other than the recycle method.

As I told you, I know very little about Cocoon internals, but there
seems to be something broken here.

--
Antonio

Mime
View raw message