postgresql/src/include/storage
Alvaro Herrera c98763bf51
Avoid spurious waits in concurrent indexing
In the various waiting phases of CREATE INDEX CONCURRENTLY (CIC) and
REINDEX CONCURRENTLY (RC), we wait for other processes to release their
snapshots; this is necessary in general for correctness.  However,
processes doing CIC in other tables cannot possibly affect CIC or RC
done in "this" table, so we don't need to wait for those.  This commit
adds a flag in MyProc->statusFlags to indicate that the current process
is doing CIC, so that other processes doing CIC or RC can ignore it when
waiting.

Note that this logic is only valid if the index does not access other
tables.  For simplicity we avoid setting the flag if the index has a
column that's an expression, or has a WHERE predicate.  (It is possible
to have expressional or partial indexes that do not access other tables,
but figuring that out would require more work.)

This flag can potentially also be used by processes doing REINDEX
CONCURRENTLY to be skipped; and by VACUUM to ignore processes in CIC or
RC for the purposes of computing an Xmin.  That's left for future
commits.

Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Author: Dimitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/20200810233815.GA18970@alvherre.pgsql
2020-11-25 18:22:57 -03:00
..
.gitignore When trace_lwlocks is used, identify individual lwlocks by name. 2015-09-11 14:01:39 -04:00
backendid.h code: replace 'master' with 'leader' where appropriate. 2020-07-08 12:58:32 -07:00
barrier.h Add BarrierArriveAndDetachExceptLast(). 2020-11-19 18:13:46 +13:00
block.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
buf.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
buf_internals.h C comment: correct use of 64-"byte" cache line size 2020-09-04 13:27:52 -04:00
buffile.h Extend the BufFile interface. 2020-08-26 07:36:43 +05:30
bufmgr.h Revert pg_relation_check_pages() 2020-11-04 10:21:46 +09:00
bufpage.h Extend PageIsVerified() to handle more custom options 2020-10-26 09:55:28 +09:00
checksum.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
checksum_impl.h Fix page-level checksum calculation in checksum_impl.h 2020-03-06 08:15:29 +09:00
condition_variable.h Clean up includes of s_lock.h. 2020-06-18 19:41:05 -07:00
copydir.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
dsm.h Preallocate some DSM space at startup. 2020-07-31 17:49:58 +12:00
dsm_impl.h Preallocate some DSM space at startup. 2020-07-31 17:49:58 +12:00
fd.h Extend the BufFile interface. 2020-08-26 07:36:43 +05:30
freespace.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
fsm_internals.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
indexfsm.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
ipc.h Don't run atexit callbacks during signal exits from ProcessStartupPacket. 2020-09-11 12:20:16 -04:00
item.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
itemid.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
itemptr.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
large_object.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
latch.h Use a long lived WaitEventSet for WaitLatch(). 2020-07-30 17:40:00 +12:00
lmgr.h Prevent concurrent SimpleLruTruncate() for any given SLRU. 2020-08-15 10:15:53 -07:00
lock.h Prevent concurrent SimpleLruTruncate() for any given SLRU. 2020-08-15 10:15:53 -07:00
lockdefs.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
lwlock.h Clean up includes of s_lock.h. 2020-06-18 19:41:05 -07:00
md.h Support PrefetchBuffer() in recovery. 2020-04-08 14:56:57 +12:00
off.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_sema.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_shmem.h Add huge_page_size setting for use on Linux. 2020-07-17 14:33:00 +12:00
pmsignal.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
predicate.h Rename SLRU structures and associated LWLocks. 2020-05-15 14:28:25 -04:00
predicate_internals.h Rename assorted LWLock tranches. 2020-05-15 18:11:07 -04:00
proc.h Avoid spurious waits in concurrent indexing 2020-11-25 18:22:57 -03:00
procarray.h snapshot scalability: Don't compute global horizons while building snapshots. 2020-08-12 16:03:49 -07:00
proclist.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
proclist_types.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
procsignal.h Avoid potential spinlock in a signal handler as part of global barriers. 2020-06-17 12:41:45 -07:00
reinit.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
relfilenode.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
s_lock.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
sharedfileset.h Extend the BufFile interface. 2020-08-26 07:36:43 +05:30
shm_mq.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
shm_toc.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
shmem.h Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
sinval.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
sinvaladt.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
smgr.h Cache smgrnblocks() results in recovery. 2020-07-31 14:29:52 +12:00
spin.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
standby.h Rename VariableCacheData.nextFullXid to nextXid. 2020-08-11 12:07:14 -07:00
standbydefs.h Rename VariableCacheData.nextFullXid to nextXid. 2020-08-11 12:07:14 -07:00
sync.h Defer flushing of SLRU files. 2020-09-25 19:00:15 +12:00