Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit024c521

Browse files
committed
Replace BackendIds with 0-based ProcNumbers
Now that BackendId was just another index into the proc array, it wasredundant with the 0-based proc numbers used in other places. Replaceall usage of backend IDs with proc numbers.The only place where the term "backend id" remains is in a few pgstatfunctions that expose backend IDs at the SQL level. Those IDs are nowin fact 0-based ProcNumbers too, but the documentation still callsthem "backend ids". That term still seems appropriate to describe whatthe numbers are, so I let it be.One user-visible effect is that pg_temp_0 is now a valid temp schemaname, for backend with ProcNumber 0.Reviewed-by: Andres FreundDiscussion:https://www.postgresql.org/message-id/8171f1aa-496f-46a6-afc3-c46fe7a9b407@iki.fi
1 parentab355e3 commit024c521

File tree

71 files changed

+571
-579
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+571
-579
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7495,7 +7495,7 @@ local0.* /var/log/postgresql
74957495
</row>
74967496
<row>
74977497
<entry><literal>%v</literal></entry>
7498-
<entry>Virtual transaction ID (backendID/localXID); see
7498+
<entry>Virtual transaction ID (procNumber/localXID); see
74997499
<xref linkend="transaction-id"/></entry>
75007500
<entry>no</entry>
75017501
</row>

‎doc/src/sgml/monitoring.sgml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4940,7 +4940,7 @@ description | Waiting for a newly initialized WAL file to reach durable storage
49404940
access functions can be used; these are shown in <xref
49414941
linkend="monitoring-stats-backend-funcs-table"/>.
49424942
These access functions use the session's backend ID number, which is a
4943-
smallpositiveinteger that is distinct from the backend ID of any
4943+
small integer (>= 0) that is distinct from the backend ID of any
49444944
concurrent session, although a session's ID can be recycled as soon as
49454945
it exits. The backend ID is used, among other things, to identify the
49464946
session's temporary schema if it has one.
@@ -6813,7 +6813,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
68136813
arg0 contains the fork to be extended. arg1, arg2, and arg3 contain the
68146814
tablespace, database, and relation OIDs identifying the relation. arg4
68156815
is the ID of the backend which created the temporary relation for a
6816-
local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared
6816+
local buffer, or <symbol>INVALID_PROC_NUMBER</symbol> (-1) for a shared
68176817
buffer. arg5 is the number of blocks the caller would like to extend
68186818
by.</entry>
68196819
</row>
@@ -6824,7 +6824,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
68246824
arg0 contains the fork to be extended. arg1, arg2, and arg3 contain the
68256825
tablespace, database, and relation OIDs identifying the relation. arg4
68266826
is the ID of the backend which created the temporary relation for a
6827-
local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared
6827+
local buffer, or <symbol>INVALID_PROC_NUMBER</symbol> (-1) for a shared
68286828
buffer. arg5 is the number of blocks the relation was extended by, this
68296829
can be less than the number in the
68306830
<literal>buffer-extend-start</literal> due to resource
@@ -6839,7 +6839,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
68396839
arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
68406840
identifying the relation.
68416841
arg5 is the ID of the backend which created the temporary relation for a
6842-
local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.
6842+
local buffer, or <symbol>INVALID_PROC_NUMBER</symbol> (-1) for a shared buffer.
68436843
</entry>
68446844
</row>
68456845
<row>
@@ -6850,7 +6850,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
68506850
arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
68516851
identifying the relation.
68526852
arg5 is the ID of the backend which created the temporary relation for a
6853-
local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.
6853+
local buffer, or <symbol>INVALID_PROC_NUMBER</symbol> (-1) for a shared buffer.
68546854
arg6 is true if the buffer was found in the pool, false if not.</entry>
68556855
</row>
68566856
<row>
@@ -6903,7 +6903,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
69036903
arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
69046904
identifying the relation.
69056905
arg5 is the ID of the backend which created the temporary relation for a
6906-
local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.</entry>
6906+
local buffer, or <symbol>INVALID_PROC_NUMBER</symbol> (-1) for a shared buffer.</entry>
69076907
</row>
69086908
<row>
69096909
<entry><literal>smgr-md-read-done</literal></entry>
@@ -6913,7 +6913,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
69136913
arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
69146914
identifying the relation.
69156915
arg5 is the ID of the backend which created the temporary relation for a
6916-
local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.
6916+
local buffer, or <symbol>INVALID_PROC_NUMBER</symbol> (-1) for a shared buffer.
69176917
arg6 is the number of bytes actually read, while arg7 is the number
69186918
requested (if these are different it indicates a short read).</entry>
69196919
</row>
@@ -6925,7 +6925,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
69256925
arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
69266926
identifying the relation.
69276927
arg5 is the ID of the backend which created the temporary relation for a
6928-
local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.</entry>
6928+
local buffer, or <symbol>INVALID_PROC_NUMBER</symbol> (-1) for a shared buffer.</entry>
69296929
</row>
69306930
<row>
69316931
<entry><literal>smgr-md-write-done</literal></entry>
@@ -6935,7 +6935,7 @@ FROM pg_stat_get_backend_idset() AS backendid;
69356935
arg2, arg3, and arg4 contain the tablespace, database, and relation OIDs
69366936
identifying the relation.
69376937
arg5 is the ID of the backend which created the temporary relation for a
6938-
local buffer, or <symbol>InvalidBackendId</symbol> (-1) for a shared buffer.
6938+
local buffer, or <symbol>INVALID_PROC_NUMBER</symbol> (-1) for a shared buffer.
69396939
arg6 is the number of bytes actually written, while arg7 is the number
69406940
requested (if these are different it indicates a short write).</entry>
69416941
</row>

