Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The solution to a problem changes the nature of the problem. -- Peer


devel / comp.databases.ingres / Triggers and locks

SubjectAuthor
* Triggers and locksFabrizio Di Renzo
+* Re: Triggers and locksRoy Hann
|`- Re: Triggers and locksG Jones
`* Re: Triggers and locksFabrizio Di Renzo
 `- Re: Triggers and locksRoy Hann

1
Triggers and locks

<757cd439-a568-4385-ad7e-b1bb6bf12a97n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=285&group=comp.databases.ingres#285

  copy link   Newsgroups: comp.databases.ingres
X-Received: by 2002:a0c:ed46:0:b0:655:d3d2:4db4 with SMTP id v6-20020a0ced46000000b00655d3d24db4mr173668qvq.6.1694511606176;
Tue, 12 Sep 2023 02:40:06 -0700 (PDT)
X-Received: by 2002:a17:902:f686:b0:1c1:f00a:64d5 with SMTP id
l6-20020a170902f68600b001c1f00a64d5mr5032768plg.4.1694511605939; Tue, 12 Sep
2023 02:40:05 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.databases.ingres
Date: Tue, 12 Sep 2023 02:40:05 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=93.63.171.9; posting-account=o45aTQoAAAC0zpFKFFtE1KNZ5g5HYdBB
NNTP-Posting-Host: 93.63.171.9
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <757cd439-a568-4385-ad7e-b1bb6bf12a97n@googlegroups.com>
Subject: Triggers and locks
From: fabrizio...@bucap.it (Fabrizio Di Renzo)
Injection-Date: Tue, 12 Sep 2023 09:40:06 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3443
 by: Fabrizio Di Renzo - Tue, 12 Sep 2023 09:40 UTC

Hi all,
we have over 2000 tables for which we want to register all insert, update and delete operations.
For this reason we have created rules that insert a row in a table that is used to store the operation performed.

These are the rules

create rule spider_insert_tab_01 AFTER INSERT ON tab_01 EXECUTE PROCEDURE prd_spider_update (cd_cliente = old.cd_cliente, cd_doc = old.cd_doc, nm_faldone = old.nm_faldone, nm_pratica = old.nm_pratica, gr_pratica = old.gr_pratica, tp_operazione = 1);
create rule spider_insert_tab_01 AFTER DELETE ON tab_01 EXECUTE PROCEDURE prd_spider_update (cd_cliente = old.cd_cliente, cd_doc = old.cd_doc, nm_faldone = old.nm_faldone, nm_pratica = old.nm_pratica, gr_pratica = old.gr_pratica, tp_operazione = 2);
create rule spider_insert_tab_01 AFTER UPDATE ON tab_01 EXECUTE PROCEDURE prd_spider_update (cd_cliente = old.cd_cliente, cd_doc = old.cd_doc, nm_faldone = old.nm_faldone, nm_pratica = old.nm_pratica, gr_pratica = old.gr_pratica, tp_operazione = 3);

create rule spider_insert_tab_02 AFTER INSERT ON tab_02 EXECUTE PROCEDURE prd_spider_update (cd_cliente = old.cd_cliente, cd_doc = old.cd_doc, nm_faldone = old.nm_faldone, nm_pratica = old.nm_pratica, gr_pratica = old.gr_pratica, tp_operazione = 1);
create rule spider_insert_tab_02 AFTER DELETE ON tab_02 EXECUTE PROCEDURE prd_spider_update (cd_cliente = old.cd_cliente, cd_doc = old.cd_doc, nm_faldone = old.nm_faldone, nm_pratica = old.nm_pratica, gr_pratica = old.gr_pratica, tp_operazione = 2);
create rule spider_insert_tab_02 AFTER UPDATE ON tab_02 EXECUTE PROCEDURE prd_spider_update (cd_cliente = old.cd_cliente, cd_doc = old.cd_doc, nm_faldone = old.nm_faldone, nm_pratica = old.nm_pratica, gr_pratica = old.gr_pratica, tp_operazione = 3);

This is the procedure

create procedure prd_spider_update (
cd_cliente VARCHAR(5) NOT NULL,
cd_doc VARCHAR(3) NOT NULL,
orario VARCHAR(2) NOT NULL,
nm_faldone INTEGER NOT NULL,
nm_pratica INTEGER NOT NULL,
gr_pratica INTEGER NOT NULL,
tp_operazione INTEGER NOT NULL
) AS
begin
INSERT INTO spider (cd_cliente, cd_doc ,nm_faldone, nm_pratica, gr_pratica, tp_operazione, tm_archiviaz)
SELECT :cd_cliente, :cd_doc, :nm_faldone, :nm_pratica, :gr_pratica, :tp_operazione, CURRENT_TIMESTAMP()
end

In this way, cuncurrency is generated on the table spider which causes locks on the database.
There is a way to force a row-level lock on the table spider?

Fabrizio

Re: Triggers and locks

<udpevj$1h2jo$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=286&group=comp.databases.ingres#286

  copy link   Newsgroups: comp.databases.ingres
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: specia...@processed.almost.meat (Roy Hann)
Newsgroups: comp.databases.ingres
Subject: Re: Triggers and locks
Date: Tue, 12 Sep 2023 10:36:35 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <udpevj$1h2jo$1@dont-email.me>
References: <757cd439-a568-4385-ad7e-b1bb6bf12a97n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 12 Sep 2023 10:36:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="29cd986c3eff8b7ca8097a1906de6f16";
logging-data="1608312"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194/6LVuAhUUgj2Np6T5xocSsR06AhmJYk="
User-Agent: XPN/1.2.6 (Street Spirit ; Windows)
Cancel-Lock: sha1:iUiSBh0JzFrItVGJwycsjiXxWtA=
 by: Roy Hann - Tue, 12 Sep 2023 10:36 UTC

Fabrizio Di Renzo wrote:

> Hi all, we have over 2000 tables for which we want to register all insert,
> update and delete operations. For this reason we have created rules that
> insert a row in a table that is used to store the operation performed.
>
> These are the rules
[snip]
> This is the procedure
>
> create procedure prd_spider_update (
> cd_cliente VARCHAR(5) NOT NULL, cd_doc VARCHAR(3) NOT NULL, orario
> VARCHAR(2) NOT NULL, nm_faldone INTEGER NOT NULL, nm_pratica INTEGER
> NOT NULL, gr_pratica INTEGER NOT NULL, tp_operazione INTEGER NOT NULL
> ) AS begin
> INSERT INTO spider (cd_cliente, cd_doc ,nm_faldone, nm_pratica,
> gr_pratica, tp_operazione, tm_archiviaz)
> SELECT :cd_cliente, :cd_doc, :nm_faldone, :nm_pratica,
> :gr_pratica, :tp_operazione, CURRENT_TIMESTAMP()
> end
>
> In this way, cuncurrency is generated on the table spider which causes
> locks on the database. There is a way to force a row-level lock on the
> table spider?

There is no way to turn on row-level locking in the DDL, if that is what
you are hoping for.

You can use SET LOCKMODE ON tablename WHERE LEVEL=ROW in every application.
Setting it using ING_SET (and ingsetenv) might make that a bit easier to
apply, but not everything respects ING_SET; it depends on what languages
your applications are written in.

There may be other ways to tackle the problem. You could consider using
auditdb to trawl the journal files and write an application to insert the
relevant output to a table. The application would not block itself.

Or maybe instead of inserting into spider in the prd_spider_update procedure,
raise an event and attach the arguments as a message. Then write a listener
for the events that would insert into spider, similar to the suggestion
above. (This would have the disadvantage that it could have already raised
an event when a subsequent rollback occurs.)

Or you could consider using HVR, but that costs money and there's a
learning curve.

(I haven't mentioned using MVCC because I assume your application is
using locking for consistency control. MVCC is far preferable to normal
row-level locking but the testing burden would probably be prohibitive
for a large existing application. You _can_ turn on MVCC for individual
tables, but it is probably imprudent to mix locking and MVCC so I won't
suggest it.)

Roy

Re: Triggers and locks

<950fbce7-29e4-4990-bdfd-4c919f3d12e2n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=287&group=comp.databases.ingres#287

  copy link   Newsgroups: comp.databases.ingres
X-Received: by 2002:a05:6214:911:b0:649:9ae9:290a with SMTP id dj17-20020a056214091100b006499ae9290amr270969qvb.4.1694529715152;
Tue, 12 Sep 2023 07:41:55 -0700 (PDT)
X-Received: by 2002:a05:6a00:c95:b0:68e:3012:fd6e with SMTP id
a21-20020a056a000c9500b0068e3012fd6emr5036534pfv.0.1694529714655; Tue, 12 Sep
2023 07:41:54 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.databases.ingres
Date: Tue, 12 Sep 2023 07:41:54 -0700 (PDT)
In-Reply-To: <udpevj$1h2jo$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=163.1.206.129; posting-account=WeWzrgoAAADuZDdxDgTJ3OtwovooLFLl
NNTP-Posting-Host: 163.1.206.129
References: <757cd439-a568-4385-ad7e-b1bb6bf12a97n@googlegroups.com> <udpevj$1h2jo$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <950fbce7-29e4-4990-bdfd-4c919f3d12e2n@googlegroups.com>
Subject: Re: Triggers and locks
From: geraint....@ndph.ox.ac.uk (G Jones)
Injection-Date: Tue, 12 Sep 2023 14:41:55 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1437
 by: G Jones - Tue, 12 Sep 2023 14:41 UTC

Perhaps partitioning the 'spider' table would help, so your concurrent rule-fired inserts are acting on multiple physical tables rather than just one.
(It's a less effective approach if spider has secondary indexes though, those can't be partitioned so a single index spans all partitions of the base table).

Re: Triggers and locks

<442e0ed1-b216-4d64-b400-3e0b707fc22en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=289&group=comp.databases.ingres#289

  copy link   Newsgroups: comp.databases.ingres
X-Received: by 2002:a05:622a:19a5:b0:410:6ea4:9662 with SMTP id u37-20020a05622a19a500b004106ea49662mr25071qtc.2.1694588016671;
Tue, 12 Sep 2023 23:53:36 -0700 (PDT)
X-Received: by 2002:a05:6870:c7a8:b0:1d5:8fa2:e777 with SMTP id
dy40-20020a056870c7a800b001d58fa2e777mr639679oab.5.1694588016457; Tue, 12 Sep
2023 23:53:36 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.databases.ingres
Date: Tue, 12 Sep 2023 23:53:35 -0700 (PDT)
In-Reply-To: <80ea7a3c-5dab-48ed-bc0d-cd39836ef4ecn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=93.63.171.9; posting-account=o45aTQoAAAC0zpFKFFtE1KNZ5g5HYdBB
NNTP-Posting-Host: 93.63.171.9
References: <757cd439-a568-4385-ad7e-b1bb6bf12a97n@googlegroups.com> <80ea7a3c-5dab-48ed-bc0d-cd39836ef4ecn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <442e0ed1-b216-4d64-b400-3e0b707fc22en@googlegroups.com>
Subject: Re: Triggers and locks
From: fabrizio...@bucap.it (Fabrizio Di Renzo)
Injection-Date: Wed, 13 Sep 2023 06:53:36 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1461
 by: Fabrizio Di Renzo - Wed, 13 Sep 2023 06:53 UTC

Thank you all,
we will try to use dbevent, I think this is a good idea.
We never used it, but it seem the better solution.

> ps. your AFTER INSERT rule looks like it needs to refer to the new record rather than the old record?

We need to refer to old record

Fabrizio

Re: Triggers and locks

<udrtc5$228kp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=290&group=comp.databases.ingres#290

  copy link   Newsgroups: comp.databases.ingres
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: specia...@processed.almost.meat (Roy Hann)
Newsgroups: comp.databases.ingres
Subject: Re: Triggers and locks
Date: Wed, 13 Sep 2023 08:54:29 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <udrtc5$228kp$1@dont-email.me>
References: <757cd439-a568-4385-ad7e-b1bb6bf12a97n@googlegroups.com> <80ea7a3c-5dab-48ed-bc0d-cd39836ef4ecn@googlegroups.com> <442e0ed1-b216-4d64-b400-3e0b707fc22en@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 13 Sep 2023 08:54:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8c1fd399d9719ea821a73a8090000519";
logging-data="2171545"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CfCmRJz7NxOoplRPhzFKRb07UlQ1kAd0="
User-Agent: XPN/1.2.6 (Street Spirit ; Windows)
Cancel-Lock: sha1:M8T8g/lMEQB0YEatrP8lTRhGbN0=
 by: Roy Hann - Wed, 13 Sep 2023 08:54 UTC

Fabrizio Di Renzo wrote:

> Thank you all,
> we will try to use dbevent, I think this is a good idea.
> We never used it, but it seem the better solution.

Keep in mind that a raised event won't be "unraised" if there is a
rollback, so there is risk of recording things which--in a sense--didn't
happen.

Geraint's partitioning suggestion might be the quickest, easiest, and
most robust thing to try first. It requires no code and can be
backed out quickly if it doesn't help.

Roy (Kicking himself for forgetting to mention his own favorite solution)

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor