[Bizgres-general] [ENG] Re: Statement Queuing take II - Resource Scheduling
Mark Kirkwood
mkirkwood at greenplum.com
Mon Jul 24 05:55:54 UTC 2006
Alon Goldshuv wrote:
>
> Keep in mind that:
>
> - in between FETCHes other non related cursor commands may be executed.
> - there can be many cursors running, just waiting to be retrieved from
> shared memory when it's their turn to FETCH, and then wait for the next one.
> I guess this will mean 1 lock for every live cursor.
> - cursor doesn't always get closed by a CLOSE command. If the transaction is
> finished the cursor is closed automatically. So maybe PortalDrop is a
> strategic place to look at (?)
>
>
I found 2 bugs connected with cursors and prepared statements last week.
The first was that I had not handled unnamed prepared statements in
exec_parse_message, so was trivial to fix.
The second relates to having more than one cursor open at the same time
- the code is garbage collecting the PROCLOCK entry when the first
cursor closes, and so I get a missing PROCLOCK when the second one tries
to close (don't know how I missed this till now... but anyway).
What I need to do (I think), is to alter the lock granularity from queue
level to queue and statement level. This makes code still work pretty
much like standard locks and turns out to have some nice benefits for
the more sophisticated limit types (COST etc) e.g:
We need to remember the increment that we are requesting (e.g. a
statement's cost) - for lock acquisition *and* release. This is most
sensibly done by amending the PROCLOCK structure to accommodate an array
of increments. Now if we have 1 lock per queue, this array needs to be
variable sized (1 set of increments for each statement that 1 process
has running or waiting). However if I have 1 lock per queue and
statement, then we only need 1 set of increments (i.e. fixed size) for
each process and statement. This seems much better!
Clearly to implement this I need a statement or portal id I can use - It
seems that portals are referenced by name , which I can't use in a
LOCKTAG, so before I go and add some simple integer counter similar to
the unnamed_portal_count in CreateNewPortal, does anyone know of an
existing one I can use?
Cheers
Mark
More information about the Bizgres-general
mailing list