mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Create an infrastructure for parallel computation in PostgreSQL.
This does four basic things. First, it provides convenience routines to coordinate the startup and shutdown of parallel workers. Second, it synchronizes various pieces of state (e.g. GUCs, combo CID mappings, transaction snapshot) from the parallel group leader to the worker processes. Third, it prohibits various operations that would result in unsafe changes to that state while parallelism is active. Finally, it propagates events that would result in an ErrorResponse, NoticeResponse, or NotifyResponse message being sent to the client from the parallel workers back to the master, from which they can then be sent on to the client. Robert Haas, Amit Kapila, Noah Misch, Rushabh Lathia, Jeevan Chalke. Suggestions and review from Andres Freund, Heikki Linnakangas, Noah Misch, Simon Riggs, Euler Taveira, and Jim Nasby.
This commit is contained in:
68
src/include/access/parallel.h
Normal file
68
src/include/access/parallel.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* parallel.h
|
||||
* Infrastructure for launching parallel workers
|
||||
*
|
||||
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/access/parallel.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef PARALLEL_H
|
||||
#define PARALLEL_H
|
||||
|
||||
#include "access/xlogdefs.h"
|
||||
#include "lib/ilist.h"
|
||||
#include "postmaster/bgworker.h"
|
||||
#include "storage/shm_mq.h"
|
||||
#include "storage/shm_toc.h"
|
||||
#include "utils/elog.h"
|
||||
|
||||
typedef void (*parallel_worker_main_type)(dsm_segment *seg, shm_toc *toc);
|
||||
|
||||
typedef struct ParallelWorkerInfo
|
||||
{
|
||||
BackgroundWorkerHandle *bgwhandle;
|
||||
shm_mq_handle *error_mqh;
|
||||
int32 pid;
|
||||
} ParallelWorkerInfo;
|
||||
|
||||
typedef struct ParallelContext
|
||||
{
|
||||
dlist_node node;
|
||||
SubTransactionId subid;
|
||||
int nworkers;
|
||||
parallel_worker_main_type entrypoint;
|
||||
char *library_name;
|
||||
char *function_name;
|
||||
ErrorContextCallback *error_context_stack;
|
||||
shm_toc_estimator estimator;
|
||||
dsm_segment *seg;
|
||||
void *private;
|
||||
shm_toc *toc;
|
||||
ParallelWorkerInfo *worker;
|
||||
} ParallelContext;
|
||||
|
||||
extern bool ParallelMessagePending;
|
||||
extern int ParallelWorkerNumber;
|
||||
|
||||
#define IsParallelWorker() (ParallelWorkerNumber >= 0)
|
||||
|
||||
extern ParallelContext *CreateParallelContext(parallel_worker_main_type entrypoint, int nworkers);
|
||||
extern ParallelContext *CreateParallelContextForExternalFunction(char *library_name, char *function_name, int nworkers);
|
||||
extern void InitializeParallelDSM(ParallelContext *);
|
||||
extern void LaunchParallelWorkers(ParallelContext *);
|
||||
extern void WaitForParallelWorkersToFinish(ParallelContext *);
|
||||
extern void DestroyParallelContext(ParallelContext *);
|
||||
extern bool ParallelContextActive(void);
|
||||
|
||||
extern void HandleParallelMessageInterrupt(void);
|
||||
extern void HandleParallelMessages(void);
|
||||
extern void AtEOXact_Parallel(bool isCommit);
|
||||
extern void AtEOSubXact_Parallel(bool isCommit, SubTransactionId mySubId);
|
||||
extern void ParallelWorkerReportLastRecEnd(XLogRecPtr);
|
||||
|
||||
#endif /* PARALLEL_H */
|
Reference in New Issue
Block a user