autovacuum locking question

Mike Schanne <[email protected]> Thu, 5 Dec 2019 17:46:19 +0000
Newsgroups gmane.comp.db.postgresql.performance
Message-ID <[email protected]>
--_000_0871fcf35ceb4caa8a2204ca9c38e330USEPRDEX1corpknscom_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi,
I am investigating a performance problem in our application and am seeing s=
omething unexpected in the postgres logs regarding the autovacuum.

2019-12-01 13:05:39.029 UTC,"wb","postgres",6966,"127.0.0.1:53976",5ddbd990=
.1b36,17099,"INSERT waiting",2019-11-25 13:39:28 UTC,12/1884256,12615023,LO=
G,00000,"process 6966 still waiting for RowExclusiveLock on relation 32938 =
of database 32768 after 1000.085 ms","Process holding the lock: 6045. Wait =
queue: 6966.",,,,,"INSERT INTO myschema.mytable (...) VALUES (...) RETURNIN=
G process.mytable.mytable_id",13,,""
2019-12-01 13:05:39.458 UTC,,,6045,,5de3b800.179d,1,,2019-12-01 12:54:24 UT=
C,10/417900,0,ERROR,57014,"canceling autovacuum task",,,,,"automatic vacuum=
 of table ""postgres.myschema.mytable""",,,,""

My understanding from reading the documentation was that a vacuum can run c=
oncurrently with table inserts/updates, but from reading the logs it appear=
s they are conflicting over a row lock.  This particular table gets very fr=
equent inserts/updates (10-100 inserts / sec) so I am concerned that if the=
 autovacuum is constantly canceled, then the table never gets cleaned and i=
ts performance will continue to degrade over time.  Is it expected for the =
vacuum to be canceled by an insert in this way?

We are using postgres 9.6.10.

Thanks,
Mike

________________________________

This email is non-binding, is subject to contract, and neither Kulicke and =
Soffa Industries, Inc. nor its subsidiaries (each and collectively "K&S") s=
hall have any obligation to you to consummate the transactions herein or to=
 enter into any agreement, other than in accordance with the terms and cond=
itions of a definitive agreement if and when negotiated, finalized and exec=
uted between the parties. This email and all its contents are protected by =
International and United States copyright laws. Any reproduction or use of =
all or any part of this email without the express written consent of K&S is=
 prohibited.

--_000_0871fcf35ceb4caa8a2204ca9c38e330USEPRDEX1corpknscom_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri","sans-serif";}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Hi,<o:p></o:p></p>
<p class=3D"MsoNormal">I am investigating a performance problem in our appl=
ication and am seeing something unexpected in the postgres logs regarding t=
he autovacuum.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">2019-12-01 13:05:39.029 UTC,&quot;wb&quot;,&quot;pos=
tgres&quot;,6966,&quot;127.0.0.1:53976&quot;,5ddbd990.1b36,17099,&quot;INSE=
RT waiting&quot;,2019-11-25 13:39:28 UTC,12/1884256,12615023,LOG,00000,&quo=
t;process 6966 still waiting for RowExclusiveLock on relation 32938 of data=
base
 32768 after 1000.085 ms&quot;,&quot;Process holding the lock: 6045. Wait q=
ueue: 6966.&quot;,,,,,&quot;INSERT INTO myschema.mytable (...) VALUES (...)=
 RETURNING process.mytable.mytable_id&quot;,13,,&quot;&quot;<o:p></o:p></p>
<p class=3D"MsoNormal">2019-12-01 13:05:39.458 UTC,,,6045,,5de3b800.179d,1,=
,2019-12-01 12:54:24 UTC,10/417900,0,ERROR,57014,&quot;canceling autovacuum=
 task&quot;,,,,,&quot;automatic vacuum of table &quot;&quot;postgres.mysche=
ma.mytable&quot;&quot;&quot;,,,,&quot;&quot;<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">My understanding from reading the documentation was =
that a vacuum can run concurrently with table inserts/updates, but from rea=
ding the logs it appears they are conflicting over a row lock.&nbsp; This p=
articular table gets very frequent inserts/updates
 (10-100 inserts / sec) so I am concerned that if the autovacuum is constan=
tly canceled, then the table never gets cleaned and its performance will co=
ntinue to degrade over time.&nbsp; Is it expected for the vacuum to be canc=
eled by an insert in this way?<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">We are using postgres 9.6.10.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Thanks,<o:p></o:p></p>
<p class=3D"MsoNormal">Mike<o:p></o:p></p>
</div>
<br>
<hr>
<font face=3D"Arial" color=3D"Black" size=3D"2"><br>
This email is non-binding, is subject to contract, and neither Kulicke and =
Soffa Industries, Inc. nor its subsidiaries (each and collectively &#8220;K=
&amp;S&#8221;) shall have any obligation to you to consummate the transacti=
ons herein or to enter into any agreement, other
 than in accordance with the terms and conditions of a definitive agreement=
 if and when negotiated, finalized and executed between the parties. This e=
mail and all its contents are protected by International and United States =
copyright laws. Any reproduction
 or use of all or any part of this email without the express written consen=
t of K&amp;S is prohibited.<br>
</font>
</body>
</html>

--_000_0871fcf35ceb4caa8a2204ca9c38e330USEPRDEX1corpknscom_--