From: Christophe Pettus <xof@thebuild.com>
To: merryok <merryok@163.com>
Cc: adrian.klaver@aklaver.com
Cc: hjp-pgsql@hjp.at
Cc: pgsql-general@lists.postgresql.org
Subject: Re: equivalent thing of mtr in mysql
Date: Mon, 18 Jul 2022 20:24:00 -0700
Message-ID: <F33AF7D9-AC7E-4E5F-8A68-F5ED95CD52A2@thebuild.com> (raw)
In-Reply-To: <parcghlk5gg05gn2crkioq5m.1658199830937@email.android.com>
References: <52b03573-1e24-9cde-3bcb-41ecb60906ec@aklaver.com>
<parcghlk5gg05gn2crkioq5m.1658199830937@email.android.com>
> On Jul 18, 2022, at 20:03, merryok <merryok@163.com> wrote:
>
> I've read the doc, and it doesn't help too much.
> Finally I've found START_CRIT_SECTION and END_CRIT_SECTION. It's like mtr.start(), mtr.commit() in mysql. May I ask why many places are wrapped into START_CRIT_SECTION/END_CRIT_SECTION during a single dml operation ?
A PostgreSQL critical section is not the equivalent of MySQL InnoDB mini-transaction.
A critical section in PostgreSQL is a section of code that needs to run without interruption to avoid corruption of internal in-memory data structures.
PostgreSQL doesn't have a direct equivalent of a MySQL mini-transaction. When WAL information is created by a statement, it's stored in the WAL buffers, and then flushed to disk by the WAL writer (to a first approximation). There's no special operation that groups pages together for atomic writes; that's done by the underlying file system flush operation.
> And if Assert(CritSectionCount > 0) isn't satisfied (CritSectionCount need't be protected ?), PG server will panic and exit ? If so, what's the probability of that ?
If it occurs, it indicates a bug in PostgreSQL. It is *extremely* infrequent (as in, you can go years without seeing one; I can't remember the last time I did).
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: xof@thebuild.com, merryok@163.com, adrian.klaver@aklaver.com, hjp-pgsql@hjp.at
Subject: Re: equivalent thing of mtr in mysql
In-Reply-To: <F33AF7D9-AC7E-4E5F-8A68-F5ED95CD52A2@thebuild.com>
References: <52b03573-1e24-9cde-3bcb-41ecb60906ec@aklaver.com> <parcghlk5gg05gn2crkioq5m.1658199830937@email.android.com> <F33AF7D9-AC7E-4E5F-8A68-F5ED95CD52A2@thebuild.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox