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

Commit19c90bc

Browse files
committed
Add a bit more locking to vac_update_relstats and vac_update_dbstats
to make them comparable to what UpdateStats does in the same situation.I'm not certain two instances of vac_update_relstats could run inparallel for the same relation, but parallel invocations of vac_update_dbstatsdo seem possible.
1 parentbea8af9 commit19c90bc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎src/backend/commands/vacuum.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.262 2003/09/29 00:05:25 petere Exp $
16+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.263 2003/10/02 23:19:44 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -520,6 +520,9 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples,
520520
elog(ERROR,"pg_class entry for relid %u vanished during vacuuming",
521521
relid);
522522

523+
/* ensure no one else does this at the same time */
524+
LockBuffer(buffer,BUFFER_LOCK_EXCLUSIVE);
525+
523526
/* overwrite the existing statistics in the tuple */
524527
pgcform= (Form_pg_class)GETSTRUCT(&rtup);
525528
pgcform->relpages= (int32)num_pages;
@@ -533,6 +536,8 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples,
533536
if (!hasindex)
534537
pgcform->relhaspkey= false;
535538

539+
LockBuffer(buffer,BUFFER_LOCK_UNLOCK);
540+
536541
/*
537542
* Invalidate the tuple in the catcaches; this also arranges to flush
538543
* the relation's relcache entry. (If we fail to commit for some
@@ -588,12 +593,17 @@ vac_update_dbstats(Oid dbid,
588593
if (!HeapTupleIsValid(tuple))
589594
elog(ERROR,"could not find tuple for database %u",dbid);
590595

596+
/* ensure no one else does this at the same time */
597+
LockBuffer(scan->rs_cbuf,BUFFER_LOCK_EXCLUSIVE);
598+
591599
dbform= (Form_pg_database)GETSTRUCT(tuple);
592600

593601
/* overwrite the existing statistics in the tuple */
594602
dbform->datvacuumxid=vacuumXID;
595603
dbform->datfrozenxid=frozenXID;
596604

605+
LockBuffer(scan->rs_cbuf,BUFFER_LOCK_UNLOCK);
606+
597607
/* invalidate the tuple in the cache and write the buffer */
598608
CacheInvalidateHeapTuple(relation,tuple);
599609
WriteNoReleaseBuffer(scan->rs_cbuf);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp