You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Werner Baumann <we...@onlinehome.de> on 2007/12/28 11:46:47 UTC

Re: thoughts on ETags and mod_dav

Paritosh Shah wrote:
 > Another possible approach would be to create a new
 > ap_meets_conditions_2() with resource_exists as an explicit argument (
 > instead of implicitly using r->notes ). Till the next major release we
 > could just make the current ap_meets_conditions() call
 > ap_meets_conditions_2() with resource_exists as 1. Later we can make
 > ap_meets_conditions_2() the default ap_meets_conditions().
This seems to be the best way to fix this bug.

I proposed a solution for the Etag-problem, please see
http://issues.apache.org/bugzilla/show_bug.cgi?id=42987

But I am really frustrated about how this problem is handled by the 
Apache developers.

Happy New Year nonetheless
Werner

Re: [PATCH] Re: thoughts on ETags and mod_dav

Posted by Michael Clark <mi...@metaparadigm.com>.
Michael Clark wrote:
> Patch below makes mod_dav consistent with the format in http_etag.c
> and fixes the cond_put regression with litmus
>
> Index: modules/dav/fs/repos.c
> ===================================================================
> --- modules/dav/fs/repos.c    (revision 607400)
> +++ modules/dav/fs/repos.c    (working copy)
> @@ -1777,10 +1777,10 @@
>         return apr_pstrdup(ctx->pool, "");
>
>     if (ctx->finfo.filetype != 0) {
> -        return apr_psprintf(ctx->pool, "\"%lx-%lx-%lx\"",
> -                           (unsigned long) ctx->finfo.inode,
> -                           (unsigned long) ctx->finfo.size,
> -                           (unsigned long) ctx->finfo.mtime);
> +        return apr_psprintf(ctx->pool, "\"%llx-%llx-%llx\"",
> +                           (apr_uint64_t) ctx->finfo.inode,
> +                           (apr_uint64_t) ctx->finfo.size,
> +                           (apr_uint64_t) ctx->finfo.mtime);
>     }
>
>     return apr_psprintf(ctx->pool, "\"%lx\"", (unsigned long) 
> ctx->finfo.mtime);

Oh, and the mtime only case needs to be changed also.


[PATCH] Re: thoughts on ETags and mod_dav

Posted by Michael Clark <mi...@metaparadigm.com>.
While on the topic of ETags - I just picked up this regression in 2.2.7-dev

Some innocuous changes to make ETags always 64bit in modules/http/http_etag.c
broke DAV due to it's private dav_fs_getetag routine (ETags never matched
in ap_meets_condition due to the different format).

Patch below makes mod_dav consistent with the format in http_etag.c
and fixes the cond_put regression with litmus
 
Picked this up today while running litmus against 2.2.6 and 2.2.7-dev.

I've filed a bug. Would be nice to get this verified and in before 2.2.7

Index: modules/dav/fs/repos.c
===================================================================
--- modules/dav/fs/repos.c	(revision 607400)
+++ modules/dav/fs/repos.c	(working copy)
@@ -1777,10 +1777,10 @@
         return apr_pstrdup(ctx->pool, "");
 
     if (ctx->finfo.filetype != 0) {
-        return apr_psprintf(ctx->pool, "\"%lx-%lx-%lx\"",
-                           (unsigned long) ctx->finfo.inode,
-                           (unsigned long) ctx->finfo.size,
-                           (unsigned long) ctx->finfo.mtime);
+        return apr_psprintf(ctx->pool, "\"%llx-%llx-%llx\"",
+                           (apr_uint64_t) ctx->finfo.inode,
+                           (apr_uint64_t) ctx->finfo.size,
+                           (apr_uint64_t) ctx->finfo.mtime);
     }
 
     return apr_psprintf(ctx->pool, "\"%lx\"", (unsigned long) ctx->finfo.mtime);



Re: thoughts on ETags and mod_dav

Posted by Henrik Nordström <he...@henriknordstrom.net>.
lör 2007-12-29 klockan 20:56 +0100 skrev Werner Baumann:

> Objections:
> - Squid seems not to take any information from the Etag.

Yes it does. It uses the ETag as an resource variant identifier.

