Mon 09 Apr 2012 02:06:01 PM UTC, original submission:
I'm using davfs2-1.4.6 (with default settings) and apache-2.2.22.
I'd like to append to a single file from multiple locations, but I'm experiencing lost updates. I'm mounting a single WebDAV directory (using the same WebDAV user) on two different client machines, called A and B below.
I've got two test sequences, the first one with shell commands, the second one with a combination of shell and Python to see more details.
First test sequence:
On A:
$ echo "Hallo" >> foo
Then, on B:
$ echo "Moin" >> foo
bash: foo: No such file or directory
$ echo "Moin" >> foo
Then, on A:
$ cat foo
cat: foo: No such file or directory
$ cat foo
cat: foo: No such file or directory
$ cat foo
Moin
$ rm foo
Then, on B:
$ rm foo
In the above sequence, why does the second append on B succeed if the first one fails? In addition, "No such file or directory" is a pretty surprising error message for a command that should create the file if it does not exist. Finally, why can I delete twice?
Apache logs for above commands:
A - jens [09/Apr/2012:15:37:44 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1249
A - jens [09/Apr/2012:15:37:44 +0200] "LOCK /webdav/foo HTTP/1.1" 200 418
B - jens [09/Apr/2012:15:37:46 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1666
B - jens [09/Apr/2012:15:37:46 +0200] "LOCK /webdav/foo HTTP/1.1" 423 277
B - jens [09/Apr/2012:15:37:46 +0200] "PROPFIND /webdav/foo HTTP/1.1" 207 587
B - jens [09/Apr/2012:15:37:46 +0200] "LOCK /webdav/foo HTTP/1.1" 200 418
B - jens [09/Apr/2012:15:37:46 +0200] "GET /webdav/foo HTTP/1.1" 404 208
B - jens [09/Apr/2012:15:37:46 +0200] "UNLOCK /webdav/foo HTTP/1.1" 204 -
B - jens [09/Apr/2012:15:37:46 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1249
B - jens [09/Apr/2012:15:37:48 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1249
B - jens [09/Apr/2012:15:37:48 +0200] "LOCK /webdav/foo HTTP/1.1" 200 418
A - jens [09/Apr/2012:15:37:54 +0200] "PUT /webdav/foo HTTP/1.1" 412 244
A - jens [09/Apr/2012:15:37:54 +0200] "UNLOCK /webdav/foo HTTP/1.1" 400 226
A - jens [09/Apr/2012:15:37:54 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1666
A - jens [09/Apr/2012:15:37:56 +0200] "GET /webdav/foo HTTP/1.1" 404 208
A - jens [09/Apr/2012:15:37:57 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1666
A - jens [09/Apr/2012:15:37:59 +0200] "GET /webdav/foo HTTP/1.1" 404 208
B - jens [09/Apr/2012:15:37:59 +0200] "PUT /webdav/foo HTTP/1.1" 201 183
B - jens [09/Apr/2012:15:37:59 +0200] "HEAD /webdav/foo HTTP/1.1" 200 -
B - jens [09/Apr/2012:15:37:59 +0200] "UNLOCK /webdav/foo HTTP/1.1" 204 -
A - jens [09/Apr/2012:15:38:00 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1730
A - jens [09/Apr/2012:15:38:01 +0200] "GET /webdav/foo HTTP/1.1" 200 5
A - jens [09/Apr/2012:15:38:15 +0200] "DELETE /webdav/foo HTTP/1.1" 204 -
B - jens [09/Apr/2012:15:38:17 +0200] "DELETE /webdav/foo HTTP/1.1" 404 208
B - jens [09/Apr/2012:15:38:17 +0200] "PROPFIND /webdav/foo HTTP/1.1" 404 208
B - jens [09/Apr/2012:15:38:18 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1249
Here is a similar test sequence using Python commands (preceded by >>>) and shell commands (preceded by $):
On A:
>>> import os
>>> f = open("foo", "a")
On B:
>>> f = open("foo", "a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'foo'
So, open() fails. Apart from the error message itself, which does not hint towards locking conflicts, this might be fine. However, repeating the command succeeds:
On B:
>>> f = open("foo", "a")
On A:
>>> f.write("Moin\n")
>>> f.flush()
>>> os.fsync(f.fileno())
>>> f.close()
On B:
>>> f.write("Hello\n")
>>> f.close()
On B:
$ cat foo
Hello
On A:
$ cat foo
cat: foo: No such file or directory
<The previous message occurs for several invocations of cat.>
$ cat foo
<empty result>
<wait more>
$ cat foo
Hello
$ rm foo
<success, no output>
On B:
$ rm foo
<success, no output>
Thus, why does the second open() on B succeed if the first one fails? Then, all writes of A are lost (although I'm trying to sync explicitly), which is bad. Moreover, in between the file seems to disappear on A, which is even worse.
Then, why does deletion succeed twice?
Apache logs for Python tests:
A - jens [09/Apr/2012:15:31:37 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1249
A - jens [09/Apr/2012:15:31:37 +0200] "LOCK /webdav/foo HTTP/1.1" 200 418
B - jens [09/Apr/2012:15:31:39 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1666
B - jens [09/Apr/2012:15:31:39 +0200] "LOCK /webdav/foo HTTP/1.1" 423 277
B - jens [09/Apr/2012:15:31:39 +0200] "PROPFIND /webdav/foo HTTP/1.1" 207 587
B - jens [09/Apr/2012:15:31:39 +0200] "LOCK /webdav/foo HTTP/1.1" 200 418
B - jens [09/Apr/2012:15:31:39 +0200] "GET /webdav/foo HTTP/1.1" 404 208
B - jens [09/Apr/2012:15:31:39 +0200] "UNLOCK /webdav/foo HTTP/1.1" 204 -
B - jens [09/Apr/2012:15:31:39 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1249
B - jens [09/Apr/2012:15:31:41 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1249
B - jens [09/Apr/2012:15:31:41 +0200] "LOCK /webdav/foo HTTP/1.1" 200 418
A - jens [09/Apr/2012:15:31:48 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1666
B - jens [09/Apr/2012:15:32:02 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1666
A - jens [09/Apr/2012:15:32:07 +0200] "PUT /webdav/foo HTTP/1.1" 412 244
A - jens [09/Apr/2012:15:32:07 +0200] "UNLOCK /webdav/foo HTTP/1.1" 400 226
A - jens [09/Apr/2012:15:32:08 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1666
A - jens [09/Apr/2012:15:32:08 +0200] "GET /webdav/foo HTTP/1.1" 404 208
A - jens [09/Apr/2012:15:32:09 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1666
A - jens [09/Apr/2012:15:32:10 +0200] "GET /webdav/foo HTTP/1.1" 404 208
A - jens [09/Apr/2012:15:32:10 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1666
A - jens [09/Apr/2012:15:32:12 +0200] "GET /webdav/foo HTTP/1.1" 404 208
A - jens [09/Apr/2012:15:32:12 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1666
B - jens [09/Apr/2012:15:32:13 +0200] "PUT /webdav/foo HTTP/1.1" 201 183
B - jens [09/Apr/2012:15:32:13 +0200] "HEAD /webdav/foo HTTP/1.1" 200 -
B - jens [09/Apr/2012:15:32:13 +0200] "UNLOCK /webdav/foo HTTP/1.1" 204 -
A - jens [09/Apr/2012:15:32:14 +0200] "GET /webdav/foo HTTP/1.1" 200 6
A - jens [09/Apr/2012:15:32:16 +0200] "GET /webdav/foo HTTP/1.1" 304 -
A - jens [09/Apr/2012:15:32:19 +0200] "DELETE /webdav/foo HTTP/1.1" 204 -
B - jens [09/Apr/2012:15:32:22 +0200] "DELETE /webdav/foo HTTP/1.1" 404 208
B - jens [09/Apr/2012:15:32:22 +0200] "PROPFIND /webdav/foo HTTP/1.1" 404 208
B - jens [09/Apr/2012:15:32:23 +0200] "PROPFIND /webdav/ HTTP/1.1" 207 1249
|