Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DA5DD797A for ; Mon, 1 Aug 2011 22:30:07 +0000 (UTC) Received: (qmail 25065 invoked by uid 500); 1 Aug 2011 22:30:06 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 25014 invoked by uid 500); 1 Aug 2011 22:30:05 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 25006 invoked by uid 99); 1 Aug 2011 22:30:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Aug 2011 22:30:05 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of randall.leeds@gmail.com designates 209.85.210.180 as permitted sender) Received: from [209.85.210.180] (HELO mail-iy0-f180.google.com) (209.85.210.180) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Aug 2011 22:30:01 +0000 Received: by iyh42 with SMTP id 42so11464201iyh.11 for ; Mon, 01 Aug 2011 15:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=w8D+v6roqDIF9HYbcA3hU6JE0NVz020ePmVmpCttNzw=; b=bHvMdK+tGMCFOrFLw+iWRkO9EfKvNz4RmvzvHyUor1fN9LV3b5BEHFmbFwodJThjav aoFoXdKLHpozzuiCVuLsDCHz1A/gzLqzn85ZhkehVFa3rv2XVmivYEzcp9SlR3K9TPDw QUMbjhSOkWWWbhxS007UOFWqVK15IpNlEvnP8= MIME-Version: 1.0 Received: by 10.42.196.69 with SMTP id ef5mr3104667icb.30.1312237779244; Mon, 01 Aug 2011 15:29:39 -0700 (PDT) Received: by 10.42.175.202 with HTTP; Mon, 1 Aug 2011 15:29:39 -0700 (PDT) In-Reply-To: References: Date: Mon, 1 Aug 2011 15:29:39 -0700 Message-ID: Subject: Re: Guys with deep knowledge about CouchDB Replication, I'd need your help :) From: Randall Leeds To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Jul 29, 2011 at 04:12, Michael Aufreiter wrote: > > Nice. Having a look at it. > > It really depends on how much functionality you wanna delegate to the cli= ent. In my opinion, in most cases you wan't to keep the amount of local dat= a low. That's why I'll probably use localstorage to memoize a complete snap= shot of the current graph. Once you reload the page all data is loaded into= memory again (restored) and you can query it as usual (using Data.Graph#fi= nd). So in my case I'd rather wanna use just LocalStorage without employing= indexedDB etc. as local views(map-reduce etc) wouldn't be an requirement h= ere. But what I need to solve is the replication thing. To solve replication and safely allow the application to be used across tabs you need indexedDB because it has transactions. Let me break that deduction down: Incremental replication requires a restart-able changes feed. A changes feed requires an index of updates order by time/sequence number. A sequence index that's kept in sync with the index of documents ordered by name requires changes to two indexes in an atomic transaction or race conditions are possible. If you're not worried about replicating incrementally or you're not worried about the possibility of race conditions (e.g., concurrent access by multiple tabs) you might be able to use LocalStorage, otherwise you'll need IndexedDB. Since PouchDB aims to be a robust and general-purpose implementation of CouchDB it uses IndexedDB. -Randall > > On Thursday, July 28, 2011 at 6:18 PM, Max Ogden wrote: > > > beginnings of an html5 couch: https://github.com/mikeal/pouchdb > > > > it would be great to get @mikeal and @tilgovi to chime in on this > > thread as they were writing the replicator for that > > > > On Thu, Jul 28, 2011 at 11:48 AM, Michael Aufreiter wrote: > > > I'm currently working on a complete data-persistence solution for off= line apps, involving CouchDB and Data.js. I already introduced Data.js here= at this mailing list the other day, but here's a link again: > > > > > > http://substance.io/#michael/data-js > > > > > > I've setup a cleanroom example (tasks) that I want to test the new sy= nc-functionality against. > > > > > > http://tasks.substance.io (don't miss the sync button in the upper ri= ght corner) > > > https://github.com/michael/data/blob/7729d41677e48bd5132119997dc0cff5= 3522bb55/examples/tasks/public/javascripts/views/app.js > > > > > > It's currently just one way. It just writes changes to the server but= does not pull in node-updates. Now this should change. > > > > > > The algorithm for a bi-directional sync I have in mind looks like so: > > > > > > 1. Pull: For all nodes I have in my local graph, check if there are u= pdates (other users might have updated them), and if yes, pull them in > > > If conflicts occur the client/user decides how to resolve it (choose = a revision or merge it) > > > > > > 2. Push: Write all local dirty nodes to the server > > > > > > If that succeeded, the sync is complete. Usually if there's not much = time between the pull and the push it's unlikely to run into conflicts when= doing the push. > > > > > > However I'm asking myself how CouchDB replication is implemented -- m= aybe I can re-use some of the concepts. > > > > > > In order to perform the Pull, I thought about sending a list of ID's+= revisions to the server. The server (resp. Couch) should then check if ther= e are updates for any of them. If yes, those nodes should be fetched and de= livered to the client. Given that number of ID/revision pairs, what would b= e the best way to check for updates? Or do you have any other ideas on how = to do the pull? > > > > > > An implication of this scenario is that application developers should= do their best to keep the local graph rather small (the bigger it gets the= more overhead you have when doing the push, also more memory is used). How= ever this should suit a lot of scenarios (like in my case making possible o= ffline editing of Substance.io (http://Substance.io) documents) > > > > > > Would be great if some of you could help me out a bit here. I think s= uch a framework (Data.js+Couch) would be a great benefit for application de= velopers who wan't to build offline apps. What do you think? > > > > > > Thanks! > > > > > > -- Michael > >