> - if the client has the etag and the entity (aka variant), it also has 
> the freshness information from Expires or max-age. It will not contact 
> Squid at all.

It varies wildly. Mostly due to clients often not having their clocks
set right I suppose.

> - is it wise to send an Expires header and an Etag? I don't think so. 
> These are two alternative ways of cache validation. Using both is 
> confusing. Which one has preference? An Etag implies an If-(None)-Match 
> conditional request; what's the use of Expires?

What? The two is completely unrelated.

ETag assigns a resource variant version identifier, unique for that
specific version of a resource variant. In a sense similar to
Last-Modified, but is not (protocol wise) limited to linearly increasing
time at a second granularity, and also uniquely identifies a single
variant version of a resource clearly telling caches when two responses
to different requests results in the same variant on negotiated objects.

Expires says when a returned response can no longer be considered fresh
without a conditional cache validation request using
If-None-Match/Last-Modified.

> - if a client lost the expires header as well as the confusing Etag and 
> sends GET If-Unmodified-Since, how would Squid respond? I guess: 304.

I don't know of any clients using GET If-Unmodified-Since.. only
If-Modified-Since / If-None-Match / If-Range.

DELETE If-Unmofified-Since I have heard about.

> So I don't think Squid or the clients will loose anything, when the 
> invalid Etag is dropped.

Squid will loose it's variant knowledge.

Many Mozilla versions will behave somewhat badly on Vary:ing objects due
to bug in it's use of If-Modified-Since.   and the fixed versions will
not cache such objects iirc.. (I haven't folloved the resolution to that
bug very closely and may be wrong about it being fixed or how it got
fixed)

