Commit Graph

127 Commits

Author SHA1 Message Date
Alvaro Herrera 1734992738 Fix typo 2011-09-27 16:50:27 -03:00
Alvaro Herrera 28190bacfd Add expected isolationtester output when prepared xacts are disabled
This was deemed unnecessary initially but in later discussion it was
agreed otherwise.

Original file from Kevin Grittner, allegedly from Dan Ports.
I had to clean up whitespace a bit per changes from Heikki.
2011-08-25 17:44:56 -03:00
Tom Lane 2e95f1f002 Add "%option warn" to all flex input files that lacked it.
This is recommended in the flex manual, and there seems no good reason
not to use it everywhere.
2011-08-25 13:55:57 -04:00
Alvaro Herrera f18795e7b7 Update FK alternative test output to new whitespace rules
With these changes, the isolation tests pass again on isolation levels
serializable and repeatable read.

Author: Kevin Grittner
2011-08-24 18:24:03 -03:00
Tom Lane 11c88e59a6 Explain max_prepared_transactions requirement in isolation tests' README.
Now that we have a test that requires nondefault settings to pass, it seems
like we'd better mention that detail in the directions about how to run the
tests.

Also do some very minor copy-editing.
2011-08-18 11:45:25 -04:00
Heikki Linnakangas af35737313 Add an SSI regression test that tests all interesting permutations in the
order of begin, prepare, and commit of three concurrent transactions that
have conflicts between them.

The test runs for a quite long time, and the expected output file is huge,
but this test caught some serious bugs during development, so seems
worthwhile to keep. The test uses prepared transactions, so it fails if the
server has max_prepared_transactions=0. Because of that, it's marked as
"ignore" in the schedule file.

Dan Ports
2011-08-18 17:09:58 +03:00
Heikki Linnakangas 62fd1afc55 Strip whitespace from SQL blocks in the isolation test suite. This is purely
cosmetic, it removes a lot of IMHO ugly whitespace from the expected output.
2011-08-18 17:09:58 +03:00
Alvaro Herrera c8dfc89232 Make isolationtester more robust on locked commands
Noah Misch diagnosed the buildfarm problems in the isolation tests
partly as failure to differentiate backends properly; the old code was
using backend IDs, which is not good enough because a new backend might
use an already used ID.  Use PIDs instead.

Also, the code was purposely careless about other concurrent activity,
because it isn't expected; and in fact, it doesn't affect the vast
majority of the time.  However, it can be observed that autovacuum can
block tables for long enough to cause sporadic failures.  The new code
accounts for that by ignoring locks held by processes not explicitly
declared in our spec file.

Author: Noah Misch
2011-07-19 14:22:42 -04:00
Alvaro Herrera d6db0e4e0e Increase deadlock_timeout to 100ms in FK isolation tests
The previous value of 20ms is dangerously close to the time actually
spent just waiting for the deadlock to happen, so on occasion it causes
the test to fail simply because the other session didn't get to run
early enough, not managing to cause the deadlock that needs to be
detected.  With this new value, it's expected that most machines on
normal load will be able to pass the test.

Author: Noah Misch
2011-07-19 13:07:16 -04:00
Alvaro Herrera a0eae1a2ee Add expected regress output on stricter isolation levels
These new files allow the new FK tests on isolationtester to pass on the
serializable and repeatable read isolation levels (which are untested
by the buildfarm).

Author: Kevin Grittner
Reviewed by Noah Misch
2011-07-19 12:43:16 -04:00
Alvaro Herrera d71197cd35 Set different deadlock_timeout on each session in new isolation tests
This provides deterministic deadlock-detection ordering for new
isolation tests, fixing the sporadic failures in them.

Author: Noah Misch
2011-07-15 18:43:33 -04:00
Alvaro Herrera 846af54dd5 Add support for blocked commands in isolationtester
This enables us to test that blocking commands (such as foreign keys
checks that conflict with some other lock) act as intended.  The set of
tests that this adds is pretty minimal, but can easily be extended by
adding new specs.

The intention is that this will serve as a basis for ensuring that
further tweaks of locking implementation preserve (or improve) existing
behavior.

Author: Noah Misch
2011-07-12 17:24:17 -04:00
Tom Lane 1568fa75bc Use single quotes in preference to double quotes for protecting pathnames.
Per recommendation from Peter.  Neither choice is bulletproof, but this
is the existing style and it does help prevent unexpected environment
variable substitution.
2011-06-15 21:45:23 -04:00
Tom Lane a61b6b7d18 Fix assorted issues with build and install paths containing spaces.
Apparently there is no buildfarm critter exercising this case after all,
because it fails in several places.  With this patch, build, install,
check-world, and installcheck-world pass for me on OS X.
2011-06-14 16:40:35 -04:00
Heikki Linnakangas 3103f9a77d The row-version chaining in Serializable Snapshot Isolation was still wrong.
On further analysis, it turns out that it is not needed to duplicate predicate
locks to the new row version at update, the lock on the version that the
transaction saw as visible is enough. However, there was a different bug in
the code that checks for dangerous structures when a new rw-conflict happens.
Fix that bug, and remove all the row-version chaining related code.

