Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 37375 invoked from network); 5 Jan 2010 05:22:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Jan 2010 05:22:01 -0000 Received: (qmail 68408 invoked by uid 500); 5 Jan 2010 05:22:00 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 68260 invoked by uid 500); 5 Jan 2010 05:21:59 -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 68250 invoked by uid 99); 5 Jan 2010 05:21:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jan 2010 05:21:59 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jchris@gmail.com designates 209.85.160.56 as permitted sender) Received: from [209.85.160.56] (HELO mail-pw0-f56.google.com) (209.85.160.56) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jan 2010 05:21:49 +0000 Received: by pwi19 with SMTP id 19so10810795pwi.35 for ; Mon, 04 Jan 2010 21:21:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=fPig0NxSjgQjLwlMzGzaa2hychi8DfTGDXa1AgjHLsA=; b=DQubL/SMoelgbZM3TRzRD3BeHkNr/wRk56QKJwEAuQ3GJndTWnqxpq9bDMrP7Yq9dL I5iPlGcA1HLE1FIo3C0t2sEDVjFikkgoDx3JnorTWdtCUcc6ukWpksHgsNfdfhweKU0h SqZr2fpRPsWzSPQo1OLcXG0O9ZRBDQTgAFBWA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=jFBtvwXZvbVUPqJBptJ0gtg5UbtYpgF8+Sz2I+ORo64EAaCkN8GF4Ce33vWCag2D/T EXuZKmt/MAa3VqaQxhvnGKatIZ0khLh5pwI9OQYWBXF8hEdJX+QdIli/vYF+bMOxQ3k6 AKNU1XEaGqLEm9UJ7XSczmxaIqoAMmXMNRv9Q= MIME-Version: 1.0 Sender: jchris@gmail.com Received: by 10.142.122.11 with SMTP id u11mr2528905wfc.21.1262668888087; Mon, 04 Jan 2010 21:21:28 -0800 (PST) In-Reply-To: <4B42D67D.2090401@gmail.com> References: <4B42B68B.2070403@gmail.com> <4B42D67D.2090401@gmail.com> Date: Mon, 4 Jan 2010 21:21:27 -0800 X-Google-Sender-Auth: a83377da1a76e774 Message-ID: Subject: Re: Dealing with Atomic Operations From: Chris Anderson To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Mon, Jan 4, 2010 at 10:04 PM, Andreas Pavlogiannis wrote: > On 1/4/2010 10:58 AM, Chris Anderson wrote: >> >> On Mon, Jan 4, 2010 at 7:48 PM, Andreas Pavlogiannis >> =A0wrote: >> >>> >>> Hello, >>> >>> I 've been experimenting with Couchdb and I have reached a point in whi= ch >>> I >>> need to do some transactions in an atomic way. I know that Couchdb lack= s >>> locking, so is there a uniform way to deal with this? >>> In particular, I have created a filesystem in which each file and folde= r >>> is >>> represented by a single document, while its pathname is a list. For >>> example: >>> >>> ['root', 'home'] >>> ['root', 'home', pictures'] >>> ['root', 'home', 'pictures', 'picture.jpg'] >>> >>> Now, when creating the document with pathname ['root', 'home', pictures= ', >>> 'my_dog.jpg'], I need to make sure that its parent, ['root', 'home', >>> pictures'] exists in the db. Moreover, I need to ensure that the user i= s >>> not >>> exceeding his quota. >>> >> >> Why do you need the parent to exist? You can use views to create >> parents "virtually." This way each file would have a path, and you >> could use a view to sort all files so that those in paths and subpaths >> together are listed together. There is no need for a document to >> denote the existence of an empty directory. >> >> If you need to model directory permissions, then it makes sense to >> have a document for that directory, but this also doesn't seem like it >> needs to be transactionally checked / modified with the creation of >> new files. >> > > I need to ensure that when creating a new > document, its parent exists in the db. If you drop this constraint, you should still be able to handle the business case, while doing away with a bunch of complexity. > > Hm, what about the case in which =A0a user =A0has enough space to upload = just > one file, but several upload requests arrive concurrently. As these reque= sts > are handled locally, each one will allow for the document to be submitted= . > But in this way the user can exceed his quota unboundedly (extreme scenar= io, > but possible). >> You can always handle uploads by setting a custom piece of data in the validation function. if you run a view query to say what the users free space is, you can use this to reject oversize attachment uploads. Still, I'd rather accept all uploads, and initiate a billing system action or something when they cross the threshold. --=20 Chris Anderson http://jchrisa.net http://couch.io