gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnumed-devel] re: timeout instead of blocking


From: catmat
Subject: [Gnumed-devel] re: timeout instead of blocking
Date: Thu, 20 Jan 2005 09:01:29 +1100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041231

in postgresql.conf, if default_transaction_isolation and statement_timeout is uncommented and default_transaction_isolation is 'serializable' instead of 'read committed',

the concurrent write timeout and  abort works as expected.

e.g. transaction A does read(x), write(x), commit, and transaction B does the same.

A commits first,
then B will report a concurrent write access error when it tries to write(x) after reading x's old value
and A has committed a new value for x.

If B doesn't read x's old value before writing it, and A commits first, then B never saw an old value of
x so it can serialize the write to x, so it will succeed.

Interestingly, using listen "message" and notify "message", psql gets the message whenever any command is executed, unless it has started a transaction. Then it seems to only get the message on that connection when the transaction has committed or aborted and the next transaction started. A solution might be to have 2 connections per client, one for doing reading and writing, and one for message listening ( assuming the
pypgsql blocking listen command works).
    Then in the case above, when A commits , it issues a notify "message",
the listen channel on B's client gets the notification, and then B's client aborts its transaction, begins a new transaction and re-reads, including A's changes. Now when it tries to write x
after reading it , it has no problems, because it has seen A's x.


BTW , the above isn't necessary to know with the current scheme to use xmin to detect
changes between read and write transactions  .

( it just seems untidy to have to do your own concurrency checking with timestamps , using a timestamping transactional database system).




#---------------------------------------------------------------------------
# CLIENT CONNECTION DEFAULTS
#---------------------------------------------------------------------------

# - Statement Behavior -

#search_path = '$user,public'   # schema names
#check_function_bodies = true
default_transaction_isolation = 'serializable'
default_transaction_read_only = false
statement_timeout = 4000                # 0 is disabled, in milliseconds





reply via email to

[Prev in Thread] Current Thread [Next in Thread]