Re: [PATCH] lock_timeout and common SIGALRM framework

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>, Ants Aasma <ants(at)cybertec(dot)at>
Subject: Re: [PATCH] lock_timeout and common SIGALRM framework
Date: 2012-04-04 13:17:14
Message-ID: 4F7C49DA.7080008@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

2012-04-04 12:30 keltezéssel, Boszormenyi Zoltan írta:
> Hi,
>
> attached is a patch to implement a framework to simplify and
> correctly nest multiplexing more than two timeout sources
> into the same SIGALRM signal handler.
>
> The framework is using a new internal API for timeouts:
>
> bool enable_timeout(TimeoutName tn, int delayms);
> bool disable_timeout(TimeoutName tn, bool keep_indicator);
> bool disable_all_timeouts(bool keep_indicators);
>
> A timeout source has these features to allow different initialization,
> cleanup and check functions and rescheduling:
>
> typedef void (*timeout_init)(TimestampTz, TimestampTz);
> typedef void (*timeout_destroy)(bool);
> typedef bool (*timeout_check)(void);
> typedef TimestampTz (*timeout_start)(void);
>
> typedef struct {
> TimeoutName index;
> bool resched_next;
> timeout_init timeout_init;
> timeout_destroy timeout_destroy;
> timeout_check timeout_check;
> timeout_start timeout_start;
> TimestampTz fin_time;
> } timeout_params;
>
> This makes it possible to differentiate between the standby and
> statement timeouts, regular deadlock and standby deadlock using
> the same signal handler function.
>
> And finally, this makes it possible to implement the lock_timeout
> feature that we at Cybertec implemented more than 2 years ago.
>
> The patch also adds two new tests into prepared_xacts.sql to trigger
> the lock_timeout instead of statement_timeout.
>
> Documentation and extensive comments are included.

Second version. Every timeout-related functions are now in a separate
source file, src/backend/storage/timeout.c with accessor functions.
There are no related global variables anymore, only the GUCs.

>
> Best regards,
> Zoltán Böszörményi

--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig& Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/

Attachment Content-Type Size
pg92-common-lock-framework-lock_timeout-v2.patch text/x-patch 92.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2012-04-04 13:17:32 Question regarding SSL code in backend and frontend
Previous Message Tomas Vondra 2012-04-04 13:00:40 Re: performance-test farm