> There might be a one in a million chance (I don't know how), that this 
> invalid Etag will save the transfer of an 1 MByte file from Squid to 
> client. But this is not worth the confusion.

What confusion are we actually talking about?

The risk that someone makes two or more significant updates to a
resource within the same second, and that this is important to requests
within that same second?

Or the bug that Apache contrary to the RFC never matches weak ETags in
If-None-Match conditions?

Or the WebDAV update problem that proper WebDAV operation really needs a
strong ETag from start usable in If-Match? (i.e. PUT, followed by PUT
If-Match on update without having to do a GET inbetween).

Or the relatewd problem that the specs forbids weak ETags in PUT
If-Match even when in real life semantic equivalence is sufficient there
and octet equavilence is not that important..

Or the risk that due to Apahces way of dealing with the sub-second
update problem in it's ETag generation, cobined with it's inability to
later match that ETag in If-None-Match may cause client implementors to
make workarounds and assumptions about how Apache deals with ETag, maybe
even dropping the weakness if seeing it "upgraded" to a strong one..?

Regards
Henrik

Re: thoughts on ETags and mod_dav

Posted by Henrik Nordström <he...@henriknordstrom.net>.
lör 2007-12-29 klockan 15:09 -0800 skrev Chris Darroch:
>    Reading that over, it still makes some sense to me.  Apache httpd is
> never in the situation implied by the RFC's example, where one wants to
> generate a weak ETag because one has knowledge that the file's semantic
> meaning hasn't changed, and therefore one can use the file's mtime to
> generate the weak ETag.

True, you don't know. Just as you don't really know there hasn't been
any direct fs modifications where the mtime was not updated.

In the end this boils down to a probability weighted design decision.
Not sending ETag (even a weak one) is bad for caching and WebDAV. Not
updating the ETag on changes (semantic changes in case of weak) is also
bad for caching and WebDAV. So you have to select which badness is the
worst unless you can generate real strong ETags using a versioned store
or similar.

ETag is not a "last-modified". It's a unique identifier identifying the
variant representation. It needs to change each time the representation
changes, but it's perfectly fine that it returns back to the same value
if the representation does even if the modification time is not the
same, or that it does not change if the only change is the last-modified
timestamp.

>    Currently, when httpd notices that a file's mtime and the current
> time are the same, ap_make_etag() just creates its usual ETag but
> then marks it as weak.  This has the advantage of being fast, since,
> as you point out, high performance is critical.  If I understand
> the issues at hand correctly, though, to resolve #42987 we should
> really just not generate any ETag at all in this case.

Not generating an ETag on objects modified "now" will bring a number of
other cache issues, mainly on negotiated objects (Vary responses).

> I'd proposed putting this into the hands of the administrator
> via a configuration directive:

As long as it's properly explained why one should not change the setting
without knowing the implications I am fine.

>    Does that seem out to lunch?  Certainly the intention is not
> to run counter to the RFC, but rather to do the best job of
> conforming to it while providing high performance, and being backwards-
> compatible with existing behaviour where that's appropriate.

I like the none/weak/ignore proposal even if I would use
none/weak/strong. Things done weirdly is best left configurable as
different setups have different tradeoffs, and one size fits all
solutions always have exceptions when it doesn't fit..

Regards
Henrik

Re: thoughts on ETags and mod_dav

Posted by Chris Darroch <ch...@pearsoncmg.com>.
Hi --

   I'm delighted to see that others have stepped in to keep this
thread going; thank you!  Work commitments have kept me from having
the appropriate time to devote to it.  It looks like Nick Kew and
Ruediger Pluem have committed some of the patches discussed in the
thread and the bug reports; again, thanks to all involved.  It would
be great if the problems addressed in #38034 and #16593 could be
handled properly (at least with respect to mod_dav).


Roy T. Fielding wrote:

> If you want a better meets_conditions in general, then write a new
> one with a new interface that can pass in the metadata for the
> chosen representation (if any) and does not stink of stupid DAVisms
> (like "resource exists" where it should say "representation exists").
> Do not make patches to the old interface because those won't be
> distributed until Apache 3.x.

   It looks like the patch Nick committed for mod_dav essentially
wraps ap_meets_conditions() and deals with the additional
If-Match/If-None-Match tests outside of that function.  That should
suffice to handle all the DAV issues from #38034 and that may be
entirely sufficient until 3.x.

   With an eye on handling those additional If-Match/If-None-Match
tests for all users, not just mod_dav, I'd hoped to allow callers
to pass the necessary extra info to ap_meets_conditions() in r->notes.
The function would remain entirely backwards-compatible for existing
users, of course.  I think Paul Querna suggested creating a
parallel ap_meets_conditions2(), as reported by Paritosh Shah, and that
may be less crufty than my notion.  I just wish I had an idea for more
meaningful name for such a replacement function.


> If the weak etags are not being matched to the string etags on
> GET, then that is another bug that must be fixed.  It is not an
> excuse to ignore the HTTP design.

   This, if I understand correctly, is the subject of #42987.  My
own best effort at understanding the issue, from my original post,
is below -- if you can weigh in with any clarifications or corrections,
that would be very helpful (to me, at least!)

Chris Darroch wrote:

>>    The RFC says that a file's mtime "could" be a weak validator, because
>> the file might change more than once in a second.  But I think the
>> subtly important issue here is that word "could".  If I understand it
>> correctly, the implication is that one has [a] resource for which one wants
>> to generate weak ETags only, because one knows the semantic meaning isn't
>> changing although the content may be.  In this particular case, the
>> modification time *might* be appropriate to use as a weak validator
>> (although that seems somewhat unlikely, because non-semantic changes
>> that occurred seconds apart would still cause different weak ETags to be
>> generated, which probably isn't what you'd want in this circumstance).
>> 
>>    But, in the cases handled by ap_make_etag(), the content and/or the
>> semantic meaning of a resource could always be changing, so weak ETags
>> would seem to be, as the PR says, simply never appropriate.

   Reading that over, it still makes some sense to me.  Apache httpd is
never in the situation implied by the RFC's example, where one wants to
generate a weak ETag because one has knowledge that the file's semantic
meaning hasn't changed, and therefore one can use the file's mtime to
generate the weak ETag.

   Since httpd is never in that situation, the RFC's example essentially
doesn't apply to the problem httpd faces when a file's modification
time is the current time (to the second).  Put another way, modification
times are not appropriate as weak ETag sources when one doesn't know,
somehow, that a file's semantic meaning hasn't changed.  I think!  :-/

   Currently, when httpd notices that a file's mtime and the current
time are the same, ap_make_etag() just creates its usual ETag but
then marks it as weak.  This has the advantage of being fast, since,
as you point out, high performance is critical.  If I understand
the issues at hand correctly, though, to resolve #42987 we should
really just not generate any ETag at all in this case.

   I'd proposed putting this into the hands of the administrator
via a configuration directive:

>> - add a nomtime=none|weak|ignore option to FileETag (in the manner
>>   of ProxyPass) which specifies what to do when the MTime option is
>>   configured but the file's mtime is the same as r->request_time;
>>   the default value is "weak" to retain backward compatibility

   So, the out-of-box default would be the current functionality.
One could tune it to not generate any ETag in this particular situation
(where mtime is used a part of the strong ETags, and the mtime and
current time match), or to ignore this situation and just always
send out a strong ETag.

   Does that seem out to lunch?  Certainly the intention is not
to run counter to the RFC, but rather to do the best job of
conforming to it while providing high performance, and being backwards-
compatible with existing behaviour where that's appropriate.

Chris.

-- 
GPG Key ID: 366A375B
GPG Key Fingerprint: 485E 5041 17E1 E2BB C263  E4DE C8E3 FA36 366A 375B


Re: thoughts on ETags and mod_dav

Posted by Henrik Nordstrom <he...@henriknordstrom.net>.
On sön, 2007-12-30 at 12:54 +0100, Werner Baumann wrote:

> Is this true. Is there no way for a cache to uniquely identify variants, 
> but using the cache validator? Isn't this a flaw in the protocol?

The Content-Location also works as a variant identifier, but requires
that each variant do have a unique direct URI bypassing negotiation and
is therefore not always applicable (i.e. mod_deflate).

Regards
Henrik


Re: thoughts on ETags and mod_dav

Posted by Werner Baumann <we...@onlinehome.de>.
Roy T. Fielding wrote:
> If the weak etags are not being matched to the string etags on
> GET, then that is another bug that must be fixed.  It is not an
> excuse to ignore the HTTP design.
>
This is a new aspect. I always thought it was intended behaviour, that 
weak etags (in Apache) will *never match*. And therefore thought it a 
waste of time to calculate a string that will never be used. If the 
intention was, that the weak etag will match on conditional (full body) 
GET requests, this will change the discussion.
But still: Wouldn't in this case Last-Modified-Date be the better, more 
efficient and less confusing choice of weak validator?

Henrik Nordström wrote:
 > lör 2007-12-29 klockan 20:56 +0100 skrev Werner Baumann:
 >
 >> Objections:
 >> - Squid seems not to take any information from the Etag.
 >
 > Yes it does. It uses the ETag as an resource variant identifier.
 >
Is this true. Is there no way for a cache to uniquely identify variants, 
but using the cache validator? Isn't this a flaw in the protocol?

Cheers
Werner


Re: thoughts on ETags and mod_dav

Posted by "Roy T. Fielding" <fi...@gbiv.com>.
This is getting ridiculous.  ETags are important to caching.
Caching is important to HTTP.  If you sum up all of the instances
of webdav in the world (including the ones my company sells), they
still amount to nothing compared to the rest of the uses of HTTP.

If you want strong etags for mod_dav, then do the right thing and
generate strong etags in mod_dav.  Replace its backend with a
versioned filestore (like subversion) and use the revision
number as the strong etag.

All this other nonsense about removing the weakness indicator
on weak etags, or just not supplying etags at all on weak
filesystem writes, is not going to happen.  We have weak etags
because our generic core filesystem backend doesn't need strong
etags anywhere near as much as it needs high performance.  That's
why modules that do authoring should not use the generic core
filesystem backend.  Until mod_dav learns that, just apply the
patch that Werner proposed

   http://issues.apache.org/bugzilla/attachment.cgi?id=20552

(and perhaps make it a hook that can be replaced by modules).
That is sufficient to fix the bug for dav.

If you want a better meets_conditions in general, then write a new
one with a new interface that can pass in the metadata for the
chosen representation (if any) and does not stink of stupid DAVisms
(like "resource exists" where it should say "representation exists").
Do not make patches to the old interface because those won't be
distributed until Apache 3.x.

If the weak etags are not being matched to the string etags on
GET, then that is another bug that must be fixed.  It is not an
excuse to ignore the HTTP design.

....Roy

Re: thoughts on ETags and mod_dav

Posted by Werner Baumann <we...@onlinehome.de>.
First:
I proposed to not only drop that *none*-Etag, but also to send no-cache. 
The second is an error. The server should not send no-cache, but let it 
to the client and the intermediate caches to decide about caching on the 
base of the spec and their configured policy. But I still believe 
dropping that *none*-Etag is the best.

Henrik Nordström wrote:
> Clietn -> Squid -[internet]-> Apache
> 
> the object in question is having a weak ETag but significant freshness
> assigned to it via mod_expires or similar.
> 
> object gets cached by Squid & client with a weak etag
> 
> client later issues an IF-None-Match request to Squid using the weak
> ETag. Squid considers the object still fresh and responds with 304.
>
Objections:
- Squid seems not to take any information from the Etag.

- if the client has the etag and the entity (aka variant), it also has 
the freshness information from Expires or max-age. It will not contact 
Squid at all.

- is it wise to send an Expires header and an Etag? I don't think so. 
These are two alternative ways of cache validation. Using both is 
confusing. Which one has preference? An Etag implies an If-(None)-Match 
conditional request; what's the use of Expires?

- if a client lost the expires header as well as the confusing Etag and 
sends GET If-Unmodified-Since, how would Squid respond? I guess: 304.

So I don't think Squid or the clients will loose anything, when the 
invalid Etag is dropped.

There might be a one in a million chance (I don't know how), that this 
invalid Etag will save the transfer of an 1 MByte file from Squid to 
client. But this is not worth the confusion.

Cheers
Werner


Re: thoughts on ETags and mod_dav

Posted by Henrik Nordström <he...@henriknordstrom.net>.
lör 2007-12-29 klockan 10:42 +0100 skrev Werner Baumann:

> I have no idea what this would be. Can you give a *short* outline?
> Please note: The weak Etags generated by Apache will *never* match. So 
> the only way I see, how Apache's weak Etags could be used, is to ignore 
> the weakness indicator, as I do in davfs2.

Intermediaries is proxies etc. These do their own condidionals
processing, and some do follow the RFC and allows for weak etags to be
used in conditionals.

Clietn -> Squid -[internet]-> Apache

the object in question is having a weak ETag but significant freshness
assigned to it via mod_expires or similar.

object gets cached by Squid & client with a weak etag

client later issues an IF-None-Match request to Squid using the weak
ETag. Squid considers the object still fresh and responds with 304.

Regards
Henrik


Re: thoughts on ETags and mod_dav

Posted by Werner Baumann <we...@onlinehome.de>.
Creating strong Etags would be not to difficult, if the WebDAV 
repository is only changed by mod_dav. To me it seems not very 
important, how exactly the strong Etag is created:
(filesize+inode+counter, counter only, locking the file for one second, 
enforcing an inode-change. All this can work. Even delaying some 
PUT-requests (because of locking) would not be a problem, as it would 
occur rarely.
But the problem is, that mod_dav might be bypassed. There are just two 
possible solutions:

1) make sure, mod_dav can reliable detect any changes by what ever means 
they are made

2) put the responsibility on the administrator.

As I cannot see any realistic solution according 1), I propose solution 
2). The suggested check for changes made outside of mod_dav is only 
meant to catch *most* of the errors made by administrators. It cannot be 
reliable, and is not meant to take the responsibility from the 
administrator.

