<div dir="ltr"><div dir="ltr">On Mon, 7 Oct 2019 at 11:50, Klaus Darilion &lt;<a href="mailto:klaus.mailinglists@pernau.at" target="_blank">klaus.mailinglists@pernau.at</a>&gt; wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello!<br>
<br>
We use slony 2.1.4 and will be forced to this version for some more time.<br>
<br>
Today I debugged an issue where the logswitching did not finish.<br>
Although it would be safe (in my opinion) to truncate the old log table,<br>
the logswitch_finish() fails with:<br>
<br>
  could not lock sl_log_2 - sl_log_2 not truncated<br>
<br>
The function tries to lock the sl_log table with:<br>
<br>
 begin;<br>
 lock table &quot;_regdnscluster&quot;.sl_log_2 in access exclusive mode nowait;<br>
<br>
The problem seems, that the table is so hot in reading (55 slaves) that<br>
the lock hardly succeeds.<br>
<br>
If I call logswitch_finish() manually (because the cleanup thread tries<br>
only every 10 minutes - hard coded) I need to call it approx 100 times<br>
until I get the lock.<br>
<br>
Is there a reason to use &quot;nowait&quot;? As far as I understand, it should be<br>
safe to wait some time until giving up, i.e.:<br>
<br>
SET lock_timeout TO &#39;10s&#39;;<br>
begin;<br>
lock table &quot;_regdnscluster&quot;.sl_log_2 in access exclusive mode;<br>
<br>
<br>
This way, log switching can happen more often.<br></blockquote><div><br></div><div>set lock_timeout was introduced in PostgreSQL 9.3, so it isn&#39;t available in &quot;all versions.&quot;<br><br></div><div>When it was introduced, we wouldn&#39;t have been keen on directly adopting it due to that factor, especially in view that one of the major use cases for Slony is as a way of upgrading from elderly versions of PostgreSQL.</div><div><br></div><div>It surely seems like a reasonable idea to attempt to use it now, for the reasons you suggest.</div><div><br></div><div>The way I&#39;d be inclined to adopt it would be as follows...</div><div><br></div><div>-  slon should check to see if lock_timeout is available (looking in pg_catalog.pg_settings where name=&#39;lock_timeout&#39;)&#39;</div><div>   - this is probably mostly localized to the function logswitch_finish()<br></div><div>-  if not, then stay with the current NOWAIT behaviour<br></div><div>-  if available, then set lock_timeout and attempt without NOWAIT</div><div>   - open question: what&#39;s the apropos lock_timeout time?  Probably configurable, perhaps that points to a new config parameter to add to confoptions.h and confoptions.c<br></div><div><br></div><div>It doesn&#39;t seem like either an enormous change or an awfully risky one.</div><div><br></div><div>I&#39;d love to see a patch to review for this ;-)<br></div><div><br></div><div><br></div><div><br></div></div></div>