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 6D964E4D4 for ; Tue, 18 Dec 2012 21:36:25 +0000 (UTC) Received: (qmail 77139 invoked by uid 500); 18 Dec 2012 21:36:23 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 76978 invoked by uid 500); 18 Dec 2012 21:36:23 -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 76952 invoked by uid 99); 18 Dec 2012 21:36:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Dec 2012 21:36:23 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ciprian.craciun@gmail.com designates 209.85.215.172 as permitted sender) Received: from [209.85.215.172] (HELO mail-ea0-f172.google.com) (209.85.215.172) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Dec 2012 21:36:16 +0000 Received: by mail-ea0-f172.google.com with SMTP id a1so512011eaa.31 for ; Tue, 18 Dec 2012 13:35:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=gr9yoUOC8S4x1fuUH35q1WIh8kHfjpAEfbDTAnGlqDU=; b=CXInxvAwVM1hh8A2mh/lC4MUhqPnv+ensoyXUmsbFM5EZTH5whdR7Q39CUIQ+Q/1xk hGrZC1nMs20RmKNNrI6L9b6rmY9vsoHZ+Duf8iHuaVYXil/B8Je0LYGqdez22jDa+jrB TtlB61Y7pYJTlKZl9cj3Chq10nshuc9vZT2GmCuaN8AVulC+5oGuFGdWC6Wzd7R9VU9A S6CVwlWy1x+GtV16CEiyM3kmEMW2h509DkzFblICjzt0ZoHCaIYTR/fBjvjoy3yD1PIx LWbYT8S9dE0thJJyKmh5innYYODkAiFDMk0rNebgKa8sMRnw6t/xs/QKNNWYOlHJg3+0 deXQ== MIME-Version: 1.0 Received: by 10.14.202.3 with SMTP id c3mr9137513eeo.4.1355866554893; Tue, 18 Dec 2012 13:35:54 -0800 (PST) Received: by 10.14.129.202 with HTTP; Tue, 18 Dec 2012 13:35:54 -0800 (PST) Date: Tue, 18 Dec 2012 23:35:54 +0200 Message-ID: Subject: Simple "transactional" access (i.e. "repeatable reads") (related to `last_seq` for previous revisions) From: Ciprian Dorin Craciun To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org Hello all! Previously I've written an email inquiring about how to get `last_seq` on previous revisions of an object. The purpose of that is described below. I intend to use CouchDB as a backend for a configuration management solution. For this I need a way to achieve the following: simple "repeatable reads" transactions... !!!! Now before everyone starts shouting at me that this is not the purpose of CouchDB, or even achievable, I say to my defense that I know that... I don't want transactions in the SQL sense, I just want "repeatable reads"... :) All I want to achieve is the following: * given that the configuration of a service is composed of multiple documents inside a database; (with multiple service configurations sharing the same database;) * given that all updates that touch a configuration's documents, are made in a single request of the bulk write (with atomic set to true); * I want to be able to read "consistent" revisions of a particular document graph, regardless of other write operations that have happened; I think I could achieve this by using "multiple" get, but I'm unsure, and moreover I don't know before hand which documents are needed. To achieve this I though about the following simple algorithm which provides me with a limited MVCC-like solution: * before reading or writing I read the last sequence number of the entire database; (I call this the "session sequence";) * when reading a document I first "stat" it's latest revision and see if it's sequence is less or equal to that of the session; ** if not I read a revision back and check again; (I stop after reading a couple of revisions and give an error); * (up to this point all read documents are either coming from unrelated "write sessions" or were written inside the same "write session", but I can't have them mixed); * I repeat the above for any needed document; * any document to be written is batched inside a single bulk write with atomic set to true; * if any conflict existed I go to step one; As seen I try to use time limited document versioning, to achieve some kind of "repeatable reads" transactions. As such, are there other ideas, observations, solutions? Thanks, Ciprian.