A configuration option should allow the administrator to deny his/her 
responsibility. Doing so, the WebDav-server can no longer create strong 
Etags it will get inefficient and unreliable. But this would at least be 
the responsibility of the administrator. The documentation has to be 
very clear about this.

Concerning Etags outside of WebDAV:

Henrik Nordström wrote:
 > ..., and the weak ETag may be useful to
 > intermediaries which implements local If-None-Match processing so
 > sending a weak etag is actually better than none, especially so if the
 > object Vary:es..
I have no idea what this would be. Can you give a *short* outline?
Please note: The weak Etags generated by Apache will *never* match. So 
the only way I see, how Apache's weak Etags could be used, is to ignore 
the weakness indicator, as I do in davfs2. But this is of course not how 
weak Etags are meant to work and includes some risk.
So I still think: Apache's weak Etags are *none*-Etags and simply imply 
no-cache. It would be better to say this in the clear.
BTW: IIS seems to do the same, but this doesn't make it better.

Werner



Re: thoughts on ETags and mod_dav

Posted by Henrik Nordström <he...@henriknordstrom.net>.
lör 2007-12-29 klockan 13:19 +0800 skrev Michael Clark:

> AFAICT, we are in agreement here. My point was related to the current 
> inability to detect the direct filesystem access i.e. with the 
> DavETagIsolation dav+fs you would have to invalidate the ETag unless you 
> had some sort of  mechanism to detect sub second direct filesystem 
> accesses (or mandatory locking as you propose) - i.e. invalidate strong 
> ETag == regenerate strong ETag.

