Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C0DAF632A74 for ; Wed, 13 Jan 2010 01:47:43 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 78523-09 for ; Wed, 13 Jan 2010 05:47:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.25]) by mail.postgresql.org (Postfix) with ESMTP id 2BDF1632AA0 for ; Wed, 13 Jan 2010 01:47:31 -0400 (AST) Received: by ey-out-2122.google.com with SMTP id 22so3978152eye.33 for ; Tue, 12 Jan 2010 21:47:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=B/RHwxh44diOjdyo2n8dtb/f+TfK/1ZKTdlSvg/OKFI=; b=nMlH0GCeSxfAo/25WBgRjUqC9rfsWXL+W5C0nO5kgjB5Ea57ou3QqCbjfl+sVjc/Qe uFxF3koAIRx1tuhCebhaXLDcsGgEKZ82OcDUakpgEqHkqll1nsoGi4sxTnYu5doUhKs+ gtfyC6wAJ+RBddd5T2VYS/6iSbmuCdzmBgQIM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=Ei0cearNdNEuHFncD7/bYG7HdHB8b5dPd3EdDqNgtqghvZDliHBgXcdEqENO4Lw2mz dJHhbdf7Bt0CooO7j8gA4pmfIQWXlWIFWw8eL5kVGPPgghFM+L3nhcWQRLj+NXPwbZRC 4jnISOEQ9Lq040gnHrPTIjSf73sDGijU3q0p8= MIME-Version: 1.0 Received: by 10.216.93.75 with SMTP id k53mr278527wef.209.1263361650398; Tue, 12 Jan 2010 21:47:30 -0800 (PST) In-Reply-To: <4B4D5698.8040808@emolecules.com> References: <4B4D5698.8040808@emolecules.com> Date: Wed, 13 Jan 2010 02:47:30 -0300 Message-ID: Subject: Re: a heavy duty operation on an "unused" table kills my server From: Eduardo Piombino To: Craig James Cc: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=0016e6d5665f6521eb047d054e97 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.591 tagged_above=-10 required=5 tests=BAYES_00=-2.599, FH_DATE_PAST_20XX=3.188, HTML_FONT_SIZE_LARGE=0.001, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201001/240 X-Sequence-Number: 37120 --0016e6d5665f6521eb047d054e97 Content-Type: text/plain; charset=ISO-8859-1 I'm sorry. The server is a production server HP Proliant, I don't remember the exact model, but the key features were: 4 cores, over 2GHz each (I'm sorry I don't remember the actual specs), I think it had 16G of RAM (if that is possible?) It has two 320G disks in RAID (mirrored). I don't even have the emails with the specs here, but I can give you the exact configuration by tomorrow. Operating system: Windows 2003 server, with latest patches. Postgres version: 8.2.4, with all defaults, except DateStyle and TimeZone. At any given time, the server is on 0% CPU load, with peaks of 1%, 2%, max. In normal operation. I've been digging a little in the archives, and one thing that it helped me come up with, is that I don't really remember seeing high CPU usage (fact that surprised me, but i do remember seeing high IO activity). I'm sorry, its pretty late here. I know this single statement is enough to almost change everything I've just asked. Please try interpreting again my original mail, considering that when I said "high CPU usage" It might very well be "high IO usage". The final effect was that the server went non-responsive, for all matters, not even the TaskManager would come up when i hit CTRL-ALT-DEL, and of course, every client would suffer horrific (+20 secs) for the simplest operations like SELECT NOW(); I've just made a little modification to my original questions, to extend to the possibility of a IO usage issue, instead of just CPU. * * > > *Bottom line is, I can't seem to do any heavy processing on the database > (or any operation that would require the server to enter into high CPU usage > **or IO USAGE), and still expect the server to behave normally. Whatever > heavy duty operation, DDL, DML, on whatever table (related, or unrelated), > on whatever thread, would tear down my servers integrity.* > > * My question then is: is there a way to limit the CPU or IO USAGEassigned to a specific connection? > * > * I mean, I don't care if my ALTER TABLE takes 4 days instead of 4 hours.* > > * Something like:* > * pg_set_max_cpu _or_io_usage(2/100);* > On Wed, Jan 13, 2010 at 2:14 AM, Craig James wrote: > Eduardo Piombino wrote: > >> Hi list, I'm having a problem when dealing with operations that asks too >> much CPU from the server. >> The scenario is this: >> > > A nice description below, but ... you give no information about your > system: number of CPUs, disk types and configuration, how much memory, what > have you changed in your Postgres configuration? And what operating system, > what version of Postgres, etc., etc. The more information you give, the > better the answer. > > If you're operating on a single disk with a tiny amount of memory, and old, > misconfigured Postgres on a laptop computer, that's a whole different > problem than if you're on a big sytem with 16 CPUs and a huge RAID 1+0 with > battery-backed cache. > Craig > > > >> I have a multithreaded server, each thread with its own connection to the >> database. Everything is working fine, actually great, actually >> outstandingly, in normal operation. >> >> I've a table named "a" with 1.8 million records, and growing, but I'm ok >> with it, at least for the moment. Maybe in the near future we will cut it >> down, backup old data, and free it up. But this is not the issue, as I said, >> everything is working great. I have a cpl of indexes to help some queries, >> and that's it. >> >> Now my problem started when I tried to do some model refactoring on this >> production table. >> >> First I tried a dumb approach. >> I connected from pgadmin, opened a new session. >> I tried an ALTER TABLE on this table just to turn a char(255) field into >> char(250), and it locked up my system. >> >> No surprise, since I had many threads waiting for this alter table to >> finish. What I did not foresee was that this alter table would take up so >> much time. Ok, my fault, for not having calculated the time that it would >> take the ALTER TABLE to complete. >> >> Now, with this experience, I tried a simple workaround. >> Created an empty version of "a" named "a_empty", identical in every sense. >> renamed "a" to "a_full", and "a_empty" to "a". This procedure costed me >> like 0 seconds of downtime, and everything kept working smoothly. Maybe a >> cpl of operations could have failed if they tried to write in the very >> second that there was actually no table named "a", but since the operation >> was transactional, the worst scenario was that if the operation should have >> failed, the client application would just inform of the error and ask the >> user for a retry. No big deal. >> >> Now, this table, that is totally unattached to the system in every way (no >> one references this table, its like a dumpster for old records), is not >> begin accessed by no other thread in the system, so an ALTER table on it, to >> turn a char(255) to char(250), should have no effect on the system. >> >> So, with this in mind, I tried the ALTER TABLE this time on the "a_full" >> (totally unrelated) table. >> The system went non-responsive again, and this time it had nothing to do >> with threads waiting for the alter table to complete. The pgAdmin GUI went >> non-responsive, as well as the application's server GUI, whose threads kept >> working on the background, but starting to take more and more time for every >> clients request (up to 25 seconds, which are just ridiculous and completely >> unacceptable in normal conditions). >> >> This resulted in my client applications to start disconnecting after their >> operations failed due to timeout, and the system basically went down again, >> from a users point of view. >> >> This time, since I saw no relation between my operation on a totally >> unrelated table, and the server BIG slowdown, I blamed the servers memory. >> >> After some tests, I came up to the conclusion that any heavy duty >> operation on any thread (ALTER TABLE on 1.8 million records tables, updates >> on this table, or an infinite loop, just to make my point), would affect the >> whole server. >> >> Bottom line is, I can't seem to do any heavy processing on the database >> (or any operation that would require the server to enter into high CPU usage >> *or IO USAGE*), and still expect the server to behave normally. Whatever >> heavy duty operation, DDL, DML, on whatever table (related, or unrelated), >> on whatever thread, would tear down my servers integrity. >> >> My question then is: is there a way to limit the CPU* or **IO USAGE* assigned >> to a specific connection? >> I mean, I don't care if my ALTER TABLE takes 4 days instead of 4 hours. >> >> Something like: >> pg_set_max_cpu*_or_io_*usage(2/100); >> >> and rest assured that no matter what that thread is asking the database to >> do, it just wont affect the other running threads. Obviosly, assuring that >> the process itself does not involve any locking of the other threads. >> >> Is something like that possible? >> >> Thanks in advance, >> Eduardo. >> >> > --0016e6d5665f6521eb047d054e97 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I'm sorry.

The server is a production server HP Proliant, I don&= #39;t remember the exact model, but the key features were:
4 cores, over= 2GHz each (I'm sorry I don't remember the actual specs), I think i= t had 16G of RAM (if that is possible?)
It has two 320G disks in RAID (mirrored).

I don't even have the emails with the specs here, but I can give yo= u the exact configuration by tomorrow.

Operating system: Windows 200= 3 server, with latest patches.
Postgres version: 8.2.4, with all default= s, except DateStyle and TimeZone.

At any given time, the server is on 0% CPU load, with peaks of 1%, 2%, = max. In normal operation.

I've been digging a little in the arch= ives, and one thing that it helped me come up with, is that I don't rea= lly remember seeing high CPU usage (fact that surprised me, but i do rememb= er seeing high IO activity). I'm sorry, its pretty late here.
I know this single statement is enough to almost change everything I've= just asked.
Please try interpreting again my original mail, considering= that when I said "high CPU usage" It might very well be "hi= gh IO usage".

The final effect was that the server went non-responsive, for all matte= rs, not even the TaskManager would come up when i hit CTRL-ALT-DEL, and of = course, every client would suffer horrific (+20 secs) for the simplest oper= ations like SELECT NOW();

I've just made a little modification to my original questions, to e= xtend to the possibility of a IO usage issue, instead of just CPU.


