MVCC works in serialized mode!
CVS is just updated...
Please try concurrent writes/reads...
It'll take some time to implement READ COMMITTED mode...
Note:
1. Vacuum is not updated yet and so will remove deleted tuples
though some xactions would like to see them in selects...
2. LOCK TABLE modes are not yet implemented...
3. As well as SELECT ... FOR UPDATE: I need in advice here!
Do Oracle, Informix etc support SELECT FOR UPDATE if
there are aggregates, group by, distinct in SELECT ???
Is SELECT FOR UPDATE allowed in subqueries ???
4. Rtree & gist indices use _relation level_ locking -
no wish, no time to change them...
Executor locks them in exclusive mode (on relation level)
for update/insert and so prevents deadlocks...
These locks released after _query_ is done - not so bad
for concurrency...
5. Hash & btree indices use _page level_ locking and so
are "opened" for deadlocks -:))
(In the case of concurrent inserts/updates when
indices are used for scans).
I hope to change btree - it's possible, -
but not hashes...
6. I'm not happy with current deadlock detection code!
It seems that backend does DeadLockCheck each time
when timer expired - shouldn't this be done _once_,
before backend is going to sleep ?!
7. As I read in Sybase documentation the default
standard transaction mode is _chained_ - all
queries before explicit COMMIT/ABORT are run in _single
transaction_... But we have to use BEGIN/END to get it!
This was not so bad for system with relation level locks,
but now only the same row writes block one other and so
chained mode seems more appropriate...
Shouldn't we change default transaction mode now?
And use option/SET TRANSACTION MODE to switch to
un-chained mode if one like it?
Vadim
6. I'm not happy with current deadlock detection code!
It seems that backend does DeadLockCheck each time
when timer expired - shouldn't this be done _once_,
before backend is going to sleep ?!
Not sure. Now that I think of it, it makes sense that if I go to sleep,
a deadlock is not sudenly going to appear while I am asleep. If a new
process causes a deadlock, the new process that causes it will see it.
I did not check when I went to sleep because I thought it may be too
cpu-intensive to do checking on every sleep, but now that I remember it,
it may be very trivial in cpu time to do the check on every sleep.
I recommend changing it to do it just before every sleep. Let me know
if you want me to make the change.
--
Bruce Momjian | http://www.op.net/~candle
maillist@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Bruce Momjian wrote:
6. I'm not happy with current deadlock detection code!
It seems that backend does DeadLockCheck each time
when timer expired - shouldn't this be done _once_,
before backend is going to sleep ?!Not sure. Now that I think of it, it makes sense that if I go to sleep,
a deadlock is not sudenly going to appear while I am asleep. If a new
process causes a deadlock, the new process that causes it will see it.I did not check when I went to sleep because I thought it may be too
cpu-intensive to do checking on every sleep, but now that I remember it,
it may be very trivial in cpu time to do the check on every sleep.I recommend changing it to do it just before every sleep. Let me know
if you want me to make the change.
May be we could just reduce first sleep time (60 sec is too long),
do DeadLockCheck _only once_, after first SIGALARM, and after that
just sleep forever ?
Why do DeadLockCheck many times ?
Let's think more...
And please consider when lock conflict occures:
1. One process tries update row being updated by other.
2. When reading/writing hashes (I hope to change btrees to
use new buffer context lock code, as heap access methods
do, - this is short term locking without deadlocks and so -
without using lockmanager).
Vadim
Bruce Momjian wrote:
6. I'm not happy with current deadlock detection code!
It seems that backend does DeadLockCheck each time
when timer expired - shouldn't this be done _once_,
before backend is going to sleep ?!Not sure. Now that I think of it, it makes sense that if I go to sleep,
a deadlock is not sudenly going to appear while I am asleep. If a new
process causes a deadlock, the new process that causes it will see it.I did not check when I went to sleep because I thought it may be too
cpu-intensive to do checking on every sleep, but now that I remember it,
it may be very trivial in cpu time to do the check on every sleep.I recommend changing it to do it just before every sleep. Let me know
if you want me to make the change.May be we could just reduce first sleep time (60 sec is too long),
Yes, much too long. 5 or 15 seconds sounds good.
do DeadLockCheck _only once_, after first SIGALARM, and after that
just sleep forever ?
Why do DeadLockCheck many times ?
Yes, no need to do many times.
OK. Should I make the change?
Let's think more...
And please consider when lock conflict occures:
1. One process tries update row being updated by other.
2. When reading/writing hashes (I hope to change btrees to
use new buffer context lock code, as heap access methods
do, - this is short term locking without deadlocks and so -
without using lockmanager).
Oh. I would think even a 1 second deadlock detection would work well.
Most short-term locks don't last that long.
--
Bruce Momjian | http://www.op.net/~candle
maillist@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Bruce Momjian wrote:
6. I'm not happy with current deadlock detection code!
It seems that backend does DeadLockCheck each time
when timer expired - shouldn't this be done _once_,
before backend is going to sleep ?!Not sure. Now that I think of it, it makes sense that if I go to sleep,
a deadlock is not sudenly going to appear while I am asleep. If a new
process causes a deadlock, the new process that causes it will see it.I did not check when I went to sleep because I thought it may be too
cpu-intensive to do checking on every sleep, but now that I remember it,
it may be very trivial in cpu time to do the check on every sleep.I recommend changing it to do it just before every sleep. Let me know
if you want me to make the change.May be we could just reduce first sleep time (60 sec is too long),
do DeadLockCheck _only once_, after first SIGALARM, and after that
just sleep forever ?
Why do DeadLockCheck many times ?Let's think more...
And please consider when lock conflict occures:
1. One process tries update row being updated by other.
2. When reading/writing hashes (I hope to change btrees to
use new buffer context lock code, as heap access methods
do, - this is short term locking without deadlocks and so -
without using lockmanager).Vadim
I have applied the following patch. It causes only one deadlock check
after a sleep of one second. Applied only to the CURRENT tree.
--
Bruce Momjian | http://www.op.net/~candle
maillist@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Attachments:
/tmp/xtext/plainDownload
Index: src/backend/parser/scan.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/parser/scan.c,v
retrieving revision 1.31
diff -c -r1.31 scan.c
*** scan.c 1998/10/13 17:26:50 1.31
--- scan.c 1998/12/18 19:30:54
***************
*** 1,7 ****
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
! * $Header: /usr/local/cvsroot/pgsql/src/backend/parser/scan.c,v 1.31 1998/10/13 17:26:50 scrappy Exp $
*/
#define FLEX_SCANNER
--- 1,7 ----
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
! * /master/usr.bin/lex/skel.c,v 1.3 1997/09/25 00:10:23 jch Exp
*/
#define FLEX_SCANNER
***************
*** 556,562 ****
*
*
* IDENTIFICATION
! * $Header: /usr/local/cvsroot/pgsql/src/backend/parser/scan.c,v 1.31 1998/10/13 17:26:50 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
--- 556,562 ----
*
*
* IDENTIFICATION
! * $Header: /usr/local/cvsroot/pgsql/src/backend/parser/scan.l,v 1.44 1998/10/08 18:29:51 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Index: src/backend/storage/lmgr/proc.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v
retrieving revision 1.43
diff -c -r1.43 proc.c
*** proc.c 1998/09/01 04:32:02 1.43
--- proc.c 1998/12/18 19:30:59
***************
*** 77,83 ****
#include "storage/proc.h"
#include "utils/trace.h"
! static void HandleDeadLock(int sig);
static PROC *ProcWakeup(PROC *proc, int errType);
#define DeadlockCheckTimer pg_options[OPT_DEADLOCKTIMEOUT]
--- 77,83 ----
#include "storage/proc.h"
#include "utils/trace.h"
! static void HandleDeadLock(void);
static PROC *ProcWakeup(PROC *proc, int errType);
#define DeadlockCheckTimer pg_options[OPT_DEADLOCKTIMEOUT]
***************
*** 154,161 ****
* Routine called if deadlock timer goes off. See ProcSleep()
* ------------------
*/
- pqsignal(SIGALRM, HandleDeadLock);
-
SpinAcquire(ProcStructLock);
/* attach to the free list */
--- 154,159 ----
***************
*** 449,457 ****
TransactionId xid) /* needed by user locks, see below */
{
int i;
PROC *proc;
! struct itimerval timeval,
! dummy;
/*
* If the first entries in the waitQueue have a greater priority than
--- 447,455 ----
TransactionId xid) /* needed by user locks, see below */
{
int i;
+ bool deadlock_checked = false;
PROC *proc;
! struct timeval timeval;
/*
* If the first entries in the waitQueue have a greater priority than
***************
*** 523,539 ****
* to 0.
* --------------
*/
! MemSet(&timeval, 0, sizeof(struct itimerval));
! timeval.it_value.tv_sec = \
(DeadlockCheckTimer ? DeadlockCheckTimer : DEADLOCK_CHECK_TIMER);
do
{
MyProc->errType = NO_ERROR; /* reset flag after deadlock check */
! if (setitimer(ITIMER_REAL, &timeval, &dummy))
elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
/* --------------
* if someone wakes us between SpinRelease and IpcSemaphoreLock,
* IpcSemaphoreLock will not block. The wakeup is "saved" by
--- 521,546 ----
* to 0.
* --------------
*/
! MemSet(&timeval, 0, sizeof(struct timeval));
! timeval.tv_sec = \
(DeadlockCheckTimer ? DeadlockCheckTimer : DEADLOCK_CHECK_TIMER);
do
{
+ int expire;
+
MyProc->errType = NO_ERROR; /* reset flag after deadlock check */
! if ((expire = select(0, NULL, NULL, NULL,
! (deadlock_checked == false) ? &timeval : NULL)) == -1)
elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
+ if (expire == 0 /* timeout reached */ && deadlock_checked == false)
+ {
+ HandleDeadLock();
+ deadlock_checked = true;
+ }
+
/* --------------
* if someone wakes us between SpinRelease and IpcSemaphoreLock,
* IpcSemaphoreLock will not block. The wakeup is "saved" by
***************
*** 545,558 ****
} while (MyProc->errType == STATUS_NOT_FOUND); /* sleep after deadlock
* check */
- /* ---------------
- * We were awoken before a timeout - now disable the timer
- * ---------------
- */
- timeval.it_value.tv_sec = 0;
- if (setitimer(ITIMER_REAL, &timeval, &dummy))
- elog(FATAL, "ProcSleep: Unable to diable timer for process wakeup");
-
/* ----------------
* We were assumed to be in a critical section when we went
* to sleep.
--- 552,557 ----
***************
*** 695,701 ****
* --------------------
*/
static void
! HandleDeadLock(int sig)
{
LOCK *mywaitlock;
--- 694,700 ----
* --------------------
*/
static void
! HandleDeadLock()
{
LOCK *mywaitlock;
Index: src/pl/plpgsql/src/gram.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/gram.c,v
retrieving revision 1.1
diff -c -r1.1 gram.c
*** gram.c 1998/10/28 17:07:17 1.1
--- gram.c 1998/12/18 19:31:12
***************
*** 65,71 ****
* procedural language
*
* IDENTIFICATION
! * $Header: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/gram.c,v 1.1 1998/10/28 17:07:17 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
--- 65,71 ----
* procedural language
*
* IDENTIFICATION
! * $Header: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.1 1998/08/24 19:14:47 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
Index: src/pl/plpgsql/src/scan.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/scan.c,v
retrieving revision 1.1
diff -c -r1.1 scan.c
*** scan.c 1998/10/28 17:07:17 1.1
--- scan.c 1998/12/18 19:31:21
***************
*** 635,641 ****
* procedural language
*
* IDENTIFICATION
! * $Header: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/scan.c,v 1.1 1998/10/28 17:07:17 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
--- 635,641 ----
* procedural language
*
* IDENTIFICATION
! * $Header: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/scan.l,v 1.1 1998/08/24 19:14:49 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
Bruce Momjian wrote:
I have applied the following patch. It causes only one deadlock check
after a sleep of one second. Applied only to the CURRENT tree.
Nice, at least for now.
Vadim
Hi all,
-----Original Message-----
From: owner-pgsql-hackers@postgreSQL.org
[mailto:owner-pgsql-hackers@postgreSQL.org]On Behalf Of Vadim Mikheev
Sent: Wednesday, December 16, 1998 10:01 PM
To: hackers@postgreSQL.org
Subject: [HACKERS] MVCC works in serialized mode!CVS is just updated...
Please try concurrent writes/reads...
I happend to enjoy MVCC a little in (v6.4.1) .
Readers are never blocked and writers are blocked only by
same row writers as I expected.
It's so comfortable.
But I have a question.
Once transactions are blocked,it takes so long time to resume
after blocks were removed.
Why ?
Currently blocked transactions resume immediately after blocks
were removed.
Thanks.
Hiroshi Inoue
Inoue@tpf.co.jp
[Charset iso-8859-1 unsupported, filtering to ASCII...]
Hi all,
-----Original Message-----
From: owner-pgsql-hackers@postgreSQL.org
[mailto:owner-pgsql-hackers@postgreSQL.org]On Behalf Of Vadim Mikheev
Sent: Wednesday, December 16, 1998 10:01 PM
To: hackers@postgreSQL.org
Subject: [HACKERS] MVCC works in serialized mode!CVS is just updated...
Please try concurrent writes/reads...
I happend to enjoy MVCC a little in (v6.4.1) .
That's funny.
Readers are never blocked and writers are blocked only by
same row writers as I expected.
It's so comfortable.
Wow, that is cool.
--
Bruce Momjian | http://www.op.net/~candle
maillist@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Hiroshi Inoue wrote:
CVS is just updated...
Please try concurrent writes/reads...
I happend to enjoy MVCC a little in (v6.4.1) .
Readers are never blocked and writers are blocked only by
same row writers as I expected.
It's so comfortable.But I have a question.
Once transactions are blocked,it takes so long time to resume
after blocks were removed.
Why ?
Currently blocked transactions resume immediately after blocks
were removed.
What do you mean?
Example please...
Vadim
-----Original Message-----
From: root@dune.krs.ru [mailto:root@dune.krs.ru]On Behalf Of Vadim
Mikheev
Sent: Friday, December 25, 1998 2:40 PM
To: Hiroshi Inoue
Cc: hackers@postgreSQL.org
Subject: Re: [HACKERS] MVCC works in serialized mode!Hiroshi Inoue wrote:
CVS is just updated...
Please try concurrent writes/reads...
I happend to enjoy MVCC a little in (v6.4.1) .
Readers are never blocked and writers are blocked only by
same row writers as I expected.
It's so comfortable.But I have a question.
Once transactions are blocked,it takes so long time to resume
after blocks were removed.
Why ?
Currently blocked transactions resume immediately after blocks
were removed.What do you mean?
Example please...
inoue=> create table t1 (key int,a int);
inoue=> insert into t1 values (1,0);
<Session-1> <Session-2>
inoue=> begin; inoue=> begin;
BEGIN BEGIN
inoue=> update t1 set a=1 where key=1;
UPDATE 1
inoue=> update
t1 set a=2 where key=1;
[ blocked ]
inoue=> end/abort;
END/ABORT
[ after
long time .... ]
ERROR: Can't
serialize access due to concurrent update
/ UPDATE 1
Thanks.
Hiroshi Inoue
Inoue@tpf.co.jp
Hiroshi Inoue wrote:
But I have a question.
Once transactions are blocked,it takes so long time to resume
after blocks were removed.
Why ?
Currently blocked transactions resume immediately after blocks
were removed.What do you mean?
Example please...[ after long time .... ]
ERROR: Can't serialize access due to concurrent update
Just tried (with CURRENT) - no problems...
Vadim
2. LOCK TABLE modes are not yet implemented...
Implemented, as well as SET TRANSACTION ISOLATION LEVEL...
3. As well as SELECT ... FOR UPDATE: I need in advice here!
Do Oracle, Informix etc support SELECT FOR UPDATE if
there are aggregates, group by, distinct in SELECT ???
As I see in Oracle documentation FOR UPDATE is disallowed
in these cases... No objections ?
Is SELECT FOR UPDATE allowed in subqueries ???
Could someone test this?
7. As I read in Sybase documentation the default
standard transaction mode is _chained_ - all
queries before explicit COMMIT/ABORT are run in _single
transaction_... But we have to use BEGIN/END to get it!
This was not so bad for system with relation level locks,
but now only the same row writes block one other and so
chained mode seems more appropriate...Shouldn't we change default transaction mode now?
And use option/SET TRANSACTION MODE to switch to
un-chained mode if one like it?
No comments on this?
I would like to make BEGIN implicit...
Objections?
Vadim
7. As I read in Sybase documentation the default
standard transaction mode is _chained_ - all
queries before explicit COMMIT/ABORT are run in _single
transaction_... But we have to use BEGIN/END to get it!
This was not so bad for system with relation level locks,
but now only the same row writes block one other and so
chained mode seems more appropriate...Shouldn't we change default transaction mode now?
And use option/SET TRANSACTION MODE to switch to
un-chained mode if one like it?No comments on this?
I would like to make BEGIN implicit...
Objections?
Informix requires BEGIN. Ingres does not, but has 'set autocommit'
mode, so each SQL statement is its own transaction, like we have now.
I always felt that if I go in to psql and run a query, I want it
applied. I don't want to have to commit every query I type.
I know I can use SET TRANSACTION MODE to change this.
What do others think?
--
Bruce Momjian | http://www.op.net/~candle
maillist@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Shouldn't we change default transaction mode now?
And use option/SET TRANSACTION MODE to switch to
un-chained mode if one like it?No comments on this?
I would like to make BEGIN implicit...
Objections?
Yes, I object. I think the default behavior should be the one that
is sufficient in most cases.
As to the isolation level:
Informix and DB/2 default to read committed mode. In most cases this
is
sufficient.
Therefore most clients don't need the extra set transaction
isolation statement.
As to transaction blocks:
Actually most clients never use commit work, and remember
that postgresql will never free it's memory before commit. This will
hog up
memory for otherwise lightweight clients.
I also think that the begin work; commit work; statement block is
somewhat part of the postgresql philosophy. We do not stand alone
with this approach (Informix).
Actually the other DB's start the transaction with the first
modifying
statement, in my opinion a rather weird approach.
I have seen programs that do a dummy update, just to simulate a
begin work, what a waste.
But this alone will not work, because a select statement, that needs
a sort would have started the transaction earlier (Since it created
an implicit
temp table).
I could go on, but you see I don't really like this ......
If you want to change the behavior, I think we will need a
changeable default
at database level.
Andreas
Import Notes
Resolved by subject fallback
Bruce Momjian wrote:
7. As I read in Sybase documentation the default
standard transaction mode is _chained_ - all
queries before explicit COMMIT/ABORT are run in _single
transaction_... But we have to use BEGIN/END to get it!
This was not so bad for system with relation level locks,
but now only the same row writes block one other and so
chained mode seems more appropriate...Shouldn't we change default transaction mode now?
And use option/SET TRANSACTION MODE to switch to
un-chained mode if one like it?No comments on this?
I would like to make BEGIN implicit...
Objections?Informix requires BEGIN. Ingres does not, but has 'set autocommit'
mode, so each SQL statement is its own transaction, like we have now.I always felt that if I go in to psql and run a query, I want it
applied. I don't want to have to commit every query I type.I know I can use SET TRANSACTION MODE to change this.
What do others think?
As long as we can switch. Interactive applications typically update more
than one objects per transaction.
--------
Regards
Theo
No comments on this?
I would like to make BEGIN implicit...
Objections?Informix requires BEGIN. Ingres does not, but has 'set autocommit'
mode, so each SQL statement is its own transaction, like we have now.
imho we should have an Ingres-like feature for "autocommit". We can have
the default be "set autocommit on" (probably with an equals sign like
our other "set" variables) and we can have it be a run-time option like
DATESTYLE and other settable parameters. So you can configure your
server or your client environment to always behave the way you prefer.
I'd be happy to implement the syntax and the environment variable parts;
just need a global boolean value to check and set...
- Tom
No time this year.
If necessary I will do it next year.Thanks.
Yes. I need to know if the code change between setitimer and select()
causes the difference you are seeing.
OK, I have re-coded that section. I had majorly broken it.
As part of the fix, I changed the deadlock detection in include/config.h
from 60 to 1. Remember, config.h is generated from config.h.in.
Can you change it back to 60 to see that the timeout is working
properly? The one-second default is not going to be noticable during
testing.
--
Bruce Momjian | http://www.op.net/~candle
maillist@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Import Notes
Reply to msg id not found: FromenvmaillistatDec281998112837pm | Resolved by subject fallback
Hello!
I want to make a filtered selection on a table. This can return with many
tuples. The download of the query results may take a few minutes. I'd like
to show the progress status. How can i do this?
If i run this in two query (first i count the number of lines, than the real
query), than the backend calculates the query two times.
If i use cursor, i can not get the line count before i fetch the whole table.
--
So long and thanx for all the fish.
NeKo@(kva.hu|kornel.szif.hu)
-----Original Message-----
From: Bruce Momjian [mailto:maillist@candle.pha.pa.us]
Sent: Wednesday, December 30, 1998 4:59 AM
To: PostgreSQL-development
Cc: Inoue@tpf.co.jp; vadim@krs.ru
Subject: Re: [HACKERS] MVCC works in serialized mode!No time this year.
If necessary I will do it next year.Thanks.
Yes. I need to know if the code change between setitimer and select()
causes the difference you are seeing.OK, I have re-coded that section. I had majorly broken it.
As part of the fix, I changed the deadlock detection in include/config.h
from 60 to 1. Remember, config.h is generated from config.h.in.Can you change it back to 60 to see that the timeout is working
properly? The one-second default is not going to be noticable during
testing.
I changed DEADLOCK_CHECK_TIMER in config.h to 60 and compiled.
Deadlock check takes about 60 seconds.
So timeout is set to 60 properly.
And the result is as follows.
create table t1 (key int,a int);
insert into t1 values (1,1);
Session-1 Session-2
begin; begin;
BEGIN BEGIN
update t1 set a=1;
UPDATE 1
update t1 set a=1;
[ update is blocked ]
abort;
ABORT
[ immediately ]
UPDATE 1
It's OK.
Thanks a lot.
Hiroshi Inoue
Inoue@tpf.co.jp
-----Original Message-----
From: owner-pgsql-hackers@postgreSQL.org
[mailto:owner-pgsql-hackers@postgreSQL.org]On Behalf Of Zeugswetter
Andreas IZ5
Sent: Monday, December 28, 1998 6:30 PM
To: hackers@postgreSQL.org
Cc: 'vadim@krs.ru'
Subject: Re: [HACKERS] MVCC works in serialized mode!Shouldn't we change default transaction mode now?
And use option/SET TRANSACTION MODE to switch to
un-chained mode if one like it?No comments on this?
I would like to make BEGIN implicit...
Objections?Yes, I object. I think the default behavior should be the one that
is sufficient in most cases.
I have a question about new default(isolation level / transaction mode).
How do we upgrade existent programs,if default is different
from current ?
I think the isolation level of current PostgreSQL is SERIALIZABLE
and the transaction mode is un-chained..
As to the isolation level,even SERIALIZABLE isolaton level can't guarantee
the integrity of current level.
So we must change existent programs anyway ?
Thanks.
Hiroshi Inoue
Inoue@tpf.co.jp
Show quoted text
As to the isolation level:
Informix and DB/2 default to read committed mode. In most cases this
is
sufficient.
Therefore most clients don't need the extra set transaction
isolation statement.As to transaction blocks:
Actually most clients never use commit work, and remember
that postgresql will never free it's memory before commit. This will
hog up
memory for otherwise lightweight clients.I also think that the begin work; commit work; statement block is
somewhat part of the postgresql philosophy. We do not stand alone
with this approach (Informix).
Actually the other DB's start the transaction with the first
modifying
statement, in my opinion a rather weird approach.
I have seen programs that do a dummy update, just to simulate a
begin work, what a waste.
But this alone will not work, because a select statement, that needsa sort would have started the transaction earlier (Since it created
an implicit
temp table).
I could go on, but you see I don't really like this ......If you want to change the behavior, I think we will need a
changeable default
at database level.Andreas
Hiroshi Inoue wrote:
I have a question about new default(isolation level / transaction mode).
How do we upgrade existent programs,if default is different
from current ?
I think the isolation level of current PostgreSQL is SERIALIZABLE
and the transaction mode is un-chained..As to the isolation level,even SERIALIZABLE isolaton level can't guarantee
the integrity of current level.
So we must change existent programs anyway ?
You're right!
The word from Oracle: (-:))
"Because Oracle does not use read locks, even in serializable
transactions, data read by one transaction can be overwritten
by another. Transactions that perform database consistency
checks at the application level should not assume that the data
they read will not change during the execution of the transaction
(even though such changes are not visible to the transaction).
Database inconsistencies can result unless such application-level
consistency checks are coded with this in mind, even when using
serializable transactions.
...
Although Oracle serializable mode is compatible with SQL92 and
offers many benefits as compared with read-locking implementations,
it does not provide semantics identical to such systems.
Application designers must take into account the fact that reads
in Oracle do not block writes as they do in other systems.
Transactions that check for database consistency at the application
level may require coding techniques such as the use of
SELECT FOR UPDATE. This issue should be considered when
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
applications using serializable mode are ported to Oracle
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from other environments."
^^^^^^^^^^^^^^^^^^^^^^^
1. All our applications run in serializable mode now.
2. "Environment" is changed from locking to
multi-versioning.
This has to be explained in release notes.
Should we implement ability to run backend in mode compatible
with old versions (it seems easy to do - just use AccessExclusive
Lock for UPDATE/INSERT/DELETE in Executor and don't release
AccessShare Lock in heap_endscan) ?
Vadim
Zeugswetter Andreas IZ5 wrote:
Shouldn't we change default transaction mode now?
And use option/SET TRANSACTION MODE to switch to
un-chained mode if one like it?No comments on this?
I would like to make BEGIN implicit...
Objections?Yes, I object. I think the default behavior should be the one that
is sufficient in most cases.As to the isolation level:
Informix and DB/2 default to read committed mode. In most cases this
is
sufficient.
Therefore most clients don't need the extra set transaction
isolation statement.
And this is the same as in Oracle & SyBase.
I don't object - currently READ COMMITTED is not
supported by DELETE/UPDATE code and so default is
SERIALIZABLE, to be changed latter.
As to transaction blocks:
Actually most clients never use commit work, and remember
In Oracle, COMMIT is implicit if DB connection is closed
in "normal" way - by using PQfinish in our case.
that postgresql will never free it's memory before commit. This will
hog up
memory for otherwise lightweight clients.
This is the bug, but I believe that it's fixed for
most cases ~1year ago by this
#ifdef TBL_FREE_CMD_MEMORY
EndPortalAllocMode();
StartPortalAllocMode(DefaultAllocMode, 0);
#endif
in xact.c
I also think that the begin work; commit work; statement block is
somewhat part of the postgresql philosophy. We do not stand alone
with this approach (Informix).
First, BEGIN/END is used in standard for grouping queries
(in PL etc), not for transaction control, and so currently
using of BEGIN/END is ambiguous.
Second, Informix is using locking => chained transaction
mode is way to lock-escalation.
Actually the other DB's start the transaction with the first
modifying
statement, in my opinion a rather weird approach.
I have seen programs that do a dummy update, just to simulate a
begin work, what a waste.
I believe that this is not how Oracle works.
I assumed that any DML statement will start transaction.
But this alone will not work, because a select statement, that needs
a sort would have started the transaction earlier (Since it created
an implicit
temp table).
^^^^^^^^^^
This is changed - backend don't create temp table now.
I could go on, but you see I don't really like this ......
If you want to change the behavior, I think we will need a
changeable default
at database level.
Ok, for compatibility reasons, I agreed that default
must be un-chained mode, with ability to switch in
compile/run time.
Vadim
"Thomas G. Lockhart" wrote:
No comments on this?
I would like to make BEGIN implicit...
Objections?Informix requires BEGIN. Ingres does not, but has 'set autocommit'
mode, so each SQL statement is its own transaction, like we have now.imho we should have an Ingres-like feature for "autocommit". We can have
the default be "set autocommit on" (probably with an equals sign like
our other "set" variables) and we can have it be a run-time option like
DATESTYLE and other settable parameters. So you can configure your
server or your client environment to always behave the way you prefer.I'd be happy to implement the syntax and the environment variable parts;
just need a global boolean value to check and set...
Nice! TIA -:)
Could you also change configure stuff, to choose default mode
before compiling?
Vadim
imho we should have an Ingres-like feature for "autocommit".
Nice! TIA -:)
Sure, but if I do too much work on this I'll need you to help on outer
joins :) (Actually, that's just an excuse; I'm flailing on it trying to
understand things you already know.)
Is there a global boolean "autocommit flag" already there to work with,
or could you add one? I'd like to (if possible) keep from getting sucked
into non-parser/non-docs work until I've worked out some of the outer
join stuff. But I can do the parser and "set autocommit" stuff. Also,
I'd like to go through the gram.y code for the new MVCC support commands
and have it use parser keywords rather than "Ident" entities for the
syntax. OK?
Could you also change configure stuff, to choose default mode
before compiling?
I'll set things up for it in the code, and perhaps Tom Lane or someone
can help with the configure support. We can ask when it's time...
- Tom
Hello all,
-----Original Message-----
From: root@dune.krs.ru [mailto:root@dune.krs.ru]On Behalf Of Vadim
Mikheev
Sent: Monday, January 11, 1999 1:26 AM
To: Hiroshi Inoue
Cc: hackers@postgreSQL.org
Subject: Re: [HACKERS] MVCC works in serialized mode!Hiroshi Inoue wrote:
I have a question about new default(isolation level / transaction mode).
How do we upgrade existent programs,if default is different
from current ?
I think the isolation level of current PostgreSQL is SERIALIZABLE
and the transaction mode is un-chained..
[snip]
1. All our applications run in serializable mode now.
2. "Environment" is changed from locking to
multi-versioning.This has to be explained in release notes.
Should we implement ability to run backend in mode compatible
with old versions (it seems easy to do - just use AccessExclusive
Lock for UPDATE/INSERT/DELETE in Executor and don't release
AccessShare Lock in heap_endscan) ?
Yes,if it's easy as you say.
But I don't know whether other people mind it or not.
If no one mind it,SERIALIZABLE is permissible for me.
BTW before user's code of our own,there are no problems with
interface library such as ODBC/JDBC etc ?
Those work well with chained mode or read committed isolation
level ?
Thanks.
Hiroshi Inoue
Inoue@tpf.co.jp