Skip to content

Commit

Permalink
Traduction de bgworker
Browse files Browse the repository at this point in the history
  • Loading branch information
rjuju authored and gleu committed Oct 21, 2014
1 parent 5718cb7 commit 17fbf2d
Showing 1 changed file with 85 additions and 78 deletions.
163 changes: 85 additions & 78 deletions postgresql/bgworker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
</warning>

<para>
Background workers can be initialized at the time that
<productname>PostgreSQL</productname> is started by including the module name in
<varname>shared_preload_libraries</varname>. A module wishing to run a background
worker can register it by calling
<function>RegisterBackgroundWorker(<type>BackgroundWorker *worker</type>)</function>
from its <function>_PG_init()</function>. Background workers can also be started
after the system is up and running by calling the function
<function>RegisterDynamicBackgroundWorker(<type>BackgroundWorker
*worker, BackgroundWorkerHandle **handle</type>)</function>. Unlike
<function>RegisterBackgroundWorker</function>, which can only be called from within
the postmaster, <function>RegisterDynamicBackgroundWorker</function> must be
called from a regular backend.
Les processus en tâche de fond peuvent être initialisés au moment où
<productname>PostgreSQL</productname> est démarré en incluant le nom du
module dans <varname>shared_preload_libraries</varname>. Un module qui
souhaite fonctionner comme un processus en tâche de fond peut s'enregistrer en
appelant <function>RegisterBackgroundWorker(<type>BackgroundWorker *worker</type>)</function>
dans son <function>_PG_init()</function>. Les processus en tâche de fond
peuvent également être démarrés après que le système ait démarré et soit en
fonctionnement en appelant la fonction <function>RegisterDynamicBackgroundWorker(
<type>BackgroundWorker *worker, BackgroundWorkerHandle **handle</type>)</function>.
À la différence de <function>RegisterBackgroundWorker</function>, qui ne peut
être appelée que depuis le postmaster,<function>RegisterDynamicBackgroundWorker</function>
doit être appelée depuis un processus client standard.
</para>

<para>
Expand Down Expand Up @@ -114,38 +114,40 @@ typedef struct BackgroundWorker
<structfield>bgw_main_arg</structfield> lui sera passé comme unique argument.
Notez que la variable globale <literal>MyBgworkerEntry</literal> pointe vers
une copie de la structure <structname>BackgroundWorker</structname> passée
lors de l'enregistrement. <structfield>bgw_main</structfield> may be
NULL; in that case, <structfield>bgw_library_name</structfield> and
<structfield>bgw_function_name</structfield> will be used to determine
the entry point. This is useful for background workers launched after
postmaster startup, where the postmaster does not have the requisite
library loaded.
lors de l'enregistrement. <structfield>bgw_main</structfield> peut valoir
NULL&nbsp;; dans ce cas, <structfield>bgw_library_name</structfield> et
<structfield>bgw_function_name</structfield> seront utilisés pour déterminer
le point d'entrée. C'est utile pour les processus en tâche de fond
lancés après le démarrage du postmaster, où le postmaster n'a pas les
bibliothèques nécessaires chargées.
</para>

<para>
<structfield>bgw_library_name</structfield> is the name of a library in
which the initial entry point for the background worker should be sought.
It is ignored unless <structfield>bgw_main</structfield> is NULL.
But if <structfield>bgw_main</structfield> is NULL, then the named library
will be dynamically loaded by the worker process and
<structfield>bgw_function_name</structfield> will be used to identify
the function to be called.
<structfield>bgw_library_name</structfield> est le nom d'une bibliothèque
dans laquelle le point d'entrée initial pour le processus en tâche de fond
devrait être recherché. Il est ignoré à moins que
<structfield>bgw_main</structfield> ne vaille NULL.
Mais si <structfield>bgw_main</structfield> vaut NULL, alors cette
bibliothèque sera chargée dynamiquement par le processus en tâche de fond et
<structfield>bgw_function_name</structfield> sera utilisé pour identifier la
fonction à appeler.
</para>

<para>
<structfield>bgw_function_name</structfield> is the name of a function in
a dynamically loaded library which should be used as the initial entry point
for a new background worker. It is ignored unless
<structfield>bgw_main</structfield> is NULL.
<structfield>bgw_function_name</structfield> est le nom d'une fonction dans
une bibliothèque chargée dynamiquement qui devrait être utilisée comme point
d'entrée initial pour un nouveau processus en tâche de fond.
Il est ignoré à moins que <structfield>bgw_main</structfield> ne vaille NULL.
</para>

<para>
<structfield>bgw_notify_pid</structfield> is the PID of a PostgreSQL
backend process to which the postmaster should send <literal>SIGUSR1</literal>
when the process is started or exits. It should be 0 for workers registered
at postmaster startup time, or when the backend registering the worker does
not wish to wait for the worker to start up. Otherwise, it should be
initialized to <literal>MyProcPid</literal>.
<structfield>bgw_notify_pid</structfield> est le PID d'un processus client
PostgreSQL auquel le postmaster devrait envoyer un signal <literal>SIGUSR1</literal>
quand le processus est démarré ou quitte. Il devrait valoir 0 pour les
processus en tâche de fond enregistrés lors du démarrage du postmaster, ou
quand le processus client enregistrant le processus en tâche de fond ne
souhaite pas attendre que le processus en tâche de fond ne démarre. Sinon,
il devrait être initialisé à <literal>MyProcPid</literal>.
</para>

<para>Une fois démarré, le processus peut se connecter à une base en appelant
Expand All @@ -171,56 +173,61 @@ typedef struct BackgroundWorker
</para>

<para>
If <structfield>bgw_restart_time</structfield> for a background worker is
configured as <literal>BGW_NEVER_RESTART</literal>, or if it exits with an exit
code of 0 or is terminated by <function>TerminateBackgroundWorker</function>,
it will be automatically unregistered by the postmaster on exit.
Otherwise, it will be restarted after the time period configured via
<structfield>bgw_restart_time</structfield>, or immediately if the postmaster
reinitializes the cluster due to a backend failure. Backends which need
to suspend execution only temporarily should use an interruptible sleep
rather than exiting; Vérifiez
que le drapeau <literal>WL_POSTMASTER_DEATH</literal> est positionné lors de
l'appel à cette fonction, et vérifiez le code retour pour une sortie rapide
dans le cas d'urgence où <command>postgres</command> lui-même se termine.
Si <structfield>bgw_restart_time</structfield> est configuré à
<literal>BGW_NEVER_RESTART</literal> pour un processus en tâche de fond ou
s'il quitte avec un code de sortie 0, ou encore s'il est terminé par
<function>TerminateBackgroundWorker</function>, il sera automatiquement
désenregistré par le postmaster lors de sa sortie. Sinon, il sera redémarré
après que la période de temps configurée via
<structfield>bgw_restart_time</structfield>, ou immédiatement si le
postmaster réinitialise l'instance à cause d'une défaillance d'un processus
client. Les processus en tâche de fond qui nécessitent de suspendre leur
exécution seulement temporairement devraient utiliser un sommeil interruptible
plutôt que de quitter. Vérifiez que le drapeau
<literal>WL_POSTMASTER_DEATH</literal> est positionné lors de l'appel à cette
fonction, et vérifiez le code retour pour une sortie rapide dans le cas
d'urgence où <command>postgres</command> lui-même se termine.
</para>

