1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-08 06:02:22 +03:00

hash: Add write-ahead logging support.

The warning about hash indexes not being write-ahead logged and their
use being discouraged has been removed.  "snapshot too old" is now
supported for tables with hash indexes.  Most importantly, barring
bugs, hash indexes will now be crash-safe and usable on standbys.

This commit doesn't yet add WAL consistency checking for hash
indexes, as we now have for other index types; a separate patch has
been submitted to cure that lack.

Amit Kapila, reviewed and slightly modified by me.  The larger patch
series of which this is a part has been reviewed and tested by Álvaro
Herrera, Ashutosh Sharma, Mark Kirkwood, Jeff Janes, and Jesper
Pedersen.

Discussion: http://postgr.es/m/CAA4eK1JOBX=YU33631Qh-XivYXtPSALh514+jR8XeD7v+K3r_Q@mail.gmail.com
This commit is contained in:
Robert Haas
2017-03-14 13:27:02 -04:00
parent 2b32ac2a59
commit c11453ce0a
25 changed files with 2001 additions and 140 deletions

View File

@@ -1536,19 +1536,6 @@ archive_command = 'local_backup_script.sh "%p" "%f"'
technique. These will probably be fixed in future releases:
<itemizedlist>
<listitem>
<para>
Operations on hash indexes are not presently WAL-logged, so
replay will not update these indexes. This will mean that any new inserts
will be ignored by the index, updated rows will apparently disappear and
deleted rows will still retain pointers. In other words, if you modify a
table with a hash index on it then you will get incorrect query results
on a standby server. When recovery completes it is recommended that you
manually <xref linkend="sql-reindex">
each such index after completing a recovery operation.
</para>
</listitem>
<listitem>
<para>
If a <xref linkend="sql-createdatabase">

View File

@@ -2153,10 +2153,9 @@ include_dir 'conf.d'
has materialized a result set, no error will be generated even if the
underlying rows in the referenced table have been vacuumed away.
Some tables cannot safely be vacuumed early, and so will not be
affected by this setting. Examples include system catalogs and any
table which has a hash index. For such tables this setting will
neither reduce bloat nor create a possibility of a <literal>snapshot
too old</> error on scanning.
affected by this setting, such as system catalogs. For such tables
this setting will neither reduce bloat nor create a possibility
of a <literal>snapshot too old</> error on scanning.
</para>
</listitem>
</varlistentry>

View File

@@ -2351,12 +2351,6 @@ LOG: database system is ready to accept read only connections
These can and probably will be fixed in future releases:
<itemizedlist>
<listitem>
<para>
Operations on hash indexes are not presently WAL-logged, so
replay will not update these indexes.
</para>
</listitem>
<listitem>
<para>
Full knowledge of running transactions is required before snapshots

View File

@@ -193,18 +193,6 @@ CREATE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable>
</synopsis>
</para>
<caution>
<para>
Hash index operations are not presently WAL-logged,
so hash indexes might need to be rebuilt with <command>REINDEX</>
after a database crash if there were unwritten changes.
Also, changes to hash indexes are not replicated over streaming or
file-based replication after the initial base backup, so they
give wrong answers to queries that subsequently use them.
For these reasons, hash index use is presently discouraged.
</para>
</caution>
<para>
<indexterm>
<primary>index</primary>

View File

@@ -510,19 +510,6 @@ Indexes:
they can be useful.
</para>
<caution>
<para>
Hash index operations are not presently WAL-logged,
so hash indexes might need to be rebuilt with <command>REINDEX</>
after a database crash if there were unwritten changes.
Also, changes to hash indexes are not replicated over streaming or
file-based replication after the initial base backup, so they
give wrong answers to queries that subsequently use them.
Hash indexes are also not properly restored during point-in-time
recovery. For these reasons, hash index use is presently discouraged.
</para>
</caution>
<para>
Currently, only the B-tree, GiST, GIN, and BRIN index methods support
multicolumn indexes. Up to 32 fields can be specified by default.