Re: Parallel tuplesort (for parallel B-Tree index creation)
Thomas Munro <thomas.munro@enterprisedb.com>
On Sat, Feb 11, 2017 at 1:52 AM, Robert Haas <robertmhaas@gmail.com> wrote: > On Thu, Feb 9, 2017 at 6:38 PM, Thomas Munro > <thomas.munro@enterprisedb.com> wrote: >> Yes, potentially unbounded in rare case. If we plan for N batches, >> and then run out of work_mem because our estimates were just wrong or >> the distributions of keys is sufficiently skewed, we'll run >> HashIncreaseNumBatches, and that could happen more than once. I have >> a suite of contrived test queries that hits all the various modes and >> code paths of hash join, and it includes a query that plans for one >> batch but finishes up creating many, and then the leader exits. I'll >> post that to the other thread along with my latest patch series soon. > > Hmm, OK. So that's going to probably require something where a fixed > amount of DSM can describe an arbitrary number of temp file series. > But that also means this is an even-more-special-purpose tool that > shouldn't be deeply tied into parallel.c so that it can run before any > errors happen. > > Basically, I think the "let's write the code between here and here so > it throws no errors" technique is, for 99% of PostgreSQL programming, > difficult and fragile. We shouldn't rely on it if there is some other > reasonable option. I'm testing a patch that lets you set up a fixed sized SharedBufFileSet object in a DSM segment, with its own refcount for the reason you explained. It supports a dynamically expandable set of numbered files, so each participant gets to export file 0, file 1, file 2 and so on as required, in any order. I think this should suit both Parallel Tuplesort which needs to export just one file from each participant, and Parallel Shared Hash which doesn't know up front how many batches it will produce. Not quite ready but I will post a version tomorrow to get Peter's reaction. -- Thomas Munro http://www.enterprisedb.com
Commits
-
Support parallel btree index builds.
- 9da0cc35284b 11.0 landed
-
Report an ERROR if a parallel worker fails to start properly.
- 2badb5afb89c 11.0 cited
-
Transfer state pertaining to pending REINDEX operations to workers.
- 29d58fd3adae 11.0 landed
-
Add a barrier primitive for synchronizing backends.
- 1145acc70deb 11.0 cited
-
Allow DML commands that create tables to use parallel query.
- e9baa5e9fa14 11.0 cited
-
Refactor GetOldestXmin() to use flags
- af4b1a0869bd 10.0 cited
-
Fix regression in parallel planning against inheritance tables.
- 2609e91fcf9d 10.0 cited
-
Don't create "holes" in BufFiles, in the new logtape code.
- 7ac4a389a7db 10.0 cited
-
Simplify the code for logical tape read buffers.
- b75f467b6eec 10.0 cited
-
Fix excessive memory consumption in the new sort pre-reading code.
- b56fb691b003 10.0 cited
-
Implement binary heap replace-top operation in a smarter way.
- 24598337c8d2 10.0 cited
-
Cosmetic code cleanup in commands/extension.c.
- 25794e841e5b 10.0 cited
-
Speed up planner's scanning for parallel-query hazards.
- da1c91631e35 10.0 cited
-
Read from the same worker repeatedly until it returns no tuple.
- bc7fcab5e36b 9.6.0 cited
-
Improve tuplesort.c to support variable merge order. The original coding
- df700e6b4019 8.2.0 cited