Kevin Grittner & Dan Ports, with some comment editorialization by me.
2011-05-30 20:47:17 +03:00
Tom Lane 446d5d32ae Grammar cleanup for src/test/isolation/README
Josh Kupershmidt
2011-05-24 18:52:15 -04:00
Andrew Dunstan b08ddf8c76 Use the right pgsql for isolation tests. 2011-05-22 17:58:26 -04:00
Andrew Dunstan 78b66cff72 Quote isolationtester command name so Windows will not think dot is the command. 2011-05-15 23:42:12 -04:00
Tom Lane 7886cc73ad Remove "make check" target in src/test/isolation/Makefile.
This doesn't work as expected because the isolationtester program requires
libpq to already be installed.  While it works when you've already installed
libpq, having to already have done "make install" defeats most of the point
of a check with a temp installation.  And there are weird corner cases if
the dynamic linker picks up an old libpq.so from system library directories.
Remove the target (or more precisely, make it print a helpful message) so
people don't expect the case to work.
2011-05-09 11:00:30 -04:00
Tom Lane eff223ffd7 Fix some portability issues in isolation regression test driver.
Remove random system #includes in favor of using postgres_fe.h.  (The
alternative to that is letting this module grow its own configuration
testing ability...)

Also fix the "make clean" target to actually clean things up.

Per local testing.
2011-05-08 19:45:00 -04:00
Bruce Momjian bf50caf105 pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
Heikki Linnakangas 74a09d9210 Fix bugs in the isolation tester flex rules.
Tom Lane pointed out that it was giving a warning: "-s option given but
default rule can be matched". That was because there was no rule to handle
newline in a quoted string. I made that throw an error.

Also, line number tracking was broken, giving incorrect line number on
error. Fixed that too.
2011-03-10 09:06:56 +02:00
Itagaki Takahiro 2d8de0a50b Cleanup copyright years and file names in the header comments of some files. 2011-03-10 15:05:33 +09:00
Tom Lane 174f65ab00 Fix some oversights in distprep and maintainer-clean targets.
At least two recent commits have apparently imagined that a comment in
a Makefile stating that something would be included in the distribution
tarball was sufficient to make it so.  They hadn't bothered to hook
into the upper maintainer-clean targets either.  Per bug #5923 from
Charles Johnson, in which it emerged that the 9.1alpha4 tarballs are
short a few files that should be there.
2011-03-10 00:04:05 -05:00
Alvaro Herrera 61cf7bcdf7 Fix isolation tester Makefile so that it runs in a VPATH build 2011-02-10 19:50:43 -03:00
Alvaro Herrera 289d730655 Fix the isolation tester compilation on VPATH builds 2011-02-10 19:31:39 -03:00
Heikki Linnakangas dafaa3efb7 Implement genuine serializable isolation level.
Until now, our Serializable mode has in fact been what's called Snapshot
Isolation, which allows some anomalies that could not occur in any
serialized ordering of the transactions. This patch fixes that using a
method called Serializable Snapshot Isolation, based on research papers by
Michael J. Cahill (see README-SSI for full references). In Serializable
Snapshot Isolation, transactions run like they do in Snapshot Isolation,
but a predicate lock manager observes the reads and writes performed and
aborts transactions if it detects that an anomaly might occur. This method
produces some false positives, ie. it sometimes aborts transactions even
though there is no anomaly.

To track reads we implement predicate locking, see storage/lmgr/predicate.c.
Whenever a tuple is read, a predicate lock is acquired on the tuple. Shared
memory is finite, so when a transaction takes many tuple-level locks on a
page, the locks are promoted to a single page-level lock, and further to a
single relation level lock if necessary. To lock key values with no matching
tuple, a sequential scan always takes a relation-level lock, and an index
scan acquires a page-level lock that covers the search key, whether or not
there are any matching keys at the moment.

A predicate lock doesn't conflict with any regular locks or with another
predicate locks in the normal sense. They're only used by the predicate lock
manager to detect the danger of anomalies. Only serializable transactions
participate in predicate locking, so there should be no extra overhead for
for other transactions.

Predicate locks can't be released at commit, but must be remembered until
all the transactions that overlapped with it have completed. That means that
we need to remember an unbounded amount of predicate locks, so we apply a
lossy but conservative method of tracking locks for committed transactions.
If we run short of shared memory, we overflow to a new "pg_serial" SLRU
pool.

We don't currently allow Serializable transactions in Hot Standby mode.
That would be hard, because even read-only transactions can cause anomalies
that wouldn't otherwise occur.

Serializable isolation mode now means the new fully serializable level.
Repeatable Read gives you the old Snapshot Isolation level that we have
always had.

Kevin Grittner and Dan Ports, reviewed by Jeff Davis, Heikki Linnakangas and
Anssi Kääriäinen
2011-02-08 00:09:08 +02:00