Any way to do synchronous writes to Sync Gateway?

91 views
Skip to first unread message

Traun Leyden

unread,
Oct 8, 2014, 5:27:55 PM10/8/14
to mobile-c...@googlegroups.com

When I do a POST/PUT to Sync Gateway, does the call return after it's been "fsync'd" on Couchbase Server, or is it more "fire and forget"?

(I realize there is a configuration for Couchbase Server to only return from API calls after it's been sync'd to disk -- but I am talking about the "round trip" blocking behavior between a Sync Gw client and Couchbase Server)

Jens Alfke

unread,
Oct 8, 2014, 7:27:33 PM10/8/14
to mobile-c...@googlegroups.com

On Oct 8, 2014, at 2:27 PM, Traun Leyden <tle...@couchbase.com> wrote:

When I do a POST/PUT to Sync Gateway, does the call return after it's been "fsync'd" on Couchbase Server, or is it more "fire and forget"?

Usually it returns after the document has been written to Couchbase Server. That does not mean it's been persisted to disk; that takes a bit longer. (Some document writes do wait till the server persists the document to disk; the details are complicated.)

—Jens

Traun Leyden

unread,
Oct 9, 2014, 12:59:59 PM10/9/14
to mobile-c...@googlegroups.com

I talked to the couchbase server support folks, and they pointed me to the options for the Set command which control whether it's persisted to disk or not before returning.


@StevenBarlow: so to get what you were asking for (at least partially), you'd want to make sure those write options were set to Persist.



--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/1C769754-EE1A-422C-92F6-505212124D49%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Jens Alfke

unread,
Oct 9, 2014, 2:08:48 PM10/9/14
to mobile-c...@googlegroups.com

On Oct 9, 2014, at 9:59 AM, Traun Leyden <traun....@gmail.com> wrote:

I talked to the couchbase server support folks, and they pointed me to the options for the Set command which control whether it's persisted to disk or not before returning.


@StevenBarlow: so to get what you were asking for (at least partially), you'd want to make sure those write options were set to Persist.

I'm confused. The initial question was about a PUT to Sync Gateway. But the answer above is about writing directly to Couchbase Server (using the go-couchbase library.) Those are very different things.

At the Sync Gateway REST API level, if we were to add an option to wait for persistence it should be implemented as a handler for /db/_ensure_full_commit, which is the CouchDB equivalent. (The handler actually exists already but currently does nothing.)

—Jens

Traun Leyden

unread,
Oct 9, 2014, 2:44:07 PM10/9/14
to mobile-c...@googlegroups.com
I'm confused. The initial question was about a PUT to Sync Gateway. But the answer above is about writing directly to Couchbase Server (using the go-couchbase library.) Those are very different things.

Yes, ultimately the question is related to how PUT's to Sync Gateway behave, in terms of blocking behavior with respect to waiting for disk persistence.  I was working backwards from the Couchbase Server blocking behavior, since it seems like that would determine the Sync Gateway behavior.  
 
At the Sync Gateway REST API level, if we were to add an option to wait for persistence it should be implemented as a handler for /db/_ensure_full_commit, which is the CouchDB equivalent. (The handler actually exists already but currently does nothing.)

I didn't know about  /db/_ensure_full_commit.  That sounds similar (but not identical) to what Steven was asking for: it sounded like he wanted (and @Steven please jump in and correct me if I'm wrong), was to be able to configure Sync Gateway such that *every* PUT request blocks until the data is actually persisted to disk, with no extra api calls needed.  His concerns focus around application correctness and take priority over performance.

Would modifying Sync Gateway to set WriteOptions=Persist achieve this?  (I'm not suggesting this is the best way to do it, just want to understand if it would actually achieve the result)

Jens Alfke

unread,
Oct 9, 2014, 4:09:57 PM10/9/14
to mobile-c...@googlegroups.com

On Oct 9, 2014, at 11:44 AM, Traun Leyden <traun....@gmail.com> wrote:

His concerns focus around application correctness and take priority over performance.
Would modifying Sync Gateway to set WriteOptions=Persist achieve this?

I don't think I'm qualified to answer that. There are people at Couchbase you could ask directly, or you or Steven could ask on the Couchbase Server areas of the new dev forums.

—Jens
Reply all
Reply to author
Forward
0 new messages