Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g1e2V-0001gN-FR for pgsql-general@arkaria.postgresql.org; Sun, 16 Sep 2018 20:53:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g1e2T-0006Ts-MW for pgsql-general@arkaria.postgresql.org; Sun, 16 Sep 2018 20:53:05 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g1e2T-0006Tl-40 for pgsql-general@lists.postgresql.org; Sun, 16 Sep 2018 20:53:05 +0000 Received: from mail-qt0-x232.google.com ([2607:f8b0:400d:c0d::232]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g1e2L-0007Mo-H0 for pgsql-general@postgresql.org; Sun, 16 Sep 2018 20:53:03 +0000 Received: by mail-qt0-x232.google.com with SMTP id j7-v6so13607141qtp.2 for ; Sun, 16 Sep 2018 13:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=JGfCPz8JIQI0H9WqFbVolLg8ExlzhkyPaAsHblUDeqg=; b=MBzUP7BtATMeGgQ7gW/DFlidSj4c2Kwft6/HgcLsdEdeUrL+I+c4veV/44sDCuuycv V4joWvxMhesz5wkS1S5r5xIYGNqIQwiqSdU/nHnEPLprWruCA63cdaVoTDNYQCGKWjgA ZlOLTImyF60TDOfV3OhhIckf//v4yMHp9uzrXO/LqAvJEM0uWpEd+QhQNY0WVjmkjA3J WgfKD1Gz03jusfG99yOsOSjyBPlBD2uXYtMOPm5fO8XUIKHmPpNuotUUIylsbQVhlsVf O/2WLvv1nmNwo1tIhb1Kb/fJsg4s5YOvK5JSjhiqI7cIwRPITykX+LKvbrvmf5XeeHD7 C73A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=JGfCPz8JIQI0H9WqFbVolLg8ExlzhkyPaAsHblUDeqg=; b=OSkP7/qyif505VHn3bjw9PyVvcCgMfrIi90vm/efWEQM2EgViVrSiRiHr0xkZC2wV+ c0LmTRtBOA5yFt+9WSD5k1Sj9/Cmd+X3a6IeD25Z0jQyI9R+soZNTJX3Xkll4ZtX0gkL TZK96uZt0yD+Frpwxh98dPvY8xsLxsx00oOb/rtl51wtMIRYZsbO50GiWCfugKq8ILrD rtGjAVNHBwM6NnJOWC2GgNiJFIvu1xW2Kmjg9Mcs75jirc6hzQlecC+EfX/yxZ5AnpMb 4EBLttGMZ7zGX1dCsK4czcueL/B3g0iBk9ostPVCsRGhde63Nw+X9isUSX/MdxyFFFFX y4mQ== X-Gm-Message-State: APzg51A1CrNLrVXkkXBd4BW+q33ykRLPZPvfTnEJzu0eKuu7TlBR+VVz Eg8WnFQVm4TTHF4UpC33sz4mfMFw X-Google-Smtp-Source: ANB0VdbUG3viuk1lRswFI9hEqiouAduILU7mJZGGqvLVjsbJkzN0njZeURVCTzdDfDeEaVfThrdR8A== X-Received: by 2002:ac8:f2e:: with SMTP id e43-v6mr15143201qtk.262.1537131176343; Sun, 16 Sep 2018 13:52:56 -0700 (PDT) Received: from [192.168.1.250] (host130.190-229-77.telecom.net.ar. [190.229.77.130]) by smtp.gmail.com with ESMTPSA id k126-v6sm6950344qkb.91.2018.09.16.13.52.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Sep 2018 13:52:55 -0700 (PDT) To: "pgsql-general@postgresql.org" From: marcelo Subject: Logical locking beyond pg_advisory Message-ID: <8d7f3295-c2d6-ef00-1300-4f6db798f76e@gmail.com> Date: Sun, 16 Sep 2018 17:52:52 -0300 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------DCDDF92F2C645E99AED988C3" Content-Language: en-US X-Antivirus: Avast (VPS 180916-4, 16/09/2018), Outbound message X-Antivirus-Status: Clean List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------DCDDF92F2C645E99AED988C3 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable I need a mechanism of "logical locking" more ductile than the pg_advisory family. I'm thinking of a table ("lock_table") that would be part of the database, with columns * tablename varchar - name of the table "locked" * rowid integer, - id of the row "locked" * ownerid varchar, - identifier of the "user" who acquired the lock * acquired timestamp - to be able to release "abandoned" locks after a certain time and a group of functions 1) lock_table (tablename varchar, ownerid varchar) bool - get to lock over the entire table, setting rowid to zero 2) unlock_table (tablename varchar, ownerid varchar) bool - unlock the table, if the owner is the recorded one 3) locked_table (tablename varchar, ownerid varchar) bool - ask if the table is locked by some user other than the ownerid argument 4) lock_row (tablename varchar, rowid integer, ownerid varchar) bool - similar to pg_try_advisory_lock 5) unlock_row (tablename varchar, rowid integer, ownerid varchar) bool - similar to pg_advisory_unlock 6) unlock_all (ownerid varchar) bool - unlock all locks owned by ownerid The timeout (default, maybe 15 minutes) is implicitly applied if the lock is taken by another user (there will be no notification). Redundant locks are not queued, they simply return true, may be after an update of the acquired column. Successful locks insert a new row, except the rare case of a timeout, which becomes an update (ownerid and acquired) Unlock operations deletes the corresponding row My question is double a) What is the opinion on the project? b) What are the consequences of the large number of inserts and deletions c) Performance. In fact, pg_advisory* implies a network roundtrip, but (I think) no table operations. TIA --- El software de antivirus Avast ha analizado este correo electr=C3=B3nico en= busca de virus. https://www.avast.com/antivirus --------------DCDDF92F2C645E99AED988C3 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit I need a mechanism of "logical locking" more ductile than the pg_advisory family.
I'm thinking of a table ("lock_table") that would be part of the database, with columns
* tablename varchar - name of the table "locked"
* rowid integer, - id of the row "locked"
* ownerid varchar, - identifier of the "user" who acquired the lock
* acquired timestamp - to be able to release "abandoned" locks after a certain time

and a group of functions
1) lock_table (tablename varchar, ownerid varchar) bool - get to lock over the entire table, setting rowid to zero
2) unlock_table (tablename varchar, ownerid varchar) bool - unlock the table, if the owner is the recorded one
3) locked_table (tablename varchar, ownerid varchar) bool - ask if the table is locked by some user other than the ownerid argument
4) lock_row (tablename varchar, rowid integer, ownerid varchar) bool - similar to pg_try_advisory_lock
5) unlock_row (tablename varchar, rowid integer, ownerid varchar) bool - similar to pg_advisory_unlock
6) unlock_all (ownerid varchar) bool - unlock all locks owned by ownerid

The timeout (default, maybe 15 minutes) is implicitly applied if the lock is taken by another user (there will be no notification).
Redundant locks are not queued, they simply return true, may be after an update of the acquired column.
Successful locks insert a new row, except the rare case of a timeout, which becomes an update (ownerid and acquired)
Unlock operations deletes the corresponding row

My question is double
a) What is the opinion on the project?
b) What are the consequences of the large number of inserts and deletions
c) Performance. In fact, pg_advisory* implies a network roundtrip, but (I think) no table operations.

TIA


Libre de virus. www.avast.com
--------------DCDDF92F2C645E99AED988C3--