Bottom line is, I can't seem to do= any heavy processing on the database (or any operation that would require the server to enter into high CPU usage or IO USAGE), and still expect the server to behave normally. Whatever heavy duty operation, DDL, DML, on whatever table (related, or unrelated), on whatever thread, would tear down my servers integrity.

My question then is: is there a way to limit the CPU or IO USAGE assigned to a specific connect= ion?
I mean, I don't care if my ALTER TABLE takes 4 days instead of 4 hours.=

Something like:
pg_set_max_cpu _or_io_usage(2/100);


On Wed, Jan 13, 2010 at 2:14 AM, Craig J= ames <craig_james@emolecules.com> wrote:
Eduardo Piom= bino wrote:
Hi list, I'm having a problem when dealing with operations that asks to= o much CPU from the server.
The scenario is this:

A nice description below, but ... you give no information about your system= : number of CPUs, disk types and configuration, how much memory, what have = you changed in your Postgres configuration? =A0And what operating system, w= hat version of Postgres, etc., etc. =A0The more information you give, the b= etter the answer.

If you're operating on a single disk with a tiny amount of memory, and = old, misconfigured Postgres on a laptop computer, that's a whole differ= ent problem than if you're on a big sytem with 16 CPUs and a huge RAID = 1+0 with battery-backed cache.
=A0
<= font color=3D"#888888"> Craig



I have a multithreaded server, each thread with its own connection to the d= atabase. Everything is working fine, actually great, actually outstandingly= , in normal operation.

I've a table named "a" with 1.8 million records, and growing,= but I'm ok with it, at least for the moment. Maybe in the near future = we will cut it down, backup old data, and free it up. But this is not the i= ssue, as I said, everything is working great. I have a cpl of indexes to he= lp some queries, and that's it.

Now my problem started when I tried to do some model refactoring on this pr= oduction table.

First I tried a dumb approach.
I connected from pgadmin, opened a new session.
I tried an ALTER TABLE on this table just to turn a char(255) field into ch= ar(250), and it locked up my system.

No surprise, since I had many threads waiting for this alter table to finis= h. What I did not foresee was that this alter table would take up so much t= ime. Ok, my fault, for not having calculated the time that it would take th= e ALTER TABLE to complete.

Now, with this experience, I tried a simple workaround.
Created an empty version of "a" named "a_empty", identi= cal in every sense.
renamed "a" to "a_full", and "a_empty" to &qu= ot;a". This procedure costed me like 0 seconds of downtime, and everyt= hing kept working smoothly. Maybe a cpl of operations could have failed if = they tried to write in the very second that there was actually no table nam= ed "a", but since the operation was transactional, the worst scen= ario was that if the operation should have failed, the client application w= ould just inform of the error and ask the user for a retry. No big deal.
Now, this table, that is totally unattached to the system in every way (no = one references this table, its like a dumpster for old records), is not beg= in accessed by no other thread in the system, so an ALTER table on it, to t= urn a char(255) to char(250), should have no effect on the system.

So, with this in mind, I tried the ALTER TABLE this time on the "a_ful= l" (totally unrelated) table.
The system went non-responsive again, and this time it had nothing to do wi= th threads waiting for the alter table to complete. The pgAdmin GUI went no= n-responsive, as well as the application's server GUI, whose threads ke= pt working on the background, but starting to take more and more time for e= very clients request (up to 25 seconds, which are just ridiculous and compl= etely unacceptable in normal conditions).

This resulted in my client applications to start disconnecting after their = operations failed due to timeout, and the system basically went down again,= from a users point of view.

This time, since I saw no relation between my operation on a totally unrela= ted table, and the server BIG slowdown, I blamed the servers memory.

After some tests, I came up to the conclusion that any heavy duty operation= on any thread (ALTER TABLE on 1.8 million records tables, updates on this = table, or an infinite loop, just to make my point), would affect the whole = server.

Bottom line is, I can't seem to do any heavy processing on the database= (or any operation that would require the server to enter into high CPU usa= ge or IO USAGE), and still expect the server to behave normally. Whatever heavy duty o= peration, DDL, DML, on whatever table (related, or unrelated), on whatever = thread, would tear down my servers integrity.

My question then is: is there a way to limit the CPU or IO USAGE assigned to a speci= fic connection?
I mean, I don't care if my ALTER TABLE takes 4 days instead of 4 hours.=

Something like:
pg_set_max_cpu_or_io_<= /b>usage(2/100);

and rest assured that no matter what that thread is asking the database to = do, it just wont affect the other running threads. Obviosly, assuring that = the process itself does not involve any locking of the other threads.

Is something like that possible?

Thanks in advance,
Eduardo.



--0016e6d5665f6521eb047d054e97--