-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamcheck.html
More file actions
269 lines (269 loc) · 27 KB
/
amcheck.html
File metadata and controls
269 lines (269 loc) · 27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>F.2. amcheck</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="adminpack.html" title="F.1. adminpack" /><link rel="next" href="auth-delay.html" title="F.3. auth_delay" /><meta name="viewport" content="width=device-width,initial-scale=1.0" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="4" align="center"><a accesskey="h" href="index.html">PostgreSQL 10.5文書</a></th></tr><tr><td width="10%" align="left"></td><td width="10%" align="left"></td><td width="60%" align="center"><a href="contrib.html" title="付録F 追加で提供されるモジュール">付録F 追加で提供されるモジュール</a></td><td width="20%" align="right"><div class="actions"><a class="issue" title="github" href="https://github.com/pgsql-jp/jpug-doc/issues/new?title=version 10.5 amcheck.html">誤訳等の報告
</a></div></td></tr><tr><td width="10%" align="left"><a accesskey="p" href="adminpack.html" title="F.1. adminpack">前へ</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="付録F 追加で提供されるモジュール">上へ</a></td><td width="60%" align="center">F.2. amcheck</td><td width="20%" align="right"> <a accesskey="n" href="auth-delay.html" title="F.3. auth_delay">次へ</a></td></tr></table><hr /></div><div class="sect1" id="AMCHECK"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.2. amcheck</h2></div></div></div><a id="id-1.11.7.11.2" class="indexterm"></a><p><span class="original">
The <filename>amcheck</> module provides functions that allow you to
verify the logical consistency of the structure of indexes. If the
structure appears to be valid, no error is raised.
</span><code class="filename">amcheck</code>モジュールは、インデックスの構造の論理的な一貫性を検査する機能を提供します。
構造が適正であると見なされれば、エラーは報告されません。
</p><p><span class="original">
The functions verify various <emphasis>invariants</> in the
structure of the representation of particular indexes. The
correctness of the access method functions behind index scans and
other important operations relies on these invariants always
holding. For example, certain functions verify, among other things,
that all B-Tree pages have items in <quote>logical</> order (e.g.,
for B-Tree indexes on <type>text</>, index tuples should be in
collated lexical order). If that particular invariant somehow fails
to hold, we can expect binary searches on the affected page to
incorrectly guide index scans, resulting in wrong answers to SQL
queries.
</span>この関数は、特定のインデックスの構造表現における様々な<span class="emphasis"><em>不変量</em></span>を検査します。
インデックスの走査や、その他の重要な操作を担うアクセスメソッド関数の正しさは、これらの不変量を常に保つことに依存しています。
たとえば、ある関数は、とりわけすべてのB-Treeページの中の項目が<span class="quote">「<span class="quote">論理的な</span>」</span>順序になっていることを検査します。(たとえば<code class="type">text</code>のB-Treeインデックスでは、インデックスタプルは語句の照合順になっていなければなりません。)
その特定の不変量が何らかの理由で保たれなければ、該当するページで二分探索が不正なインデックス走査をもたらし、SQL問い合わせに誤った答えを返すことになるでしょう。
</p><p><span class="original">
Verification is performed using the same procedures as those used by
index scans themselves, which may be user-defined operator class
code. For example, B-Tree index verification relies on comparisons
made with one or more B-Tree support function 1 routines. See <xref
linkend="xindex-support"> for details of operator class support
functions.
</span>検証は、インデックス走査自身で使われるのと同じ手続きを用いて行われます。
その手続きは、ユーザ定義演算子クラスのコードかもしれません。
たとえば、B-Treeインデックスの検査は、一つ以上のB-Treeサポート関数1ルーチンを用いる比較に依存しています。
演算子クラスサポート関数の詳細については<a class="xref" href="xindex.html#XINDEX-SUPPORT" title="37.14.3. インデックスメソッドのサポートルーチン">37.14.3</a>をご覧ください。
</p><p><span class="original">
<filename>amcheck</> functions may be used only by superusers.
</span> <code class="filename">amcheck</code>関数はスーパーユーザだけが使用できます。
</p><div class="sect2" id="id-1.11.7.11.7"><div class="titlepage"><div><div><h3 class="title">F.2.1. 関数</h3></div></div></div><span class="original">
<title>Functions</title>
</span><div class="variablelist"><dl class="variablelist"><dt><span class="term"> <code class="function">bt_index_check(index regclass) returns void</code>
<a id="id-1.11.7.11.7.2.1.1.2" class="indexterm"></a>
</span></dt><dd><p><span class="original">
<function>bt_index_check</function> tests that its target, a
B-Tree index, respects a variety of invariants. Example usage:
</span><code class="function">bt_index_check</code>は対象となるB-Treeインデックスが、様々な不変量を維持していることをテストします。
例を示します。
</p><pre class="screen">test=# SELECT bt_index_check(c.oid), c.relname, c.relpages
FROM pg_index i
JOIN pg_opclass op ON i.indclass[0] = op.oid
JOIN pg_am am ON op.opcmethod = am.oid
JOIN pg_class c ON i.indexrelid = c.oid
JOIN pg_namespace n ON c.relnamespace = n.oid
WHERE am.amname = 'btree' AND n.nspname = 'pg_catalog'
-- Don't check temp tables, which may be from another session:
AND c.relpersistence != 't'
-- Function may throw an error when this is omitted:
AND i.indisready AND i.indisvalid
ORDER BY c.relpages DESC LIMIT 10;
bt_index_check | relname | relpages
----------------+---------------------------------+----------
| pg_depend_reference_index | 43
| pg_depend_depender_index | 40
| pg_proc_proname_args_nsp_index | 31
| pg_description_o_c_o_index | 21
| pg_attribute_relid_attnam_index | 14
| pg_proc_oid_index | 10
| pg_attribute_relid_attnum_index | 9
| pg_amproc_fam_proc_index | 5
| pg_amop_opr_fam_index | 5
| pg_amop_fam_strat_index | 5
(10 rows)</pre><p><span class="original">
This example shows a session that performs verification of every
catalog index in the database <quote>test</>. Details of just
the 10 largest indexes verified are displayed. Since no error
is raised, all indexes tested appear to be logically consistent.
Naturally, this query could easily be changed to call
<function>bt_index_check</function> for every index in the
database where verification is supported.
</span>
この例では、データベース<span class="quote">「<span class="quote">test</span>」</span>中のすべてのカタログインデックスの検証を行うセッションを示しています。
検証したもっとも大きな10個のインデックスの詳細だけが表示されています。
エラーは出ていないので、テストしたすべてのインデックスは論理的に一貫していることがわかります。
当然のことながら、この問い合わせは、検証可能なデータベース中のすべてのインデックスに対して<code class="function">bt_index_check</code>を呼び出すように変更できます。
</p><p><span class="original">
<function>bt_index_check</function> acquires an <literal>AccessShareLock</>
on the target index and the heap relation it belongs to. This lock mode
is the same lock mode acquired on relations by simple
<literal>SELECT</> statements.
<function>bt_index_check</function> does not verify invariants
that span child/parent relationships, nor does it verify that
the target index is consistent with its heap relation. When a
routine, lightweight test for corruption is required in a live
production environment, using
<function>bt_index_check</function> often provides the best
trade-off between thoroughness of verification and limiting the
impact on application performance and availability.
</span><code class="function">bt_index_check</code>は、ターゲットとなるインデックスと、それが所属するヒープリレーションに対して<code class="literal">AccessShareLock</code>を獲得します。
このロックモードは、単純な<code class="literal">SELECT</code>文がリレーションに対して獲得するのと同じものです。
<code class="function">bt_index_check</code>は、子/親関係に渡る不変量も、ターゲットのインデックスがヒープリレーションと一貫性があることも検査しません。
実行中のプロダクション環境で定期的、軽量なデータ破損検査が必要な場合、<code class="function">bt_index_check</code>を使うのが、検査の完全性と、アプリケーションの性能と稼働への影響を限定することとの間の最良のトレードオフになることがしばしばあります。
</p></dd><dt><span class="term"> <code class="function">bt_index_parent_check(index regclass) returns void</code>
<a id="id-1.11.7.11.7.2.2.1.2" class="indexterm"></a>
</span></dt><dd><p><span class="original">
<function>bt_index_parent_check</function> tests that its
target, a B-Tree index, respects a variety of invariants. The
checks performed by <function>bt_index_parent_check</function>
are a superset of the checks performed by
<function>bt_index_check</function>.
<function>bt_index_parent_check</function> can be thought of as
a more thorough variant of <function>bt_index_check</function>:
unlike <function>bt_index_check</function>,
<function>bt_index_parent_check</function> also checks
invariants that span parent/child relationships. However, it
does not verify that the target index is consistent with its
heap relation. <function>bt_index_parent_check</function>
follows the general convention of raising an error if it finds a
logical inconsistency or other problem.
</span><code class="function">bt_index_parent_check</code>は、ターゲットとなるB-Treeインデックスが様々な不変量を保っていることを検査します。
<code class="function">bt_index_parent_check</code>により実施される検査は、<code class="function">bt_index_check</code>により実施される検査のスーパーセットになっています。
<code class="function">bt_index_parent_check</code>は、<code class="function">bt_index_check</code>の更なる完璧版であると考えることができます。
つまり、<code class="function">bt_index_check</code>と違って<code class="function">bt_index_parent_check</code>は、子/親関係に渡る不変量も検査します。
しかし、ターゲットのインデックスがヒープリレーションと一貫性があることは検査しません。
<code class="function">bt_index_parent_check</code>は、論理的な非一貫性やその他の問題を発見した場合、一般的な習慣に従ってエラーを報告します。
</p><p><span class="original">
A <literal>ShareLock</> is required on the target index by
<function>bt_index_parent_check</function> (a
<literal>ShareLock</> is also acquired on the heap relation).
These locks prevent concurrent data modification from
<command>INSERT</>, <command>UPDATE</>, and <command>DELETE</>
commands. The locks also prevent the underlying relation from
being concurrently processed by <command>VACUUM</>, as well as
all other utility commands. Note that the function holds locks
only while running, not for the entire transaction.
</span><code class="function">bt_index_parent_check</code>は、ターゲットインデックスに<code class="literal">ShareLock</code>を獲得することを必要とします。
(<code class="literal">ShareLock</code>はヒープリレーションにも獲得されます。)
このロックは、<code class="command">INSERT</code>、<code class="command">UPDATE</code>、<code class="command">DELETE</code>が並行してデータ更新することを防ぎます。
また、このロックは<code class="command">VACUUM</code>その他のユーティリティコマンドによって、背後にあるリレーションが同時に処理されることを防ぎます。
この関数は実行中のみロックを保持し、トランザクション全体に保持するのではないことに注意してください。
</p><p><span class="original">
<function>bt_index_parent_check</function>'s additional
verification is more likely to detect various pathological
cases. These cases may involve an incorrectly implemented
B-Tree operator class used by the index that is checked, or,
hypothetically, undiscovered bugs in the underlying B-Tree index
access method code. Note that
<function>bt_index_parent_check</function> cannot be used when
Hot Standby mode is enabled (i.e., on read-only physical
replicas), unlike <function>bt_index_check</function>.
</span><code class="function">bt_index_parent_check</code>による追加の検査では、様々な病的な事象を検出する可能性があります。
これらの現象は、チェック対象のインデックスが使用している間違った実装がされたB-Tree演算子クラスによるものや、もしかしたら関連するB-Treeインデックスアクセスメソッドのコード中のまだ見つかっていないバグによるものなのかもしれません。
<code class="function">bt_index_check</code>と違って、<code class="function">bt_index_parent_check</code>は、ホットスタンバイモードが有効な場合(すなわち、読み出し専用物理レプリカ)では使用できません。
</p></dd></dl></div></div><div class="sect2" id="id-1.11.7.11.8"><div class="titlepage"><div><div><h3 class="title">F.2.2. <code class="filename">amcheck</code>を効果的に使う</h3></div></div></div><span class="original">
<title>Using <filename>amcheck</> effectively</title>
</span><p><span class="original">
<filename>amcheck</> can be effective at detecting various types of
failure modes that <link
linkend="app-initdb-data-checksums"><application>data page
checksums</></link> will always fail to catch. These include:
</span><code class="filename">amcheck</code>は、<a class="link" href="app-initdb.html#APP-INITDB-DATA-CHECKSUMS"><span class="application">データページチェックサム</span></a>が検知できないような、様々なタイプの障害モードを効果的に検知できます。
以下のようなものがあります。
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="original">
Structural inconsistencies caused by incorrect operator class
implementations.
</span>演算子クラスの正しくない実装によって引き起こされる構造の非一貫性。
</p><p><span class="original">
This includes issues caused by the comparison rules of operating
system collations changing. Comparisons of datums of a collatable
type like <type>text</> must be immutable (just as all
comparisons used for B-Tree index scans must be immutable), which
implies that operating system collation rules must never change.
Though rare, updates to operating system collation rules can
cause these issues. More commonly, an inconsistency in the
collation order between a master server and a standby server is
implicated, possibly because the <emphasis>major</> operating
system version in use is inconsistent. Such inconsistencies will
generally only arise on standby servers, and so can generally
only be detected on standby servers.
</span>オペレーティングシステムの照合順の比較ルールの変更による問題も含まれます。
<code class="type">text</code>のような照合可能な型のデータの比較は、不変でなけれならず(B-Treeインデックスの走査のための、すべての比較が不変でなければならないのと同じことです)、それはオペレーティングシステムの照合順が決して変化してはいけないことを意味します。
まれであるとは言え、オペレーティングシステムの照合順ルールの更新は、これらの問題を引き起こします。
もっと普通に起こることとしては、マスターサーバとスタンバイサーバの照合順の違いが関与することです。
これは、使用されているオペレーティングシステムの<span class="emphasis"><em>メジャー</em></span>バージョンに一貫性がないことによります。
そうした一貫性の欠如は一般的にスタンバイサーバでのみ起こるので、通常スタンバイサーバでのみ検出されます。
</p><p><span class="original">
If a problem like this arises, it may not affect each individual
index that is ordered using an affected collation, simply because
<emphasis>indexed</> values might happen to have the same
absolute ordering regardless of the behavioral inconsistency. See
<xref linkend="locale"> and <xref linkend="collation"> for
further details about how <productname>PostgreSQL</> uses
operating system locales and collations.
</span>そうした問題が起きても、影響を受けた照合順を使って順序付けられた個々のインデックスには影響ないかもしれません。
これは単純に、振る舞いにおける一貫性のなさにかかわらず<span class="emphasis"><em>インデックスされた</em></span>値は同じ絶対的な順になるからです。
<span class="productname">PostgreSQL</span>がオペレーティングシステムのロケールと照合順をどう使用するかについての更なる詳細については、<a class="xref" href="locale.html" title="23.1. ロケールのサポート">23.1</a>と<a class="xref" href="collation.html" title="23.2. 照合順序サポート">23.2</a>をご覧ください。
</p></li><li class="listitem"><p><span class="original">
Corruption caused by hypothetical undiscovered bugs in the
underlying <productname>PostgreSQL</> access method code or sort
code.
</span>依拠する<span class="productname">PostgreSQL</span>のアクセスメソッド、あるいはソートコードにおける、潜在的なまだ見つかっていないバグによる破損。
</p><p><span class="original">
Automatic verification of the structural integrity of indexes
plays a role in the general testing of new or proposed
<productname>PostgreSQL</> features that could plausibly allow a
logical inconsistency to be introduced. One obvious testing
strategy is to call <filename>amcheck</> functions continuously
when running the standard regression tests. See <xref
linkend="regress-run"> for details on running the tests.
</span>新規、あるいは提案中の <span class="productname">PostgreSQL</span>の機能が、論理的な非一貫性をもたらしかねないかどうか全般的にテストする際に、インデックスの構造的な一貫性の自動検証が役立ちます。
わかりやすいテスト戦略の一つは、関数標準の回帰テストを実行中に、<code class="filename">amcheck</code>を継続的に呼び出すことです。
テストの実行に関する詳細は、<a class="xref" href="regress-run.html" title="32.1. テストの実行">32.1</a>をご覧ください。
</p></li><li class="listitem"><p><span class="original">
File system or storage subsystem faults where checksums happen to
simply not be enabled.
</span>単にチェックサムが有効になっていないファイルシステムあるいはストレージサブシステムの障害。
</p><p><span class="original">
Note that <filename>amcheck</> examines a page as represented in some
shared memory buffer at the time of verification if there is only a
shared buffer hit when accessing the block. Consequently,
<filename>amcheck</> does not necessarily examine data read from the
file system at the time of verification. Note that when checksums are
enabled, <filename>amcheck</> may raise an error due to a checksum
failure when a corrupt block is read into a buffer.
</span><code class="filename">amcheck</code>は、ブロックをアクセスする際に共有バッファがヒットした場合、検査時に共有メモリバッファ上に表現されたページを調査します。
結果として、<code class="filename">amcheck</code>は、検査時にファイルシステムから読み込んだデータを調査するとは限りません。
チェックサムが有効な場合、<code class="filename">amcheck</code>は壊れたブロックをバッファに読み込んだ際にチェックサム障害によるエラーを報告するかもしれません。
</p></li><li class="listitem"><p><span class="original">
Corruption caused by faulty RAM, and the broader memory subsystem
and operating system.
</span>RAMおよび、広範囲に渡るメモリサブシステムとオペレーティングシステムの障害による破損。
</p><p><span class="original">
<productname>PostgreSQL</> does not protect against correctable
memory errors and it is assumed you will operate using RAM that
uses industry standard Error Correcting Codes (ECC) or better
protection. However, ECC memory is typically only immune to
single-bit errors, and should not be assumed to provide
<emphasis>absolute</emphasis> protection against failures that
result in memory corruption.
</span><span class="productname">PostgreSQL</span>は、訂正可能なメモリーエラーからは身を守らないので、業界標準のエラー訂正コード(ECC)、あるいはもっと優れた保護機構を使ったRAMを使って運用する前提となっています。
しかし、ECCメモリは典型的には単一ビットエラーに対してのみ耐性があり、メモリ破損に起因する障害に対して<span class="emphasis"><em>完全な</em></span>保護を提供すると考えるべきではありません。
</p></li></ul></div><p><span class="original">
In general, <filename>amcheck</> can only prove the presence of
corruption; it cannot prove its absence.
</span>
一般的に、<code class="filename">amcheck</code>は破損の存在を証明することはできますが、破損がないことを証明することはできません。
</p></div><div class="sect2" id="id-1.11.7.11.9"><div class="titlepage"><div><div><h3 class="title">F.2.3. 破損の修復</h3></div></div></div><span class="original">
<title>Repairing corruption</title>
</span><p><span class="original">
No error concerning corruption raised by <filename>amcheck</> should
ever be a false positive. In practice, <filename>amcheck</> is more
likely to find software bugs than problems with hardware.
<filename>amcheck</> raises errors in the event of conditions that,
by definition, should never happen, and so careful analysis of
<filename>amcheck</> errors is often required.
</span><code class="filename">amcheck</code>が報告するエラーが関与する破損で、擬陽性のものはありません。
実用的には、<code class="filename">amcheck</code>はハードウェアの問題よりも、ソフトウェアバグを発見する可能性が高いです。
<code class="filename">amcheck</code>は、定義により発生してはならないはずの条件下で発生したエラーを報告するので、<code class="filename">amcheck</code>の報告するエラーを注意深く解析することがしばしば求められます。
</p><p><span class="original">
There is no general method of repairing problems that
<filename>amcheck</> detects. An explanation for the root cause of
an invariant violation should be sought. <xref
linkend="pageinspect"> may play a useful role in diagnosing
corruption that <filename>amcheck</> detects. A <command>REINDEX</>
may not be effective in repairing corruption.
</span><code class="filename">amcheck</code>が検出した問題を修復する一般的な方法はありません。
不変条件違反の根本的な原因の説明が求められます。
<code class="filename">amcheck</code>が検出した破損の診断には、<a class="xref" href="pageinspect.html" title="F.23. pageinspect">pageinspect</a>が有用な役割を担うかもしれません。
<code class="command">REINDEX</code>は破損の修復には効果的ではないかもしれません。
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="adminpack.html">前へ</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html">上へ</a></td><td width="40%" align="right"> <a accesskey="n" href="auth-delay.html">次へ</a></td></tr><tr><td width="40%" align="left" valign="top">F.1. adminpack </td><td width="20%" align="center"><a accesskey="h" href="index.html">ホーム</a></td><td width="40%" align="right" valign="top"> F.3. auth_delay</td></tr></table></div></body></html>