You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by N/A N/A <pr...@yahoo.com> on 2011/11/01 18:20:59 UTC

CouchDB _changes _view transactions

Hello,

I have the following issue. I hold continuous _changes feed for certain events. When my web application is started for first time, i want to get last event and process it. I wrote a view for this purpose querying CouchDB. Where is the problem ? During view execution, is it possible to get newer message from continuous _changes? Which information will arrive first ? The one from the view or _changes ? Which message is last ? CouchDB doesn't support transactions so in this case i'm not sure my last information is last and valid.

Regards,

Re: CouchDB _changes _view transactions

Posted by N/A N/A <pr...@yahoo.com>.
Hi, 

Could you give me some more details?

Regards


________________________________
From: Benoit Chesneau <bc...@gmail.com>
To: user@couchdb.apache.org; N/A N/A <pr...@yahoo.com>
Sent: Tuesday, November 1, 2011 8:00 PM
Subject: Re: CouchDB _changes _view transactions

On Tue, Nov 1, 2011 at 6:20 PM, N/A N/A <pr...@yahoo.com> wrote:
> Hello,
>
> I have the following issue. I hold continuous _changes feed for certain events. When my web application is started for first time, i want to get last event and process it. I wrote a view for this purpose querying CouchDB. Where is the problem ? During view execution, is it possible to get newer message from continuous _changes? Which information will arrive first ? The one from the view or _changes ? Which message is last ? CouchDB doesn't support transactions so in this case i'm not sure my last information is last and valid.
>
> Regards,

You can do the inverse on trunk and 1.2x branch :

use the native filter _view and if a change come , query your view,
compare seqs etc...

- benoit

Re: CouchDB _changes _view transactions

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Nov 1, 2011 at 6:20 PM, N/A N/A <pr...@yahoo.com> wrote:
> Hello,
>
> I have the following issue. I hold continuous _changes feed for certain events. When my web application is started for first time, i want to get last event and process it. I wrote a view for this purpose querying CouchDB. Where is the problem ? During view execution, is it possible to get newer message from continuous _changes? Which information will arrive first ? The one from the view or _changes ? Which message is last ? CouchDB doesn't support transactions so in this case i'm not sure my last information is last and valid.
>
> Regards,

You can do the inverse on trunk and 1.2x branch :

use the native filter _view and if a change come , query your view,
compare seqs etc...

- benoit

Re: CouchDB _changes _view transactions

Posted by N/A N/A <pr...@yahoo.com>.
Hello,

Thx. So:
1: Application starts and querying view -> /_view/getState?update_seq=true&startkey=[\"something\"]&endkey=[\"something\", {}]
2: seq = update_seq
3: .../_changes", { options: {"feed": "continuous", "heartbeat": 30000, "include_docs": true, "since": seq}}, true)

_changes will give me everything since last seq, so i am not going to lose information. Looks secure at first reading...

Regards,



________________________________
From: Jens Alfke <je...@couchbase.com>
To: "user@couchdb.apache.org" <us...@couchdb.apache.org>; N/A N/A <pr...@yahoo.com>
Sent: Tuesday, November 1, 2011 7:41 PM
Subject: Re: CouchDB _changes _view transactions


On Nov 1, 2011, at 10:20 AM, N/A N/A wrote:

> During view execution, is it possible to get newer message from continuous _changes? Which information will arrive first ? The one from the view or _changes ? 

I don’t think there can be any guarantees, since the data is arriving over two separate TCP connections. Even if the server sent the packets in a known order, that could be changed during flight if some packets were delayed.

What might help is configuring your view to emit sequence numbers*. Then you can compare the sequence numbers in the view rows coming back with the latest sequence number received from _changes to see which is newer.

—Jens

* http://wiki.apache.org/couchdb/HTTP_view_API#View_Generation_Options

Re: CouchDB _changes _view transactions

Posted by Jens Alfke <je...@couchbase.com>.
On Nov 1, 2011, at 10:20 AM, N/A N/A wrote:

> During view execution, is it possible to get newer message from continuous _changes? Which information will arrive first ? The one from the view or _changes ? 

I don’t think there can be any guarantees, since the data is arriving over two separate TCP connections. Even if the server sent the packets in a known order, that could be changed during flight if some packets were delayed.

What might help is configuring your view to emit sequence numbers*. Then you can compare the sequence numbers in the view rows coming back with the latest sequence number received from _changes to see which is newer.

—Jens

* http://wiki.apache.org/couchdb/HTTP_view_API#View_Generation_Options