‎doc/src/sgml/storage.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ these files are named after the table or index's <firstterm>filenode</firstterm>
202202
which can be found in <structname>pg_class</structname>.<structfield>relfilenode</structfield>. But
203203
for temporary relations, the file name is of the form
204204
<literal>t<replaceable>BBB</replaceable>_<replaceable>FFF</replaceable></literal>, where <replaceable>BBB</replaceable>
205-
is thebackend ID of the backend which created the file, and <replaceable>FFF</replaceable>
205+
is theprocess number of the backend which created the file, and <replaceable>FFF</replaceable>
206206
is the filenode number. In either case, in addition to the main file (a/k/a
207207
main fork), each table and index has a <firstterm>free space map</firstterm> (see <xref
208208
linkend="storage-fsm"/>), which stores information about free space available in

‎doc/src/sgml/xact.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
Every transaction is identified by a unique
2727
<literal>VirtualTransactionId</literal> (also called
2828
<literal>virtualXID</literal> or <literal>vxid</literal>), which
29-
is comprised of a backend ID(or <literal>backendID</literal>)
29+
is comprised of a backend's process number(or <literal>procNumber</literal>)
3030
and a sequentially-assigned number local to each backend, known as
3131
<literal>localXID</literal>. For example, the virtual transaction
32-
ID <literal>4/12532</literal> has a <literal>backendID</literal>
32+
ID <literal>4/12532</literal> has a <literal>procNumber</literal>
3333
of <literal>4</literal> and a <literal>localXID</literal> of
3434
<literal>12532</literal>.
3535
</para>

‎src/backend/access/transam/README

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ pg_subtrans and PGPROC are done at the time it is assigned.
203203
A transaction that has no XID still needs to be identified for various
204204
purposes, notably holding locks. For this purpose we assign a "virtual
205205
transaction ID" or VXID to each top-level transaction. VXIDs are formed from
206-
two fields, thebackendID and a backend-local counter; this arrangement allows
207-
assignment of a new VXID at transaction start without any contention for
208-
shared memory. To ensure that a VXID isn't re-used too soon after backend
206+
two fields, theprocNumber and a backend-local counter; this arrangement
207+
allowsassignment of a new VXID at transaction start without any contention
208+
forshared memory. To ensure that a VXID isn't re-used too soon after backend
209209
exit, we store the last local counter value into shared memory at backend
210-
exit, and initialize it from the previous value for the samebackendID slot
211-
atbackend start. All these counters go back to zero at shared memory
210+
exit, and initialize it from the previous value for the samePGPROC slot at
211+
backend start. All these counters go back to zero at shared memory
212212
re-initialization, but that's OK because VXIDs never appear anywhere on-disk.
213213