Yes, except for the ==.

It's imho fine to fall back on the current mechanism when direct fs
modification has been detected.

Regards
Henrik


Re: thoughts on ETags and mod_dav

Posted by Michael Clark <mi...@metaparadigm.com>.
Henrik Nordström wrote:
> Modifications made using direct filesystem access, in the same second as
> the last WebDAV update and only rewriting the file in-place without
> changing the length.
>   

That would be a reasonable limitation - hence the suggesion for a 
DavETagIsolation dav-only (the default being a more conservative dav+fs)

>> A correct implementation would have to regenerate the strong ETag for 
>> all of these sub second occurring requests (which is counter intuitive 
>> for a cached property and also very inefficient).
>>     
>
> No, but if direct filesystem access is allowed it would need to be able
> to detect that there has been a such access in the same second and
> invalidate the strong ETag.
>   

AFAICT, we are in agreement here. My point was related to the current 
inability to detect the direct filesystem access i.e. with the 
DavETagIsolation dav+fs you would have to invalidate the ETag unless you 
had some sort of  mechanism to detect sub second direct filesystem 
accesses (or mandatory locking as you propose) - i.e. invalidate strong 
ETag == regenerate strong ETag.

Assuming direct filesystem access is not allowed then a stored ETag with 
mtime+inode+length+modification counter would be guaranteed to be enough 
(yes, it would need to be stored due to the additional counter) as 
mod_dav would be the only one changing anything.

Alternatively, a PUT without Content-Range (the common case) could be 
changed to mktemp / open / write / close / rename - this may remove the 
need for storing anything as a normal PUT would always change the inode 
(it would catch most of the common cases - excluding direct filesystem 
modification within the same second or mmap changes which don't update 
mtime and PUT with Content-Range which I think is a pretty special case?).

>> The other proposals I've been reading seem to require saying that this 
>> ETag is strong when we know that this it not guaranteed to be true - but 
>> perhaps this should be up to the admin (DavETagIsolation dav-mods-only).
>>     
>
> filesystem metadata based on just size + inode + mtime is never a
> guaranteed change identifier. Nothing stops an in-place edit where the
> timestamp is kept.
>   

Yes but in the first paragraph you are excluding these sub second file 
system access anyway :) . Excluding sub second direct file system access 
and with the addition of a modification counter it would be enough? (or 
by making PUT without Content-Range change the inode).

The isolation levels should perhaps be discussed independently as this 
is leading to some of the confusion. Here is my take on it:

dav+fs (assumptions of current code)
 * needs to generate a weak ETag for subsecond mtime unless it could 
detect sub second modifications or use a mandatory lock for 1 second.
 * it can't detect sub second modifications and doesn't use a mandatory 
lock for 1 second.
 * storing ETag will not improve your ability to generate a strong ETag 
(unless you could detect the direct filesystem modifications or use a 
mandatory lock).
 * if you could detect the direct filesystem modifications or use a 
mandatory lock then mtime+inode+length (+ modification counter) would be 
enough (although this would exclude mmap modifications on unix)
 * sub-second direct modifications can't be detected easily (requires 
non portable interfaces like inotify) and mmap changes can probably 
never be detected.

