couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <B.Cand...@pobox.com>
Subject Re: [jira] Commented: (COUCHDB-449) Turn off delayed commits by default
Date Thu, 06 Aug 2009 08:37:50 GMT
On Wed, Aug 05, 2009 at 05:38:15AM -0700, Jan Lehnardt (JIRA) wrote:
> The "just write and let me know when things have been committed" can be done with the
_changes feed already. No need for a separate sequence id.

Just to be clear: _changes is supposed only to update after a commit has
taken place, not after a write?

If so, I cannot demonstrate it. If I write a document and then immediately
read _changes, it always appears. See below at (*).

Furthermore, the same is true if I run

$ curl http://127.0.0.1:5984/test/_changes?feed=continuous

in another window. As soon as I add a document in the first window, it
appears in the _changes feed.

My very rough scan of the source suggests that a delayed commit should take
place after 1 second:

    Delay and (Db#db.waiting_delayed_commit == nil) ->
        Db#db{waiting_delayed_commit=
                erlang:send_after(1000, self(), delayed_commit)};

So if that's right, and what you say is true, then I would expect not to see
the document in _changes for this long.

OTOH, with batch=ok the commit is delayed indefinitely. I have raised this
as a separate ticket COUCHDB-454)

All tested with HEAD (git commit aebdb31001126dab6b579b8cc2e605ef7ec499c6)
and 12b5 under Jaunty.

Regards,

Brian.

(*)
$ curl -X DELETE http://127.0.0.1:5984/test
{"ok":true}
$ curl -X PUT http://127.0.0.1:5984/test
{"ok":true}
$ curl http://127.0.0.1:5984/test/_changes
{"results":[

],
"last_seq":0}

$ curl -X POST -d'{}' http://127.0.0.1:5984/test; curl http://127.0.0.1:5984/test/_changes
{"ok":true,"id":"70708dcbc24444977b759365f9731f27","rev":"1-967a00dff5e02add41819138abb3284d"}
{"results":[
{"seq":1,"id":"70708dcbc24444977b759365f9731f27","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]}
],
"last_seq":1}

$ curl -X POST -d'{}' http://127.0.0.1:5984/test; curl http://127.0.0.1:5984/test/_changes
{"ok":true,"id":"1d4596c1cb715c0da9f99980fea0a3a2","rev":"1-967a00dff5e02add41819138abb3284d"}
{"results":[
{"seq":1,"id":"70708dcbc24444977b759365f9731f27","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]},
{"seq":2,"id":"1d4596c1cb715c0da9f99980fea0a3a2","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]}
],
"last_seq":2}

$ curl -X POST -d'{}' http://127.0.0.1:5984/test; curl http://127.0.0.1:5984/test/_changes
{"ok":true,"id":"a2feeaaca391446bb7a0f24c359ff79e","rev":"1-967a00dff5e02add41819138abb3284d"}
{"results":[
{"seq":1,"id":"70708dcbc24444977b759365f9731f27","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]},
{"seq":2,"id":"1d4596c1cb715c0da9f99980fea0a3a2","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]},
{"seq":3,"id":"a2feeaaca391446bb7a0f24c359ff79e","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]}
],
"last_seq":3}

$ curl -X POST -d'{}' http://127.0.0.1:5984/test; curl -X POST -d'{}' http://127.0.0.1:5984/test;
curl -X POST -d'{}' http://127.0.0.1:5984/test; curl http://127.0.0.1:5984/test/_changes
{"ok":true,"id":"a2262a5904690aec5c64bb61f44903ed","rev":"1-967a00dff5e02add41819138abb3284d"}
{"ok":true,"id":"26fdac7e139531e0f4352a089d4db7f4","rev":"1-967a00dff5e02add41819138abb3284d"}
{"ok":true,"id":"f6bb36540484788becd54391dbc6189b","rev":"1-967a00dff5e02add41819138abb3284d"}
{"results":[
{"seq":1,"id":"70708dcbc24444977b759365f9731f27","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]},
{"seq":2,"id":"1d4596c1cb715c0da9f99980fea0a3a2","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]},
{"seq":3,"id":"a2feeaaca391446bb7a0f24c359ff79e","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]},
{"seq":4,"id":"a2262a5904690aec5c64bb61f44903ed","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]},
{"seq":5,"id":"26fdac7e139531e0f4352a089d4db7f4","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]},
{"seq":6,"id":"f6bb36540484788becd54391dbc6189b","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]}
],
"last_seq":6}


Mime
View raw message