Lists: | pgsql-hackers |
---|
From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Teodor Sigaev <teodor(at)sigaev(dot)ru>, Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com> |
Subject: | Few comments on commit 857f9c36 (skip full index scans ) |
Date: | 2018-05-28 08:52:48 |
Message-ID: | CAA4eK1JdS2AZbcYtcR8rFzRZe3ONozyEN-Y79Toqj39s3B9Tjg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
Review comments on commit 857f9c36:
1.
@@ -2049,6 +2055,10 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
metapg = BufferGetPage(metabuf);
metad = BTPageGetMeta(metapg);
+ /* upgrade metapage if needed */
+ if (metad->btm_version < BTREE_VERSION)
+ _bt_upgrademetapage(metapg);
+
The metapage upgrade should be performed under critical section.
2.
@@ -191,6 +304,10 @@ _bt_getroot(Relation rel, int access)
LockBuffer(metabuf, BUFFER_LOCK_UNLOCK);
LockBuffer(metabuf, BT_WRITE);
+ /* upgrade metapage if needed */
+ if (metad->btm_version < BTREE_VERSION)
+ _bt_upgrademetapage(metapg);
+
Same as above.
In other cases like _bt_insertonpg, the upgrade is done inside the
critical section. It seems the above cases are missed.
3.
+ TransactionId btm_oldest_btpo_xact; /* oldest btpo_xact among of
+ * deleted pages */
/among of/among all
Attached patch to fix the above comments.
--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
Attachment | Content-Type | Size |
---|---|---|
fix_review_skip_full_index_scan_v1.patch | application/octet-stream | 2.6 KB |
From: | Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Teodor Sigaev <teodor(at)sigaev(dot)ru>, Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com> |
Subject: | Re: Few comments on commit 857f9c36 (skip full index scans ) |
Date: | 2018-05-29 13:36:56 |
Message-ID: | CAPpHfdsOhLyRaLQWenf=P8adbnwMet-BTWsvM8PVG_dX2ekkzQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg토토 커뮤니티SQL |
Hi!
On Mon, May 28, 2018 at 11:52 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
wrote:
> Review comments on commit 857f9c36:
> 1.
> @@ -2049,6 +2055,10 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
> metapg = BufferGetPage(metabuf);
> metad = BTPageGetMeta(metapg);
>
> + /* upgrade metapage if needed */
> + if (metad->btm_version < BTREE_VERSION)
> + _bt_upgrademetapage(metapg);
> +
>
> The metapage upgrade should be performed under critical section.
>
> 2.
> @@ -191,6 +304,10 @@ _bt_getroot(Relation rel, int access)
> LockBuffer(metabuf, BUFFER_LOCK_UNLOCK);
> LockBuffer(metabuf, BT_WRITE);
>
> + /* upgrade metapage if needed */
> + if (metad->btm_version < BTREE_VERSION)
> + _bt_upgrademetapage(metapg);
> +
>
> Same as above.
>
> In other cases like _bt_insertonpg, the upgrade is done inside the
> critical section. It seems the above cases are missed.
>
> 3.
> + TransactionId btm_oldest_btpo_xact; /* oldest btpo_xact among of
> + * deleted pages */
>
> /among of/among all
>
> Attached patch to fix the above comments.
>
Thank you for catching this!
Your patch looks good for me.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Teodor Sigaev <teodor(at)sigaev(dot)ru> |
Subject: | Re: Few comments on commit 857f9c36 (skip full index scans ) |
Date: | 2018-05-29 20:05:51 |
Message-ID: | CAD21AoDCQhFHOYabQtTePZgef0GXbEuPFu+DrWdJJZt9UyR1wg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg와이즈 토토SQL |
On Mon, May 28, 2018 at 4:52 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> Hi,
>
> Review comments on commit 857f9c36:
> 1.
> @@ -2049,6 +2055,10 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
> metapg = BufferGetPage(metabuf);
> metad = BTPageGetMeta(metapg);
>
> + /* upgrade metapage if needed */
> + if (metad->btm_version < BTREE_VERSION)
> + _bt_upgrademetapage(metapg);
> +
>
> The metapage upgrade should be performed under critical section.
>
> 2.
> @@ -191,6 +304,10 @@ _bt_getroot(Relation rel, int access)
> LockBuffer(metabuf, BUFFER_LOCK_UNLOCK);
> LockBuffer(metabuf, BT_WRITE);
>
> + /* upgrade metapage if needed */
> + if (metad->btm_version < BTREE_VERSION)
> + _bt_upgrademetapage(metapg);
> +
>
> Same as above.
>
> In other cases like _bt_insertonpg, the upgrade is done inside the
> critical section. It seems the above cases are missed.
>
> 3.
> + TransactionId btm_oldest_btpo_xact; /* oldest btpo_xact among of
> + * deleted pages */
>
> /among of/among all
>
> Attached patch to fix the above comments.
>
Thank you for reviewing and the patch. All changes looks good to me.
Regards,
--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
From: | Teodor Sigaev <teodor(at)sigaev(dot)ru> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com> |
Subject: | Re: Few comments on commit 857f9c36 (skip full index scans ) |
Date: | 2018-05-30 15:39:29 |
Message-ID: | 2673add3-a9c4-2c89-8575-7a59ebf92590@sigaev.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
> The metapage upgrade should be performed under critical section.
Agree. But after close look I found that btm_version change isn't wal-logged
(near line 2251 in _bt_newroot). So btm_version is not propagated to
replica/backup/etc.
I believe it should be fixed.
--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/
From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
---|---|
To: | Teodor Sigaev <teodor(at)sigaev(dot)ru> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com> |
Subject: | Re: Few comments on commit 857f9c36 (skip full index scans ) |
Date: | 2018-05-30 16:12:22 |
Message-ID: | CAA4eK1+hU6u2PQz_vTyDq9iuaQvG1hoq6VYR71PG_KZ7PeEWMQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Wed, May 30, 2018 at 9:09 PM, Teodor Sigaev <teodor(at)sigaev(dot)ru> wrote:
>> The metapage upgrade should be performed under critical section.
>
>
> Agree. But after close look I found that btm_version change isn't wal-logged
> (near line 2251 in _bt_newroot). So btm_version is not propagated to
> replica/backup/etc.
>
I think it will always be set to BTREE_VERSION (See _bt_restore_meta).
I see that other places like _bt_insertonpg,
_bt_update_meta_cleanup_info, etc. that log meta page contents don't
log version number, so if we want to log it, all such places also need
to be modified, but I don't see the need for same.
--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
From: | Teodor Sigaev <teodor(at)sigaev(dot)ru> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com> |
Subject: | Re: Few comments on commit 857f9c36 (skip full index scans ) |
Date: | 2018-05-30 16:46:58 |
Message-ID: | b1fdc3bd-6028-dd03-dc16-ee2fc25a48ab@sigaev.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
> I think it will always be set to BTREE_VERSION (See _bt_restore_meta).
You are right, pushed. Thank you!
--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/