Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Rel 10 stable #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ee5572e
Expand coverage of parallel gather merge a bit.
anarazel Aug 14, 2017
2999063
Add missing call to ExecReScanGatherMerge.
robertmhaas Aug 15, 2017
17a2a27
Avoid unnecessary single-child Append nodes.
robertmhaas Aug 15, 2017
d7ab908
Distinguish wait-for-connection from wait-for-write-ready on Windows.
tglsfdc Aug 15, 2017
870da1e
Fix error handling path in autovacuum launcher
alvherre Aug 15, 2017
4e7cd03
doc: Improve PDF bookmarks
petere Aug 15, 2017
292d9b6
Simplify some code in logical replication launcher
petere Aug 15, 2017
0cafc26
doc: Add missing logical replication protocol message
petere Aug 15, 2017
edbad25
Fix logical replication protocol comparison logic
petere Aug 15, 2017
f2f9fcb
Simplify autovacuum work-item implementation
alvherre Aug 15, 2017
7502f39
psql: Add tab completion for \pset pager
petere Aug 15, 2017
3ea5821
Include foreign tables in information_schema.table_privileges
petere Aug 15, 2017
226be40
Initialize replication_slot_catalog_xmin in procarray
petere Aug 16, 2017
a6b174f
Allow continuation lines in ecpg cppline parsing.
Aug 15, 2017
2327690
doc: Add logical replication to comparison matrix
petere Aug 16, 2017
0c16efc
doc: Update URL of DocBook XSL stylesheets
petere Aug 16, 2017
e4892c6
pg_dump: Support using synchronized snapshots on standbys
petere Aug 16, 2017
28c5655
doc: Fix table column count
petere Aug 17, 2017
b469387
Remove bogus line from comment.
robertmhaas Aug 17, 2017
ca49d69
doc: Update RFC URLs
petere Aug 17, 2017
1d7a479
Further tweaks to compiler flags for PL/Perl on Windows.
tglsfdc Aug 17, 2017
de1ca69
Fix ExecReScanGatherMerge.
tglsfdc Aug 17, 2017
7c0ca29
Don't lock tables in RelationGetPartitionDispatchInfo.
robertmhaas Aug 17, 2017
9b64474
Temporarily revert test case from a2b70c89ca1a5fcf6181d3c777d82e7b83d…
tglsfdc Aug 17, 2017
d4b42e5
Fix interaction of triggers, partitioning, and EXPLAIN ANALYZE.
robertmhaas Aug 18, 2017
7c84acc
Fix creation of ICU comments for keyword variants
petere Aug 19, 2017
1c3869c
Fix possible core dump in parallel restore when using a TOC list.
tglsfdc Aug 19, 2017
b8a2549
Inject $(ICU_LIBS) regardless of platform.
nmisch Aug 21, 2017
a79fb8e
Expand set of predefined ICU locales
petere Aug 21, 2017
958ffb8
Don't install ICU collation keyword variants
petere Aug 21, 2017
d34a74d
Backpatch introduction of TupleDescAttr(tupdesc, i).
anarazel Aug 22, 2017
adce891
doc: Mention identity column feature in section on serial
petere Aug 22, 2017
2ac307b
pg_upgrade: Message translatability and style fixes
petere Aug 23, 2017
5e87f7b
Fix translation marker
petere Aug 23, 2017
8bf9469
Tweak some SCRAM error messages and code comments
petere Aug 23, 2017
da19c32
Fix outdated comment
petere Aug 23, 2017
d51b087
Update code comment for temporary replication slots
petere Aug 23, 2017
cf98e38
Increase SCRAM salt length
petere Aug 24, 2017
8a7beca
pg_upgrade: Remove dead code
petere Aug 24, 2017
51d0fa8
psql: Fix \gx when FETCH_COUNT is used
sfrost Aug 24, 2017
1563b8f
Fix harmless thinko in dsa.c.
anarazel Aug 24, 2017
9c57848
Message translatability fixes
petere Aug 25, 2017
33043c6
pg_upgrade: Remove more dead code
petere Aug 25, 2017
3460728
Improve low-level backup documentation.
robertmhaas Aug 25, 2017
145ca36
pg_test_timing: Some NLS fixes
petere Aug 26, 2017
5a62735
Doc: update v10 release notes through today.
tglsfdc Aug 26, 2017
947a0cc
Release notes for 9.6.5, 9.5.9, 9.4.14, 9.3.19, 9.2.23.
tglsfdc Aug 27, 2017
5ecd7cc
Clarify documentation
petere Aug 28, 2017
df44405
Fix over-aggressive sanity check in misc_sanity.sql.
tglsfdc Aug 28, 2017
89f6d58
Translation updates
petere Aug 28, 2017
7dadf7a
Doc: adjust release-note credit for parallel pg_restore fix.
tglsfdc Aug 28, 2017
2ff326d
Stamp 10beta4.
tglsfdc Aug 28, 2017
09ec0eb
Improve docs about numeric formatting patterns (to_char/to_number).
tglsfdc Aug 29, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't lock tables in RelationGetPartitionDispatchInfo.
Instead, lock them in the caller using find_all_inheritors so that
they get locked in the standard order, minimizing deadlock risks.

Also in RelationGetPartitionDispatchInfo, avoid opening tables which
are not partitioned; there's no need.

Amit Langote, reviewed by Ashutosh Bapat and Amit Khandekar

Discussion: http://postgr.es/m/[email protected]
  • Loading branch information
robertmhaas committed Aug 17, 2017
commit 7c0ca2900f7cae490fd551096cb7dc581cfe45c8
55 changes: 29 additions & 26 deletions src/backend/catalog/partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,12 +1000,16 @@ get_partition_qual_relid(Oid relid)
* RelationGetPartitionDispatchInfo
* Returns information necessary to route tuples down a partition tree
*
* All the partitions will be locked with lockmode, unless it is NoLock.
* A list of the OIDs of all the leaf partitions of rel is returned in
* *leaf_part_oids.
* The number of elements in the returned array (that is, the number of
* PartitionDispatch objects for the partitioned tables in the partition tree)
* is returned in *num_parted and a list of the OIDs of all the leaf
* partitions of rel is returned in *leaf_part_oids.
*
* All the relations in the partition tree (including 'rel') must have been
* locked (using at least the AccessShareLock) by the caller.
*/
PartitionDispatch *
RelationGetPartitionDispatchInfo(Relation rel, int lockmode,
RelationGetPartitionDispatchInfo(Relation rel,
int *num_parted, List **leaf_part_oids)
{
PartitionDispatchData **pd;
Expand All @@ -1020,14 +1024,18 @@ RelationGetPartitionDispatchInfo(Relation rel, int lockmode,
offset;

/*
* Lock partitions and make a list of the partitioned ones to prepare
* their PartitionDispatch objects below.
* We rely on the relcache to traverse the partition tree to build both
* the leaf partition OIDs list and the array of PartitionDispatch objects
* for the partitioned tables in the tree. That means every partitioned
* table in the tree must be locked, which is fine since we require the
* caller to lock all the partitions anyway.
*
* Cannot use find_all_inheritors() here, because then the order of OIDs
* in parted_rels list would be unknown, which does not help, because we
* assign indexes within individual PartitionDispatch in an order that is
* predetermined (determined by the order of OIDs in individual partition
* descriptors).
* For every partitioned table in the tree, starting with the root
* partitioned table, add its relcache entry to parted_rels, while also
* queuing its partitions (in the order in which they appear in the
* partition descriptor) to be looked at later in the same loop. This is
* a bit tricky but works because the foreach() macro doesn't fetch the
* next list element until the bottom of the loop.
*/
*num_parted = 1;
parted_rels = list_make1(rel);
Expand All @@ -1036,29 +1044,24 @@ RelationGetPartitionDispatchInfo(Relation rel, int lockmode,
APPEND_REL_PARTITION_OIDS(rel, all_parts, all_parents);
forboth(lc1, all_parts, lc2, all_parents)
{
Relation partrel = heap_open(lfirst_oid(lc1), lockmode);
Oid partrelid = lfirst_oid(lc1);
Relation parent = lfirst(lc2);
PartitionDesc partdesc = RelationGetPartitionDesc(partrel);

/*
* If this partition is a partitioned table, add its children to the
* end of the list, so that they are processed as well.
*/
if (partdesc)
if (get_rel_relkind(partrelid) == RELKIND_PARTITIONED_TABLE)
{
/*
* Already locked by the caller. Note that it is the
* responsibility of the caller to close the below relcache entry,
* once done using the information being collected here (for
* example, in ExecEndModifyTable).
*/
Relation partrel = heap_open(partrelid, NoLock);

(*num_parted)++;
parted_rels = lappend(parted_rels, partrel);
parted_rel_parents = lappend(parted_rel_parents, parent);
APPEND_REL_PARTITION_OIDS(partrel, all_parts, all_parents);
}
else
heap_close(partrel, NoLock);

/*
* We keep the partitioned ones open until we're done using the
* information being collected here (for example, see
* ExecEndModifyTable).
*/
}

/*
Expand Down
10 changes: 7 additions & 3 deletions src/backend/executor/execMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "access/xact.h"
#include "catalog/namespace.h"
#include "catalog/partition.h"
#include "catalog/pg_inherits_fn.h"
#include "catalog/pg_publication.h"
#include "commands/matview.h"
#include "commands/trigger.h"
Expand Down Expand Up @@ -3249,9 +3250,12 @@ ExecSetupPartitionTupleRouting(Relation rel,
int i;
ResultRelInfo *leaf_part_rri;

/* Get the tuple-routing information and lock partitions */
*pd = RelationGetPartitionDispatchInfo(rel, RowExclusiveLock, num_parted,
&leaf_parts);
/*
* Get the information about the partition tree after locking all the
* partitions.
*/
(void) find_all_inheritors(RelationGetRelid(rel), RowExclusiveLock, NULL);
*pd = RelationGetPartitionDispatchInfo(rel, num_parted, &leaf_parts);
*num_partitions = list_length(leaf_parts);
*partitions = (ResultRelInfo *) palloc(*num_partitions *
sizeof(ResultRelInfo));
Expand Down
3 changes: 1 addition & 2 deletions src/include/catalog/partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ extern Expr *get_partition_qual_relid(Oid relid);

/* For tuple routing */
extern PartitionDispatch *RelationGetPartitionDispatchInfo(Relation rel,
int lockmode, int *num_parted,
List **leaf_part_oids);
int *num_parted, List **leaf_part_oids);
extern void FormPartitionKeyDatum(PartitionDispatch pd,
TupleTableSlot *slot,
EState *estate,
Expand Down