Thread: pgsql: Replace the former method of determining snapshot xmax --- to
pgsql: Replace the former method of determining snapshot xmax --- to
From
tgl@postgresql.org (Tom Lane)
Date:
Log Message: ----------- Replace the former method of determining snapshot xmax --- to wit, calling ReadNewTransactionId from GetSnapshotData --- with a "latestCompletedXid" variable that is updated during transaction commit or abort. Since latestCompletedXid is written only in places that had to lock ProcArrayLock exclusively anyway, and is read only in places that had to lock ProcArrayLock shared anyway, it adds no new locking requirements to the system despite being cluster-wide. Moreover, removing ReadNewTransactionId from snapshot acquisition eliminates the need to take both XidGenLock and ProcArrayLock at the same time. Since XidGenLock is sometimes held across I/O this can be a significant win. Some preliminary benchmarking suggested that this patch has no effect on average throughput but can significantly improve the worst-case transaction times seen in pgbench. Concept by Florian Pflug, implementation by Tom Lane. Modified Files: -------------- pgsql/src/backend/access/transam: README (r1.8 -> r1.9) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/README?r1=1.8&r2=1.9) transam.c (r1.70 -> r1.71) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/transam.c?r1=1.70&r2=1.71) twophase.c (r1.34 -> r1.35) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/twophase.c?r1=1.34&r2=1.35) varsup.c (r1.78 -> r1.79) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/varsup.c?r1=1.78&r2=1.79) xact.c (r1.249 -> r1.250) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/xact.c?r1=1.249&r2=1.250) xlog.c (r1.280 -> r1.281) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/xlog.c?r1=1.280&r2=1.281) pgsql/src/backend/catalog: heap.c (r1.322 -> r1.323) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/catalog/heap.c?r1=1.322&r2=1.323) pgsql/src/backend/commands: vacuum.c (r1.356 -> r1.357) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/vacuum.c?r1=1.356&r2=1.357) pgsql/src/backend/storage/ipc: procarray.c (r1.32 -> r1.33) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/storage/ipc/procarray.c?r1=1.32&r2=1.33) pgsql/src/backend/storage/lmgr: proc.c (r1.193 -> r1.194) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/storage/lmgr/proc.c?r1=1.193&r2=1.194) pgsql/src/backend/utils/time: tqual.c (r1.104 -> r1.105) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/time/tqual.c?r1=1.104&r2=1.105) pgsql/src/include/access: transam.h (r1.61 -> r1.62) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/access/transam.h?r1=1.61&r2=1.62) xact.h (r1.89 -> r1.90) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/access/xact.h?r1=1.89&r2=1.90) pgsql/src/include/storage: procarray.h (r1.16 -> r1.17) (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/storage/procarray.h?r1=1.16&r2=1.17)