バージョンごとのドキュメント一覧

28.1. 標準的なUnixツール #

<title>Standard Unix Tools</title>

On most Unix platforms, <productname>PostgreSQL</productname> modifies its command title as reported by <command>ps</command>, so that individual server processes can readily be identified. A sample display is ほとんどのUNIXプラットフォームでは、PostgreSQLは、個々のサーバプロセスが容易に識別できるように、psによって報告されるコマンドタイトル部分を変更します。 以下に表示例を示します。

$ ps auxww | grep ^postgres
postgres  15551  0.0  0.1  57536  7132 pts/0    S    18:02   0:00 postgres -i
postgres  15554  0.0  0.0  57536  1184 ?        Ss   18:02   0:00 postgres: background writer
postgres  15555  0.0  0.0  57536   916 ?        Ss   18:02   0:00 postgres: checkpointer
postgres  15556  0.0  0.0  57536   916 ?        Ss   18:02   0:00 postgres: walwriter
postgres  15557  0.0  0.0  58504  2244 ?        Ss   18:02   0:00 postgres: autovacuum launcher
postgres  15582  0.0  0.0  58772  3080 ?        Ss   18:04   0:00 postgres: joe runbug 127.0.0.1 idle
postgres  15606  0.0  0.0  58772  3052 ?        Ss   18:07   0:00 postgres: tgl regression [local] SELECT waiting
postgres  15610  0.0  0.0  58772  3056 ?        Ss   18:07   0:00 postgres: tgl regression [local] idle in transaction

(The appropriate invocation of <command>ps</command> varies across different platforms, as do the details of what is shown. This example is from a recent Linux system.) The first process listed here is the primary server process. The command arguments shown for it are the same ones used when it was launched. The next four processes are background worker processes automatically launched by the primary process. (The <quote>autovacuum launcher</quote> process will not be present if you have set the system not to run autovacuum.) Each of the remaining processes is a server process handling one client connection. Each such process sets its command line display in the form psの適切な呼び出し方はプラットフォームによって異なります。 同様に、何が詳細に表示されるのかも異なります。 この例は最近のLinuxシステムのものです。) この一覧の最初のプロセスはプライマリサーバプロセスです。 表示されているコマンド引数は、起動時に使用されたものと同じものです。 次の4つのプロセスは、プライマリプロセスから自動的に起動されるバックグラウンドワーカープロセスです。 (自動バキュームが起動しないように設定していた場合は自動バキュームランチャプロセスは表示されません。) 残るプロセスはそれぞれ、1つのクライアント接続を取り扱うサーバプロセスです。 それぞれのプロセスは、次の形式のコマンドライン表示を設定します。

postgres: user database host activity

The user, database, and (client) host items remain the same for the life of the client connection, but the activity indicator changes. The activity can be <literal>idle</literal> (i.e., waiting for a client command), <literal>idle in transaction</literal> (waiting for client inside a <command>BEGIN</command> block), or a command type name such as <literal>SELECT</literal>. Also, <literal>waiting</literal> is appended if the server process is presently waiting on a lock held by another session. In the above example we can infer that process 15606 is waiting for process 15610 to complete its transaction and thereby release some lock. (Process 15610 must be the blocker, because there is no other active session. In more complicated cases it would be necessary to look into the <link linkend="view-pg-locks"><structname>pg_locks</structname></link> system view to determine who is blocking whom.) ユーザ、データベース、(クライアント)ホストという項目はクライアント接続の存続期間中変更されることはありませんが、活動状況を示す部分は変わります。 活動状況は、idle(つまり、クライアントからのコマンド待ち状態)、idle in transactionBEGINブロックの内側でのクライアントの待ち状態)、またはSELECTのようなコマンド種類名のいずれかとなります。 また、そのサーバプロセスが他のセッションによって保持されたロックを待っている状態の場合は、waitingが追加されます。 上の例では、プロセス15606はプロセス15610におけるトランザクションの完了とそれに伴うロックの解放を待っていると推測できます。 (他に実行中のセッションがありませんので、プロセス15610がブロックしている側であるはずです。 もっと複雑な場合ではpg_locksシステムビューを検索し、どのプロセスがどのプロセスをブロックしているか決定しなければなりません。)

If <xref linkend="guc-cluster-name"/> has been configured the cluster name will also be shown in <command>ps</command> output: cluster_nameが設定されていれば、psの出力でクラスタ名も表示されます。

$ psql -c 'SHOW cluster_name'
 cluster_name
--------------
 server1
(1 row)

$ ps aux|grep server1
postgres   27093  0.0  0.0  30096  2752 ?        Ss   11:34   0:00 postgres: server1: background writer
...

If you have turned off <xref linkend="guc-update-process-title"/> then the activity indicator is not updated; the process title is set only once when a new process is launched. On some platforms this saves a measurable amount of per-command overhead; on others it's insignificant. update_process_titleを無効にした場合、活動情報を示す部分は更新されません。 新しいプロセスが起動した時に一度だけ、プロセスの表題は設定されます。 プラットフォームの中には、これによりコマンドごとのオーバーヘッドをかなり抑えられるものもありますし、まったく意味がないものもあります。

ヒント

<productname>Solaris</productname> requires special handling. You must use <command>/usr/ucb/ps</command>, rather than <command>/bin/ps</command>. You also must use two <option>w</option> flags, not just one. In addition, your original invocation of the <command>postgres</command> command must have a shorter <command>ps</command> status display than that provided by each server process. If you fail to do all three things, the <command>ps</command> output for each server process will be the original <command>postgres</command> command line. Solarisでは特別な取り扱いが必要です。 /bin/psではなく、/usr/ucb/psを使用しなければなりません。 また、wフラグを1つではなく2つ使用しなければなりません。 さらに、元のpostgresの呼び出しに関するpsのステータス表示は、各サーバプロセスに関するステータス表示よりも短くなければなりません。 この3条件を全て満たさないと、各サーバプロセスのpsの出力は、元のpostgresのコマンドラインのものになってしまいます。