dav-only
 * could generate strong ETags always if sub-second mod_dav 
modifications were tracked somehow.
 * mtime+inode+length (+ modification counter) would be enough (what 
more is needed? no changes are happening outside mod_dav)
 * probably needs to store modification/generation counter, although...
 * if PUT without Content-Range was made to change the inode then most 
of the common cases could probably be covered without storing anything 
(although this would not cover the case where the ETag would need to 
change on sub second PROPPATCH?? and PUT with Content-Range - how common 
is this?).

Perhaps there is a third isolation level?:

dav+loose-fs
 * only differs from dav-only in that it makes a best effort at handling 
FS changes.
 * could incorrectly return a strong ETag in cases where a direct file 
system modification was made in the same second as a mod_dav modification
 * mtime+inode+length (+ modification counter) would be enough?
 * Is this any different from dav-only? Is this just an alias for dav-only?


Re: thoughts on ETags and mod_dav

Posted by Henrik Nordström <he...@henriknordstrom.net>.
lör 2007-12-29 klockan 09:20 +0800 skrev Michael Clark:

> 
> You would still suffer from the 1 second racing condition where you 
> wouldn't known if your stored ETag was up-to-date due to the mtime 
> resolution (for modifications made outside of WebDAV) forcing you back 
> into the current weak ETag situation.

Modifications made using direct filesystem access, in the same second as
the last WebDAV update and only rewriting the file in-place without
changing the length.

> A correct implementation would have to regenerate the strong ETag for 
> all of these sub second occurring requests (which is counter intuitive 
> for a cached property and also very inefficient).

No, but if direct filesystem access is allowed it would need to be able
to detect that there has been a such access in the same second and
invalidate the strong ETag.

> The other proposals I've been reading seem to require saying that this 
> ETag is strong when we know that this it not guaranteed to be true - but 
> perhaps this should be up to the admin (DavETagIsolation dav-mods-only).

filesystem metadata based on just size + inode + mtime is never a
guaranteed change identifier. Nothing stops an in-place edit where the
timestamp is kept.

> We could use something like inotify (or pnofity [1]) to track these 
> files for the required 1 second duration (or for a longer duration if we 
> wished to cache the stat info and know for sure it was valid).

For ETag the 1 second interval is sufficient.

Another option would be to use a 1 second mandatory write lock, but that
feels a little scary..

Regards
Henrik


Re: thoughts on ETags and mod_dav

Posted by Michael Clark <mi...@metaparadigm.com>.
Henrik Nordström wrote:
> But I do not agree entirely on the conclusions on how mod_dav should
> handle ETag. If you store ETag as a property it's better you generate a
> real strong ETag without relying on the filesystem meta data, only using
> the filesystem meta data as a safety check to guard from direct
> filesystem modification not using WebDAV.
>   

You would still suffer from the 1 second racing condition where you 
wouldn't known if your stored ETag was up-to-date due to the mtime 
resolution (for modifications made outside of WebDAV) forcing you back 
into the current weak ETag situation.

A correct implementation would have to regenerate the strong ETag for 
all of these sub second occurring requests (which is counter intuitive 
for a cached property and also very inefficient).

The other proposals I've been reading seem to require saying that this 
ETag is strong when we know that this it not guaranteed to be true - but 
perhaps this should be up to the admin (DavETagIsolation dav-mods-only).

If we had some way of getting (outside) file modification events we 
could have a very strong implementation using the inode, mtime and a 
generation counter (with an n microsecond race between a change and 
delivery of its change event to some sort of file modification or 
stat-cache).

We could use something like inotify (or pnofity [1]) to track these 
files for the required 1 second duration (or for a longer duration if we 
wished to cache the stat info and know for sure it was valid). It seems 
like an ugly thing to do but seems to me to be the only way we could 
guarantee we know that the file has not been modified with the coarse 
mtime we have. Of course it would be non-trivial and require quite a bit 
of infrastructure (say a VFS statcache module using a portable file 
system event notification API).

~mc

[1]  http://mark.heily.com/pnotify/

pnotify is a BSD licensed portable file systems event notification 
library that works across Linux, *BSD and OS X. It is noted by the 
author that it could also be supported on Windows and Solaris, as they 
have filesystem notification event subsystems also.

