Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9B80C200B39 for ; Sat, 25 Jun 2016 02:59:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 9A051160A5A; Sat, 25 Jun 2016 00:59:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B693D160A58 for ; Sat, 25 Jun 2016 02:59:05 +0200 (CEST) Received: (qmail 63468 invoked by uid 500); 25 Jun 2016 00:59:04 -0000 Mailing-List: contact dev-help@asterixdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.apache.org Delivered-To: mailing list dev@asterixdb.apache.org Received: (qmail 63456 invoked by uid 99); 25 Jun 2016 00:59:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Jun 2016 00:59:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 286531A5DC5 for ; Sat, 25 Jun 2016 00:59:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.179 X-Spam-Level: ** X-Spam-Status: No, score=2.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_REPLY=1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id ssjZ5GY0_s2S for ; Sat, 25 Jun 2016 00:59:01 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 4933B5F36A for ; Sat, 25 Jun 2016 00:59:01 +0000 (UTC) Received: by mail-lf0-f49.google.com with SMTP id f6so125269372lfg.0 for ; Fri, 24 Jun 2016 17:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=6iXxp/wrlI3aT0cI2BT1XoHPQN0ludRrtKrRU5Ist/E=; b=qFCoI5WPMSlPY4kG9tSpSmBf7/KI64Tx6CRYalKJMB9ZmdOQg3mxEHyd+qAvsT4FL1 Mkj7ophK4aEJgJQCbtKZMTOA5cNrL05LEIOypzqvdQ4xbN9Cd7AAbpRd75O7/Z6NYikC si2uTKHQeReRlrywz3hBCHN9XvNEhyG+5ZFtfM566Fi4sMdUDpLY66kThEIwAGSzZvO+ BQZCosTBKYVH9wmOJAyKo0n369yYu08yIm1tEByojMpGLeXvSLgULzzOlMrmJrZX8gBd JDHurgdnOr5G9sE/IZjtg3UMj2YiCIFNfXxhfT0KX3cpjIh6ACbWvSodswpwOzREQEdg uZlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=6iXxp/wrlI3aT0cI2BT1XoHPQN0ludRrtKrRU5Ist/E=; b=NaFic3YYO5EIpe+hvgD1lqLiMI5p7NorSy5XkcXRoJZxUzIlXgCTXDhCnNsmDcdbV0 gNewJDE1F6ilFkm7E6VJ1uXIBhpUvMRkI/rq/yfjkUne40c1NlTG1Xh7Y8U9MusUT8wl ZMM3wEhnwvpyZydZ+jxgIEH5qCYnEbpffc5Ha8kgXwksISfZ9dFikr1Icfmhm/ajH+pj 4O8yOTutGXK6F9uNb9zALx4qXRP9252UkbXa7+mjS4FM67pqG3DqQbvf22KqBgOPcMd2 1n3MCvT5GhyHZFuG1euirsu1b82tVfWIJ2DTXQp5vydePbXQsceTCdtRwwD8xSEp5Zit TYUg== X-Gm-Message-State: ALyK8tIl33xyY6+hLPXVQv8yQFRMnJ3GQs9VXhhoF8VTaFLEfF47OV2clWjEnmWsj+1LzJazJ5jHLmMeDUbXRQ== X-Received: by 10.46.32.42 with SMTP id g42mr1984100ljg.31.1466816340739; Fri, 24 Jun 2016 17:59:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.114.80.233 with HTTP; Fri, 24 Jun 2016 17:59:00 -0700 (PDT) In-Reply-To: <37afca89-6b3f-eb0a-0fa6-24488f33752d@gmail.com> References: <28d2f3ba-f682-9d10-3045-6a23b645ffcd@gmail.com> <37afca89-6b3f-eb0a-0fa6-24488f33752d@gmail.com> From: Young-Seok Kim Date: Fri, 24 Jun 2016 17:59:00 -0700 Message-ID: Subject: Re: Delete transactions To: dev@asterixdb.apache.org Content-Type: multipart/alternative; boundary=001a1142ca64f0c90205360fca05 archived-at: Sat, 25 Jun 2016 00:59:06 -0000 --001a1142ca64f0c90205360fca05 Content-Type: text/plain; charset=UTF-8 Non-instant read locks will break the deadlock-free locking protocol that we achieved currently since the necessary condition for the deadlock, i.e., hold-and-wait situation will come back alive. Best, Young-Seok On Fri, Jun 24, 2016 at 5:49 PM, Mike Carey wrote: > Got it and agreed. Would another solution be to retain the (no longer > instant) lock? (What can of worms would that open?) > > > > On 6/24/16 5:09 PM, Young-Seok Kim wrote: > >> Please see inline below. >> >> Best, >> Young-Seok >> >> On Fri, Jun 24, 2016 at 4:35 PM, Mike Carey wrote: >> >> So to clarify, record-level consistency (and primary/secondary index >>> consistency) is guaranteed and will work "correctly" in all cases if a >>> record R is updated (or deleted) by T2 after being targeted (by primary >>> key) for deletion by T1. >>> >> Yes, agreed on. >> >> >> The only semantic issue is that there is a (hopefully very, very small) >>> window of time between when T1 sees R in a secondary index and when it >>> acquires for the lock on R's primary key - during which T2 could change R >>> in a way that makes it no longer query-compliant. >>> >> Here, let me clarify the above sentence: "when it acquires for the lock on >> R's primary key" means that the lock is acquired and released by T1 since >> the lock was an instant shared-mode(read) lock. So, T2 can change R after >> acquiring an exclusive lock and consequently the R is not qualified for >> the >> query predicate anymore. >> >> >> (However, at its time of being observed - which happened under >>> read-committed - it was a correct candidate for deletion. So this is >>> kind >>> of "expected" but admittedly kind of weird. It seems like this could >>> maybe >>> be fixed in the future via a mechanism similar to the index-only branch's >>> way of handling locks?) >>> >> This expected but undesired situation can be avoided by introducing a >> version number which will be stored as a field (which is not exposed to >> users) in each entry of the primary index and the secondary indexes such >> that the version number can be used to verify that the record searched >> during the search phase is the same record to be deleted during the delete >> phase. If the verification is succeeded, the delete will be performed. >> Otherwise, it will not. >> >> >> >>> >>> On 6/24/16 10:59 AM, Young-Seok Kim wrote: >>> >>> This is somewhat expected issue by having read-committed isolation level >>>> based on strict 2PL locking protocol. >>>> The strict 2PL guarantees that all acquired exclusive locks by a >>>> transaction can be released after the transaction is committed. >>>> But, read lock doesn't follow this. >>>> So, as you described in the email, a record read by a transaction, T1 >>>> during search can be modified by another transaction T2 before the >>>> record >>>> is deleted by T1. This is a possible situation under the read-committed >>>> isolation level. >>>> However, there is no inconsistency between a primary index and secondary >>>> indexes in the way that the modified record by T2 is deleted by T1 from >>>> the >>>> primary index and the corresponding secondary index entry may not be >>>> deleted by T1. This is because when T1 starts deleting process through >>>> the >>>> job pipeline, an exclusive lock for the record is first acquired and >>>> then >>>> the delete operations in primary and secondary indexes are performed. >>>> So, >>>> either case1) the record should exist with the identical primary key for >>>> the record to be deleted by T1 (since the search will deliver the >>>> primary >>>> key, not the complete record) or case2) the record will not be deleted >>>> by >>>> T1 if the record with the primary key does not exist. >>>> >>>> For case1), once a record is deleted from the primary index, all rest of >>>> secondary indexes in the job pipeline correctly find and delete the >>>> corresponding secondary index entries. >>>> For case2), I need to check the behavior whether the job pipeline throws >>>> an >>>> exception due to trying to delete the non-existing record and stops >>>> proceeding the job by aborting the job, or the exception is just >>>> swallowed >>>> and the job proceeds for the next record. >>>> >>>> Best, >>>> Young-Seok >>>> >>>> >>>> On Fri, Jun 24, 2016 at 10:14 AM, abdullah alamoudi >>> > >>>> wrote: >>>> >>>> Hi everyone, >>>> >>>>> I think we have a problem related to the deletes transaction >>>>> behavior:here >>>>> is the problem: >>>>> >>>>> Our delete starts by searching the tree to identify delete tuples based >>>>> on >>>>> the delete statement conditional clause. It follows that by inserting >>>>> delete tuples in primary index, followed by updating secondary indexes, >>>>> followed by a commit on the PK >>>>> >>>>> The problem happens if after searching the tree and identifying the >>>>> records >>>>> to be deleted, one of those records was updated. This will cause the >>>>> record >>>>> to be deleted in the primary index even though it might not meet the >>>>> conditional clause. Moreover, the new entries in the secondary indexes >>>>> will >>>>> remain without their record in the primary index. >>>>> >>>>> In order to fix this, we need to do one of the following: >>>>> 1. lock the records when we do the search to identify the records to be >>>>> deleted >>>>> OR >>>>> 2. when performing the delete, we double check that the record we're >>>>> deleting is the same as the record we find when we do the actual delete >>>>> >>>>> A better way would be to perform the delete as we do the search since >>>>> there >>>>> is no need to do the whole search, materialize then perform the delete. >>>>> >>>>> There is a change I got something wrong. Did I? Thoughts? >>>>> >>>>> >>>>> > --001a1142ca64f0c90205360fca05--