<para>
When a background worker is registered using the
<function>RegisterDynamicBackgroundWorker</function> function, it is
possible for the backend performing the registration to obtain information
regarding the status of the worker. Backends wishing to do this should
pass the address of a <type>BackgroundWorkerHandle *</type> as the second
argument to <function>RegisterDynamicBackgroundWorker</function>. If the
worker is successfully registered, this pointer will be initialized with an
opaque handle that can subsequently be passed to
<function>GetBackgroundWorkerPid(<parameter>BackgroundWorkerHandle *</parameter>, <parameter>pid_t *</parameter>)</function> or
Quand un processus en tâche de fond est enregistré en utilisant la fonction
<function>RegisterDynamicBackgroundWorker</function>, le processus client
effectuant cet enregistrement peut obtenir des informations concernant le
statut du processus en tâche de fond. Les processus clients souhaitant faire
cela devraient fournir l'adresse d'un <type>BackgroundWorkerHandle *</type>
comme second argument pour <function>RegisterDynamicBackgroundWorker</function>.
Si l'enregistrement du processus en tâche de fond est réussi, ce pointeur
sera initialisé avec un handle opaque qui peut alors être fourni à
<function>GetBackgroundWorkerPid(<parameter>BackgroundWorkerHandle *</parameter>, <parameter>pid_t *</parameter>)</function> ou
<function>TerminateBackgroundWorker(<parameter>BackgroundWorkerHandle *</parameter>)</function>.
<function>GetBackgroundWorker</function> can be used to poll the status of the
worker: a return value of <literal>BGWH_NOT_YET_STARTED</literal> indicates that
the worker has not yet been started by the postmaster;
<literal>BGWH_STOPPED</literal> indicates that it has been started but is
no longer running; and <literal>BGWH_STARTED</literal> indicates that it is
currently running. In this last case, the PID will also be returned via the
second argument.
<function>TerminateBackgroundWorker</function> causes the postmaster to send
<literal>SIGTERM</literal> to the worker if it is running, and to unregister it
as soon as it is not.
<function>GetBackgroundWorker</function> peut être utilisé pour interroger
le statut du processus en tâche de fond&nbsp;: une valeur de retour valant
<literal>BGWH_NOT_YET_STARTED</literal> indique que le processus en tâche de
fond n'a pas encore été démarré par le postmaster;
<literal>BGWH_STOPPED</literal> indique qu'il a été démarré mais n'est plus
en fonctionnement; et <literal>BGWH_STARTED</literal> indique qu'il est
actuellement en fonctionnement. Dans le dernier cas, le PID sera également
renvoyé via le deuxième argument.
<function>TerminateBackgroundWorker</function> demande postmaster d'envoyer
un signal <literal>SIGTERM</literal> au processus en tâche de fond s'il est
en train de fonctionner, et de le désenregistrer dès qu'il ne sera plus en
fonctionnement.
</para>

<para>
In some cases, a process which registers a background worker may wish to
wait for the worker to start up. This can be accomplished by initializing
<structfield>bgw_notify_pid</structfield> to <literal>MyProcPid</literal> and
then passing the <type>BackgroundWorkerHandle *</type> obtained at
registration time to
Dans certains cas, un processus qui enregistre un processus en tâche de
fond peut souhaiter attendre le démarrage du processus en tâche de fond.
Ceci peut être fait en initialisant <structfield>bgw_notify_pid</structfield>
à <literal>MyProcPid</literal> et en fournissant ensuite le
<type>BackgroundWorkerHandle *</type> obtenu au moment de l'enregistrement à
la fonction
<function>WaitForBackgroundWorkerStartup(<parameter>BackgroundWorkerHandle
*handle</parameter>, <parameter>pid_t *</parameter>)</function> function.
This function will block until the postmaster has attempted to start the
background worker, or until the postmaster dies. If the background runner
is running, the return value will <literal>BGWH_STARTED</literal>, and
the PID will be written to the provided address. Otherwise, the return
value will be <literal>BGWH_STOPPED</literal> or
*handle</parameter>, <parameter>pid_t *</parameter>)</function>.
Cette fonctionne bloquera jusqu'à ce que le postmaster ait tenté de démarrer
le processus en tâche de fond, ou jusqu'à l'arrêt du postmaster. Si le
processus en tâche de fond est en fonctionnement, la valeur retournée sera
<literal>BGWH_STARTED</literal>, et le PID sera écrit à l'adresse fournie.
Sinon, la valeur de retour sera <literal>BGWH_STOPPED</literal> ou
<literal>BGWH_POSTMASTER_DIED</literal>.
</para>

Expand All @@ -230,7 +237,7 @@ typedef struct BackgroundWorker
</para>

<para>
The maximum number of registered background workers is limited by
Le nombre maximum de processus en tâche de fond enregistré est limité par
<xref linkend="guc-max-worker-processes"/>.
</para>
</chapter>

0 comments on commit 17fbf2d

Please sign in to comment.