Re: thoughts on ETags and mod_dav

Posted by Henrik Nordström <he...@henriknordstrom.net>.
fre 2007-12-28 klockan 15:00 +0000 skrev Nick Kew:

> That bug shows why there's sometime a problem with such issues.
> I committed a fix back in October, but you weren't satisfied with it,

I ahd initial objections because I thought you actually handled weak
ETags, but when remembering that you don't the suggested workaround is
sufficient to work around the problem in most cases.

Regards
Henrik


Re: thoughts on ETags and mod_dav

Posted by Nick Kew <ni...@webthing.com>.
On Fri, 28 Dec 2007 15:24:07 +0100
Henrik Nordström <he...@henriknordstrom.net> wrote:


> http://issues.apache.org/bugzilla/show_bug.cgi?id=39727
> 
> discussed a number of times here already with varying results..

See this morning's commits.  Werner's post reminded me of that one.
http://svn.apache.org/viewvc?view=rev&revision=607219
http://svn.apache.org/viewvc?view=rev&revision=607220

That bug shows why there's sometime a problem with such issues.
I committed a fix back in October, but you weren't satisfied with it,
and we ended up in an inconclusive discussion.  Roy (whose voice I
take as authoritative in matters of RFC2616) supported my position.
But at the same time, we had yourself and others calling for a
different fix.  Great for getting bogged down and doing nothing.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/

Re: thoughts on ETags and mod_dav

Posted by Henrik Nordström <he...@henriknordstrom.net>.
fre 2007-12-28 klockan 11:46 +0100 skrev Werner Baumann:
> Paritosh Shah wrote:
>  > Another possible approach would be to create a new
>  > ap_meets_conditions_2() with resource_exists as an explicit argument (
>  > instead of implicitly using r->notes ). Till the next major release we
>  > could just make the current ap_meets_conditions() call
>  > ap_meets_conditions_2() with resource_exists as 1. Later we can make
>  > ap_meets_conditions_2() the default ap_meets_conditions().
> This seems to be the best way to fix this bug.
> 
> I proposed a solution for the Etag-problem, please see
> http://issues.apache.org/bugzilla/show_bug.cgi?id=42987

Weak ETags is a bit of a touchy subject in the HTTP specifications. No
one really wants to touch them. The use of weak ETags in conditionals is
limited to If-None-Match. Using a weak ETag in any other conditional
such as If-Match is not allowed for some strange reason. (well, If-Range
is understandable, but If-Match..).

Regarding the problem in issue 42987 the real problem is that Apache can
not make a strong ETag on very new objects. Imho that's the real bug
there.

And yes, it may loook like it's be better to not send a ETag at all than
to send a completely useless one (in terms of Apache), but in the end it
doesn't matter very much, and the weak ETag may be useful to
intermediaries which implements local If-None-Match processing so
sending a weak etag is actually better than none, especially so if the
object Vary:es..

But I do not agree entirely on the conclusions on how mod_dav should
handle ETag. If you store ETag as a property it's better you generate a
real strong ETag without relying on the filesystem meta data, only using
the filesystem meta data as a safety check to guard from direct
filesystem modification not using WebDAV.

> But I am really frustrated about how this problem is handled by the 
> Apache developers.

And I am still waiting for the developers to make up their mind on the
somewhat related mod_deflate ETag issue...

http://issues.apache.org/bugzilla/show_bug.cgi?id=39727

discussed a number of times here already with varying results..

Not frustrated about it, but a little sad that the Apache team do not
take RFC complaince and interoperability more serious.

It almost like there is something with how conditionals is handled in
Apache which is optimized for performance making correctness nearly
impossible it seems..

What is needed to move forward on the discussions on how ETag &
conditionals should be handled with modules and filters?

What I can offer in this discussion is my expertice in HTTP requiremnts,
and general advice on what is required to be able to comply with the
HTTP requirents. But not skilled enough in the Apache module & filter
framework to get my hands dirty in the code I am afraid. But I suppose
if a year more or so passes then I might do that as well.

Regards
Henrik
Squid Developer