From: Bruce Momjian <bruce@momjian.us>
To: David G Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Re: BUG #10329: Could not read block 0 in file "base/56100265/57047884": read only 0 of 8192 bytes
Date: Sat, 6 Sep 2014 11:07:43 -0400
Message-ID: <20140906150743.GC20146@momjian.us> (raw)
In-Reply-To: <CAKFQuwaQQBG-gOmFB8XEebY1jpadu0Y-m7i9wJQFaQbGpy-+hw@mail.gmail.com>
References: <26235.1400166587@sss.pgh.pa.us>
<4EE3A338-8C14-4E1B-9F2B-479354765138@wingo.ch>
<20140515190235.GH25053@momjian.us>
<31390.1400180834@sss.pgh.pa.us>
<4FB93C6A-2790-4167-931A-E53E6694F73E@wingo.ch>
<31813.1400181933@sss.pgh.pa.us>
<CAM-w4HOAp903Fd_KU9Ur0wmYWncawthGKS4qqHBPmYy5NEJvHA@mail.gmail.com>
<1361.1400247902@sss.pgh.pa.us>
<20140516144825.GL25053@momjian.us>
<CAKFQuwaQQBG-gOmFB8XEebY1jpadu0Y-m7i9wJQFaQbGpy-+hw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On Fri, May 16, 2014 at 08:27:33AM -0700, David G Johnston wrote:
> Well, at this point we are decade into having crash-unsafe hash indexes,
> and rather than getting better, the issue has gotten worse with
> streaming replication. If we can't find the best way to warn people,
> let's find _a_ way, at least.
>
> I feel we are waiting for the calvary to come over the hill (and fix
> hash indexes), except the calvary never arrives. At some point we have
> to take ownership of the situation we are in and actively do something.
>
> If someone today tried to add a crash-unsafe, replication-impotent
> index, it would never be accepted, but because hash indexes came from
> Berkeley, we go with a warning in the CREATE INDEX manual page and do
> nothing more. I can't think of any other foot-gun feature that is
> allowed to remain with so little user warning.
>
> Unless there is a convincing argument to be made why doing it at CREATE INDEX
> is FRIGGIN' EVIL then who really cares if its not perfect.
>
> NOTICE: This index IS NOT WAL LOGGED and cannot be used on SLAVE servers or
> AFTER RECOVERY. See Documentation for Details!
>
> The goal should be to communicate FUD to the uninformed.
>
> I'm all for additional and improved warnings in other places but this one at
> least seems to have the benefit of being relatively simple to implement and
> non-obnoxious since it only is issued once per index creation.
>
> As devil's advocate it isn't like anyone is likely to intentionally use hash
> indexes without reading the documentation first - if only to know they exist,
> how they work, and what syntax to use. If an application is installing such
> indexes for the user then a warning at CREATE INDEX is only a little better
> than a warning in the documentation - though both are likely to never be seen.
>
>
> But that argument doesn't hold any sway for me. If someone knows they are using
> a hash index intentionally then the notice/warning will be understood and
> ignored while if someone is seeing the notice/warning and are not aware of the
> limitations of hash indexes - like the OP - this live/logged notice will
> hopefully cause them to become better informed and able to evaluate their
> specific situation. If the application doesn't point out it is using hash
> indexes then the typical user will not be checking PostgreSQL documentation for
> the same; but just maybe the notice that is raised will end up visible to the
> end-user or cause the application developers to further re-examine their usage
> and/or documentation of hash indexes.
Here is a patch which implements the warning during CREATE INDEX ...
HASH. If WAL-logging of hash indexes is ever implemented, we can remove
this warning.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugsAttachments:hash.diff (text/x-diff, 4.7K) downloaddiff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.cnew file mode 100644index fdfa6ca..4f31678
*** a/src/backend/commands/indexcmds.c
--- b/src/backend/commands/indexcmds.c
*************** DefineIndex(Oid relationId,
*** 489,494 ****
--- 489,498 ----
accessMethodId = HeapTupleGetOid(tuple);
accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
+ if (strcmp(accessMethodName, "hash") == 0)+ ereport(WARNING,+ (errmsg("hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming slaves")));+
if (stmt->unique && !accessMethodForm->amcanunique)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.outnew file mode 100644index f6f5516..7a0185a
*** a/src/test/regress/expected/create_index.out
--- b/src/test/regress/expected/create_index.out
*************** DROP TABLE array_gin_test;
*** 2238,2246 ****
--- 2238,2250 ----
-- HASH
--
CREATE INDEX hash_i4_index ON hash_i4_heap USING hash (random int4_ops);
+ WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming slaves
CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops);
+ WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming slaves
CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
+ WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming slaves
CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
+ WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming slaves
-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops);
--
-- Test functional index
diff --git a/src/test/regress/expected/enum.out b/src/test/regress/expected/enum.outnew file mode 100644index 3682642..774f6fc
*** a/src/test/regress/expected/enum.out
--- b/src/test/regress/expected/enum.out
*************** DROP INDEX enumtest_btree;
*** 383,388 ****
--- 383,389 ----
-- Hash index / opclass with the = operator
--
CREATE INDEX enumtest_hash ON enumtest USING hash (col);
+ WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming slaves
SELECT * FROM enumtest WHERE col = 'orange';
col
--------
diff --git a/src/test/regress/expected/macaddr.out b/src/test/regress/expected/macaddr.outnew file mode 100644index 50d0369..0657df1
*** a/src/test/regress/expected/macaddr.out
--- b/src/test/regress/expected/macaddr.out
*************** SELECT * FROM macaddr_data;
*** 39,44 ****
--- 39,45 ----
CREATE INDEX macaddr_data_btree ON macaddr_data USING btree (b);
CREATE INDEX macaddr_data_hash ON macaddr_data USING hash (b);
+ WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming slaves
SELECT a, b, trunc(b) FROM macaddr_data ORDER BY 2, 1;
a | b | trunc
----+-------------------+-------------------
diff --git a/src/test/regress/expected/replica_identity.out b/src/test/regress/expected/replica_identity.outnew file mode 100644index 96dc98b..62c1f95
*** a/src/test/regress/expected/replica_identity.out
--- b/src/test/regress/expected/replica_identity.out
*************** CREATE INDEX test_replica_identity_keyab
*** 11,16 ****
--- 11,17 ----
CREATE UNIQUE INDEX test_replica_identity_keyab_key ON test_replica_identity (keya, keyb);
CREATE UNIQUE INDEX test_replica_identity_nonkey ON test_replica_identity (keya, nonkey);
CREATE INDEX test_replica_identity_hash ON test_replica_identity USING hash (nonkey);
+ WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming slaves
CREATE UNIQUE INDEX test_replica_identity_expr ON test_replica_identity (keya, keyb, (3));
CREATE UNIQUE INDEX test_replica_identity_partial ON test_replica_identity (keya, keyb) WHERE keyb != '3';
-- default is 'd'/DEFAULT for user created tables
diff --git a/src/test/regress/expected/uuid.out b/src/test/regress/expected/uuid.outnew file mode 100644index d907519..e388ca2
*** a/src/test/regress/expected/uuid.out
--- b/src/test/regress/expected/uuid.out
*************** SELECT COUNT(*) FROM guid1 WHERE guid_fi
*** 114,119 ****
--- 114,120 ----
-- btree and hash index creation test
CREATE INDEX guid1_btree ON guid1 USING BTREE (guid_field);
CREATE INDEX guid1_hash ON guid1 USING HASH (guid_field);
+ WARNING: hash indexes are not WAL-logged so they are not crash-safe and cannot be used on streaming slaves
-- unique index test
CREATE UNIQUE INDEX guid1_unique_BTREE ON guid1 USING BTREE (guid_field);
-- should fail
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-bugs@postgresql.org
Cc: bruce@momjian.us, david.g.johnston@gmail.com
Subject: Re: BUG #10329: Could not read block 0 in file "base/56100265/57047884": read only 0 of 8192 bytes
In-Reply-To: <20140906150743.GC20146@momjian.us>
References: <26235.1400166587@sss.pgh.pa.us> <4EE3A338-8C14-4E1B-9F2B-479354765138@wingo.ch> <20140515190235.GH25053@momjian.us> <31390.1400180834@sss.pgh.pa.us> <4FB93C6A-2790-4167-931A-E53E6694F73E@wingo.ch> <31813.1400181933@sss.pgh.pa.us> <CAM-w4HOAp903Fd_KU9Ur0wmYWncawthGKS4qqHBPmYy5NEJvHA@mail.gmail.com> <1361.1400247902@sss.pgh.pa.us> <20140516144825.GL25053@momjian.us> <CAKFQuwaQQBG-gOmFB8XEebY1jpadu0Y-m7i9wJQFaQbGpy-+hw@mail.gmail.com> <20140906150743.GC20146@momjian.us>
* 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