X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4BF605284E for ; Fri, 22 Jul 2005 09:58:09 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 79085-01 for ; Fri, 22 Jul 2005 12:58:03 +0000 (GMT) Received: from mx-00.sil.at (mx-00.sil.at [62.116.68.196]) by svr1.postgresql.org (Postfix) with ESMTP id ABC8252820 for ; Fri, 22 Jul 2005 09:58:01 -0300 (ADT) Received: (qmail-ldap/ctrl 46118 invoked from network); 22 Jul 2005 12:58:00 -0000 Received: from unknown (HELO io.sonorys.at) ([213.235.243.42]) (envelope-sender ) by mx-00.sil.at (qmail-ldap-1.03) with SMTP for ; 22 Jul 2005 12:58:00 -0000 Received: from neptun.sonorys.at (neptun.sonorys.at [172.24.1.17]) by io.sonorys.at (8.11.7+Sun/8.11.7) with ESMTP id j6MCw1G02493; Fri, 22 Jul 2005 14:58:02 +0200 (MEST) Received: by neptun.sonorys.at with Internet Mail Service (5.5.2653.19) id ; Fri, 22 Jul 2005 14:58:02 +0200 Message-ID: From: =?iso-8859-1?Q?K=D6PFERL_Robert?= To: "'Erik Wasser'" , pgsql-sql@postgresql.org Subject: Re: Are long term never commited SELECT statements are a pr Date: Fri, 22 Jul 2005 14:57:52 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/188 X-Sequence-Number: 22166 You may get problems. At least we did. Having a long term transaction which seemingly just was one Begin with nothing, we encountered a siginifficant decrease of performance after some days (70 tx/sec) During that the pg_subtrans dir filled up with files and the IO-reads of the disk as well. After closing the particular connection the normal performance reappeared. And the files in pg_subtrans became one file again. So far. BTW. You will see the DB with a glasses that shows you the time when the transaction started. |-----Original Message----- |From: Erik Wasser [mailto:erik.wasser@iquer.net] |Sent: Donnerstag, 21. Juli 2005 15:58 |To: pgsql-sql@postgresql.org |Subject: [SQL] Are long term never commited SELECT statements are a |problem? | | |Hello List, | |I've written an application in perl using DBI with MySQL (no |transaction |support). Then we decide to migrate it to postgresql |(postgresql-8.0.1-r4). | |At first we were using 'AutoCommit => 1' with the application. That |means that every statement will be commited right away. | |Then I discovered the 'magic of transactions' and set AutoCommit to 0. |Then I rewrite many UPDATE and INSERT statements with support for |commit and rollback. BUT: the SELECT statements were untouched (and |that was mistake I think). | |Now I've got here a blocking problem. Severel SQL statements (like |renaming a field or UPDATE of a field) are blocked until I kill a |certain task. This task DOES only the INSERTS and UPDATES with a |transaction and the SELECT statements are not within an transaction. |And this task is a long term running task (some kind of daemon) so the |SELECT transactions will never be commited. Are long term never |commited SELECT statements are a problem and could that lead to |blocking other queries? | |To put it in annother way: what kind of thing I produced with the |following pseudocode? | |# open database |$DBH = DBI->connect(...,USERNAME,PASSWORD, { RaiseError => 1, |AutoCommit |=> 0 }); | |while (true) |{ | # do some select | SELECT ... FROM ... | # do some more | SELECT ... FROM ... | | if (condition) | # do an UPDATE/INSERT | eval { | UPDATE/INSERT/... | $DBH->commit; | }; | if ($@) { | warn "Transaction aborted: $@"; | eval { $DBH->rollback }; | } | } |} | |Is this some kind of nested transaction? Can there be a problem with |this code? | |Thanks for your help! | |-- |So long... Fuzz | |---------------------------(end of |broadcast)--------------------------- |TIP 2: Don't 'kill -9' the postmaster |