Return-Path: X-Original-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5EDF8E9B3 for ; Thu, 7 Mar 2013 10:07:06 +0000 (UTC) Received: (qmail 83465 invoked by uid 500); 7 Mar 2013 10:07:06 -0000 Delivered-To: apmail-jackrabbit-oak-dev-archive@jackrabbit.apache.org Received: (qmail 83348 invoked by uid 500); 7 Mar 2013 10:07:05 -0000 Mailing-List: contact oak-dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-dev@jackrabbit.apache.org Received: (qmail 83305 invoked by uid 99); 7 Mar 2013 10:07:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Mar 2013 10:07:04 +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 (nike.apache.org: domain of jukka.zitting@gmail.com designates 209.85.219.47 as permitted sender) Received: from [209.85.219.47] (HELO mail-oa0-f47.google.com) (209.85.219.47) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Mar 2013 10:06:57 +0000 Received: by mail-oa0-f47.google.com with SMTP id o17so329859oag.20 for ; Thu, 07 Mar 2013 02:06:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:from:date:message-id:subject:to :content-type; bh=VGu/uQCuZTZTTyHXJ/q/mPWCgm3dCJNpgTH2w/u5foo=; b=s9kjqwX825IIjr1ioWRTP2Q1LHsa/6qjOolkr3XmDeoWwrrxlH6jzM1omKlIoVoMuv bHu7MdhgH5zhCpaP/EYvpPlEi24rR4KVJ8KWbuOaobAjZmmx8l9MjG5uCjcSpW84m43R spZ3hdF+MI8Sn14MgPp/r5Ky+j1ilO0IxBoiEm11tP1csK+sUn7qU3wfOmWcaB47J2Ef 8Wcfslsv8YISXhOL4QjBM2+KtUYipEduccaPBFeeF94SSXoQ3LH3V6T3bBESIqMvBU5S Ym700uoyNQo0ymrYIrsiYEHNEdLwReDO0X3WqIDNWxXDl3szzBydXhNHhM4L1/8egOBJ 7ZXQ== X-Received: by 10.182.39.69 with SMTP id n5mr25993631obk.72.1362650796927; Thu, 07 Mar 2013 02:06:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.132.20 with HTTP; Thu, 7 Mar 2013 02:06:16 -0800 (PST) From: Jukka Zitting Date: Thu, 7 Mar 2013 12:06:16 +0200 Message-ID: Subject: When optimistic locking fails To: Oak devs Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Hi, There are a few scenarios where the optimistic locking approach used by the SegmentMK fails in practice: 1) A large batch operation while other smaller changes are being committed. 2) Lots of concurrent changes being committed against the same journal. In scenario 1 the large operation like an import can't complete itself since while it is rebasing itself and re-applying commit hooks other smaller operations have already updated the journal, triggering new rounds of rebasing and hook processing for the large operation until it bails out with the "System overloaded" exception. In scenario 2 the same "System overloaded" exception occurs once there are too many concurrent changes for the system to keep up with when using just a single journal. As noted by Marcel and others, this case comes up pretty quickly in a benchmark that explicitly tries to push the system to the limit. While in scenario 2 the "System overloaded" exception is a valid alternative to a potentially prolonged wait until the commit can go through, in scenario 1 it is clearly troublesome. Thus I'd like to address it, and the solution I have in mind actually works for both cases: When encountering a case where the optimistic locking mechanism can't push a commit through in say one second, instead of waiting for a longer while I'd have the SegmentMK fall back to pessimistic locking where it explicitly acquired a hard lock on the journal and does the rebase/hook processing one more time while holding that lock. This guarantees that all commits will go through eventually (unless there's a conflict or a validation failure), while keeping the benefits of optimistic locking for most cases. And even for scenario 1 the bulk of the commit has already been persisted when the pessimistic locking kicks in, so the critical section should still be much smaller than with Jackrabbit 2.x where the lock is held also while the change set is being persisted. BR, Jukka Zitting