Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Atri Sharma
> Right, the actual signal handler will only kill the query immediately > if the backend is in a safe state (eg, while it's waiting for a > heavyweight lock). Otherwise it just sets a flag that's checked by > CHECK_FOR_INTERRUPTS. See StatementCancelHandler in postgres.c. Roger that, I will defi

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Tom Lane
Atri Sharma writes: > Right.I believe this is part of the standard way in which we handle > interrupts,right? Making sure that we cancel a query when the backend > is in a state to do so,not when the interrupt actually comes in,right? Right, the actual signal handler will only kill the query imme

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Merlin Moncure
On Thu, May 23, 2013 at 10:43 AM, Atri Sharma wrote: >> >> A little bit --- the timeout won't actually kill the query until the >> next time control reaches a CHECK_FOR_INTERRUPTS macro that's not inside >> a critical section. We've had issues in the past with particular code >> paths that failed

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Atri Sharma
> > A little bit --- the timeout won't actually kill the query until the > next time control reaches a CHECK_FOR_INTERRUPTS macro that's not inside > a critical section. We've had issues in the past with particular code > paths that failed to include such a check in a long-running loop, and > ther

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Tom Lane
Atri Sharma writes: > I am not sure, but does statement_timeout depend on *what* the query > is doing internally(i.e. if it is holding lots of locks,pins etc)? A little bit --- the timeout won't actually kill the query until the next time control reaches a CHECK_FOR_INTERRUPTS macro that's not in

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Atri Sharma
On Thu, May 23, 2013 at 8:52 PM, Amit Langote wrote: >> >> If you let an uncooperative user issue arbitrary SQL queries, he can >> do any number of things to put server performance into the tank. >> For instance, take out exclusive locks on all your tables and just >> go to sleep (although I think

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Atri Sharma
> No, you're not following. These would be table-level heavyweight locks, > and there already are timeout mechanisms that work at that level. > Oh,right.Sorry,I missed that. I will go and research heavyweight locks now. Thanks a ton! Regards, Atri -- Regards, Atri l'apprenant -- Sent via

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Amit Langote
> > If you let an uncooperative user issue arbitrary SQL queries, he can > do any number of things to put server performance into the tank. > For instance, take out exclusive locks on all your tables and just > go to sleep (although I think this is limited by table permissions in > recent PG versio

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Tom Lane
Atri Sharma writes: >> For instance, take out exclusive locks on all your tables and just >> go to sleep (although I think this is limited by table permissions in >> recent PG versions). > This is what I have been worried about. The locks(exclusive locks or > content locks in buffers) can be held

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Atri Sharma
> For instance, take out exclusive locks on all your tables and just > go to sleep (although I think this is limited by table permissions in > recent PG versions). This is what I have been worried about. The locks(exclusive locks or content locks in buffers) can be held and stalled. Cant we do any

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Tom Lane
Atri Sharma writes: > BTW, what is your opinion on a rogue client's damaging capabilities? > Theoretically, what can a client which tries to stall the backend > target? If you let an uncooperative user issue arbitrary SQL queries, he can do any number of things to put server performance into the

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Atri Sharma
On Thu, May 23, 2013 at 8:18 PM, Tom Lane wrote: > Atri Sharma writes: >> I was musing over a possible condition where a rogue client gets the >> backend to process queries which take a *lot* of time(note, this is >> only in my head atm.I may be completely wrong here). > >> Wouldnt something on t

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Tom Lane
Atri Sharma writes: > I was musing over a possible condition where a rogue client gets the > backend to process queries which take a *lot* of time(note, this is > only in my head atm.I may be completely wrong here). > Wouldnt something on the lines of a timeout help here? You can already set sta

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Atri Sharma
On Thu, May 23, 2013 at 8:01 PM, Tom Lane wrote: > Atri Sharma writes: >> On a different note, shouldn't we have a time out for a content lock >> in buffer cache? > > No; the overhead of setting up and canceling such a timeout would > greatly outweigh any possible benefit. > > Generally speaking,

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Tom Lane
Atri Sharma writes: > On a different note, shouldn't we have a time out for a content lock > in buffer cache? No; the overhead of setting up and canceling such a timeout would greatly outweigh any possible benefit. Generally speaking, LWLocks are not meant to be used in situations where the lock

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Atri Sharma
Sent from my iPad On 23-May-2013, at 16:27, Amit Kapila wrote: > On Thursday, May 23, 2013 3:35 PM Atri Sharma wrote: >> Hi all, >> >> I was searching for an existing mechanism which ensures that a crashed >> process releases a content lock held on a page in buffer cache. Also, >> a similar m

Re: [HACKERS] Time limit for a process to hold Content lock in Buffer Cache

2013-05-23 Thread Amit Kapila
On Thursday, May 23, 2013 3:35 PM Atri Sharma wrote: > Hi all, > > I was searching for an existing mechanism which ensures that a crashed > process releases a content lock held on a page in buffer cache. Also, > a similar mechanism for refcount of the page. > > I seem to have missed it. Do we hav