214214
Internally, a backend needs a way to identify subtransactions whether or not

‎src/backend/access/transam/clog.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -501,15 +501,15 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
501501
* still work, just less efficiently -- we handle this case by
502502
* switching to a different bank lock in the loop below.
503503
*/
504-
if (nextidx!=INVALID_PGPROCNO&&
504+
if (nextidx!=INVALID_PROC_NUMBER&&
505505
GetPGProcByNumber(nextidx)->clogGroupMemberPage!=proc->clogGroupMemberPage)
506506
{
507507
/*
508508
* Ensure that this proc is not a member of any clog group that
509509
* needs an XID status update.
510510
*/
511511
proc->clogGroupMember= false;
512-
pg_atomic_write_u32(&proc->clogGroupNext,INVALID_PGPROCNO);
512+
pg_atomic_write_u32(&proc->clogGroupNext,INVALID_PROC_NUMBER);
513513
return false;
514514
}
515515

@@ -525,9 +525,9 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
525525
* If the list was not empty, the leader will update the status of our
526526
* XID. It is impossible to have followers without a leader because the
527527
* first process that has added itself to the list will always have
528-
* nextidx asINVALID_PGPROCNO.
528+
* nextidx asINVALID_PROC_NUMBER.
529529
*/
530-
if (nextidx!=INVALID_PGPROCNO)
530+
if (nextidx!=INVALID_PROC_NUMBER)
531531
{
532532
intextraWaits=0;
533533

@@ -543,7 +543,7 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
543543
}
544544
pgstat_report_wait_end();
545545

546-
Assert(pg_atomic_read_u32(&proc->clogGroupNext)==INVALID_PGPROCNO);
546+
Assert(pg_atomic_read_u32(&proc->clogGroupNext)==INVALID_PROC_NUMBER);
547547

548548
/* Fix semaphore count for any absorbed wakeups */
549549
while (extraWaits-->0)
@@ -568,13 +568,13 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
568568
* group.
569569
*/
570570
nextidx=pg_atomic_exchange_u32(&procglobal->clogGroupFirst,
571-
INVALID_PGPROCNO);
571+
INVALID_PROC_NUMBER);
572572

573573
/* Remember head of list so we can perform wakeups after dropping lock. */
574574
wakeidx=nextidx;
575575

576576
/* Walk the list and update the status of all XIDs. */
577-
while (nextidx!=INVALID_PGPROCNO)
577+
while (nextidx!=INVALID_PROC_NUMBER)
578578
{
579579
PGPROC*nextproc=&ProcGlobal->allProcs[nextidx];
580580
intthispageno=nextproc->clogGroupMemberPage;
@@ -633,12 +633,12 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
633633
* clogGroupNext to invalid while saving the semaphores to an array, then
634634
* a single write barrier, then another pass unlocking the semaphores.)
635635
*/
636-
while (wakeidx!=INVALID_PGPROCNO)
636+
while (wakeidx!=INVALID_PROC_NUMBER)
637637
{
638638
PGPROC*wakeproc=&ProcGlobal->allProcs[wakeidx];
639639

640640
wakeidx=pg_atomic_read_u32(&wakeproc->clogGroupNext);
641-
pg_atomic_write_u32(&wakeproc->clogGroupNext,INVALID_PGPROCNO);
641+
pg_atomic_write_u32(&wakeproc->clogGroupNext,INVALID_PROC_NUMBER);
642642

643643
/* ensure all previous writes are visible before follower continues. */
644644
pg_write_barrier();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp