README.md 17.8 KB
Newer Older
R
Roman Shaposhnik 已提交
1 2 3
## Travis [![Travis Build Status](https://travis-ci.org/greenplum-db/gpdb.svg?branch=master)](https://travis-ci.org/greenplum-db/gpdb)

## Concourse [![Concourse Build Status](https://gpdb.ci.pivotalci.info/api/v1/teams/gpdb/pipelines/gpdb_master/jobs/gpdb_rc_packaging_centos/badge)](https://gpdb.ci.pivotalci.info/teams/gpdb)
4 5 6

----------------------------------------------------------------------

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
![Greenplum](/gpAux/releng/images/logo-greenplum.png)

The Greenplum Database (GPDB) is an advanced, fully featured, open
source data warehouse. It provides powerful and rapid analytics on
petabyte scale data volumes. Uniquely geared toward big data
analytics, Greenplum Database is powered by the world’s most advanced
cost-based query optimizer delivering high analytical query
performance on large data volumes.

The Greenplum project is released under the [Apache 2
license](http://www.apache.org/licenses/LICENSE-2.0). We want to thank
all our current community contributors and are really interested in
all new potential contributions. For the Greenplum Database community
no contribution is too small, we encourage all types of contributions.

## Overview

A Greenplum cluster consists of a __master__ server, and multiple
__segment__ servers. All user data resides in the segments, the master
contains only metadata. The master server, and all the segments, share
the same schema.

Users always connect to the master server, which divides up the query
into fragments that are executed in the segments, sends the fragments
to the segments, and collects the results.

## Requirements

* **gpMgmt** utilities - command line tools for managing the cluster.

  You will need to add the following Python modules (2.7 & 2.6 are
  supported) into your installation

40
  * psutil
41
  * lockfile (>= 0.9.1)
42 43 44 45
  * paramiko
  * setuptools
  * epydoc

46 47 48
  If necessary, upgrade modules using "pip install --upgrade".
  pip should be at least version 7.x.x.

49

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
## Code layout

The directory layout of the repository follows the same general layout
as upstream PostgreSQL. There are changes compared to PostgreSQL
throughout the codebase, but a few larger additions worth noting:

* __gpMgmt/__

  Contains Greenplum-specific command-line tools for managing the
  cluster. Scripts like gpinit, gpstart, gpstop live here. They are
  mostly written in Python.

* __gpAux/__

  Contains Greenplum-specific extensions such as gpfdist and
  gpmapreduce.  Some additional directories are submodules and will be
  made available over time.

* __doc/__

  In PostgreSQL, the user manual lives here. In Greenplum, the user
71 72 73 74 75 76 77 78
  manual is maintained separately and only the reference pages used
  to build man pages are here.

* __gpdb-doc/__

  Constains the Greenplum documentation in DITA XML format. Refer to
  `gpdb-doc/README.md` for information on how to build, and work with
  the documentation.
79

80 81 82 83
* __ci/__

  Contains configuration files for the GPDB continuous integration system.

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
* __src/backend/cdb/__

  Contains larger Greenplum-specific backend modules. For example,
  communication between segments, turning plans into parallelizable
  plans, mirroring, distributed transaction and snapshot management,
  etc. __cdb__ stands for __Cluster Database__ - it was a workname used in
  the early days. That name is no longer used, but the __cdb__ prefix
  remains.

* __src/backend/gpopt/__

  Contains the so-called __translator__ library, for using the ORCA
  optimizer with Greenplum. The translator library is written in C++
  code, and contains glue code for translating plans and queries
  between the DXL format used by ORCA, and the PostgreSQL internal
  representation. This goes unused, unless building with
  _--enable-orca_.

* __src/backend/gp_libpq_fe/__

  A slightly modified copy of libpq. The master node uses this to
  connect to segments, and to send fragments of a query plan to
  segments for execution. It is linked directly into the backend, it
  is not a shared library like libpq.

* __src/backend/fts/__

  FTS is a process that runs in the master node, and periodically
  polls the segments to maintain the status of each segment.

114 115 116 117 118 119
## Building GPDB

Some configure options are nominally optional, but required to pass
all regression tests. The minimum set of options for running the
regression tests successfully is:

120
`./configure --with-perl --with-python --with-libxml --enable-mapreduce`
121 122

### Build GPDB with Planner
123 124

```
X
Xin Zhang 已提交
125 126 127
# Clean environment
make distclean

X
Xin Zhang 已提交
128
# Configure build environment to install at /usr/local/gpdb
129
./configure --with-perl --with-python --with-libxml --enable-mapreduce --prefix=/usr/local/gpdb
130

X
Xin Zhang 已提交
131
# Compile and install
132 133 134
make
make install

X
Xin Zhang 已提交
135 136
# Bring in greenplum environment into your running shell
source /usr/local/gpdb/greenplum_path.sh
137

X
Xin Zhang 已提交
138 139
# Start demo cluster (gpdemo-env.sh is created which contain
# __PGPORT__ and __MASTER_DATA_DIRECTORY__ values)
140 141 142 143 144
cd gpAux/gpdemo
make cluster
source gpdemo-env.sh
```

145 146 147 148 149 150 151 152
Compilation can be sped up with parallelization. Instead of `make`, consider:

```
make -j8
```

The directory and the TCP ports for the demo cluster can be changed on the fly.
Instead of `make cluster`, consider:
153 154 155 156 157 158 159 160 161 162 163 164

```
DATADIRS=/tmp/gpdb-cluster MASTER_PORT=15432 PORT_BASE=25432 make cluster
```

The TCP port for the regression test can be changed on the fly:

```
PGPORT=15432 make installcheck-good
```


165
### Build GPDB with GPORCA
166
You must first install the below libraries in the below order (see the READMEs on each repository):
X
Xin Zhang 已提交
167

168
1. https://github.com/greenplum-db/gp-xerces
169
2. https://github.com/greenplum-db/gporca
170 171

Next, change your `configure` command to have the additional option `--enable-orca`.
X
Xin Zhang 已提交
172 173
```
# Configure build environment to install at /usr/local/gpdb
X
Xin Zhang 已提交
174
# Enable GPORCA
175 176 177
# Build with perl module (PL/Perl)
# Build with python module (PL/Python)
# Build with XML support
D
Dhanashree Kashid 已提交
178
./configure --with-perl --with-python --with-libxml --enable-mapreduce --enable-orca --prefix=/usr/local/gpdb
X
Xin Zhang 已提交
179 180
```

X
Xin Zhang 已提交
181 182 183 184 185 186
Once build and started, run `psql` and check the GPOPT (e.g. GPORCA) version:

```
select gp_opt_version();
```

187
### Build GPDB with code generation enabled
188 189 190 191 192 193 194 195 196 197 198 199

To build GPDB with code generation (codegen) enabled, you will need cmake 2.8 or higher
and a recent version of llvm and clang (include headers and developer libraries). Codegen utils
is currently developed against the LLVM 3.7.X release series. You can find more details about the codegen feature,
including details about obtaining the prerequisites, building and testing GPDB with codegen in the [Codegen README](src/backend/codegen).

In short, you can change the `configure` with additional option
`--enable-codegen`, optionally giving the path to llvm and clang libraries on
your system.
```
# Configure build environment to install at /usr/local/gpdb
# Enable CODEGEN
200
./configure --with-perl --with-python --with-libxml ---enable-mapreduce --enable-codegen --prefix=/usr/local/gpdb --with-codegen-prefix="/path/to/llvm;/path/to/clang"
201 202
```

X
Xin Zhang 已提交
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
## Regression tests

* The default regression tests

```
make installcheck-good
```

* The PostgreSQL __check__ target does not work. Setting up a
  Greenplum cluster is more complicated than a single-node PostgreSQL
  installation, and no-one's done the work to have __make check__
  create a cluster. Create a cluster manually or use gpAux/gpdemo/
  (example below) and run __make installcheck-good__ against
  that. Patches are welcome!

* The PostgreSQL __installcheck__ target does not work either, because
  some tests are known to fail with Greenplum. The
  __installcheck-good__ schedule excludes those tests.

222 223 224 225 226
* When adding a new test, please add it to one of the GPDB-specific tests,
  in greenplum_schedule, rather than the PostgreSQL tests inherited from the
  upstream. We try to keep the upstream tests identical to the upstream
  versions, to make merging with newer PostgreSQL releases easier.

227
## Development with Docker
228 229

We provide a docker image with all dependencies required to compile and test
230
GPDB. You can view the dependency dockerfile at `./src/tools/docker/base/Dockerfile`.
231 232 233
The image is hosted on docker hub at `pivotaldata/gpdb-devel`. This docker
image is currently under heavy development.

234 235
A quickstart guide to Docker can be found on the [Pivotal Engineering Journal](http://engineering.pivotal.io/post/docker-gpdb/).

236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
Known issues:
* The `installcheck-good` make target has at least 4 failures, some of which
  are non-deterministic

### Running regression tests with Docker

1. Create a docker host with 8gb RAM and 4 cores
    ```bash
    docker-machine create -d virtualbox --virtualbox-cpu-count 4 --virtualbox-disk-size 50000 --virtualbox-memory 8192 gpdb
    eval $(docker-machine env gpdb)
    ```

1. Build your code on gpdb-devel rootfs
    ```bash
    cd [path/to/gpdb]
    docker build .
    # image beefc4f3 built
    ```
    The top level Dockerfile will automatically sync your current working
    directory into the docker image. This means that any code you are working
    on will automatically be built and ready for testing in the docker context

1. Log into docker image
    ```bash
    docker run -it beefc4f3
    ```

1. As `gpadmin` user run `installcheck-good`
    ```bash
    su gpadmin
    cd /workspace/gpdb
    make installcheck-good
    ```

### Caveats

* No Space Left On Device
    On macOS the docker-machine vm can periodically become full with unused images.
    You can clear these images with a combination of docker commands.
    ```bash
    # assuming no currently running containers
    # remove all stopped containers from cache
    docker ps -aq | xargs -n 1 docker rm
    # remove all untagged images
    docker images -aq --filter dangling=true | xargs -n 1 docker rmi
    ```

283 284
* The Native macOS docker client available with docker 1.12+ (beta) or
  Community Edition 17+ may also work
285

286 287
## Contributing

288 289
Greenplum is maintained by a core team of developers with commit rights to the
[main gpdb repository](https://github.com/greenplum-db/gpdb) on GitHub. At the
290 291
same time, we are very eager to receive contributions from anybody in the wider
Greenplum community. This section covers all you need to know if you want to see
R
Roman Shaposhnik 已提交
292 293
your code or documentation changes be added to Greenplum and appear in the
future releases.
294 295 296

### Getting started

297
Greenplum is developed on GitHub, and anybody wishing to contribute to it will
298 299
have to [have a GitHub account](https://github.com/signup/free) and be familiar
with [Git tools and workflow](https://wiki.postgresql.org/wiki/Working_with_Git). 
300
It is also recommend that you follow the [developer's mailing list](http://greenplum.org/#contribute)
301 302 303
since some of the contributions may generate more detailed discussions there.

Once you have your GitHub account, [fork](https://github.com/greenplum-db/gpdb/fork)
304 305 306 307 308 309 310 311
repository so that you can have your private copy to start hacking on and to
use as source of pull requests.

Anybody contributing to Greenplum has to be covered by either the Corporate or
the Individual Contributor License Agreement. If you have not previously done
so, please fill out and submit the [Contributor License Agreement](https://cla.pivotal.io/sign/greenplum).
Note that we do allow for really trivial changes to be contributed without a
CLA if they fall under the rubric of [obvious fixes](https://cla.pivotal.io/about#obvious-fixes).
312 313 314 315 316 317 318
However, since our GitHub workflow checks for CLA by default you may find it
easier to submit one instead of claiming an "obvious fix" exception.

### Coding guidelines

Your chances of getting feedback and seeing your code merged into the project
greatly depend on how granular your changes are. If you happen to have a bigger
319
change in mind, we highly recommend engaging on the developer's mailing list
320 321 322
first and sharing your proposal with us before you spend a lot of time writing
code. Even when your proposal gets validated by the community, we still recommend
doing the actual work as a series of small, self-contained commits. This makes
323
the reviewer's job much easier and increases the timeliness of feedback.
324 325 326 327 328 329 330 331 332 333 334

When it comes to C and C++ parts of Greenplum, we try to follow 
[PostgreSQL Coding Conventions](https://www.postgresql.org/docs/devel/static/source.html).
In addition to that we require that:
   * All Python code passes [Pylint](https://www.pylint.org/)
   * All Go code is formatted according to [gofmt](https://golang.org/cmd/gofmt/)

We recommend using ```git diff --color``` when reviewing your changes so that you
don't have any spurious whitespace issues in the code that you submit.

All new functionality that is contributed to Greenplum should be covered by regression
R
Roman Shaposhnik 已提交
335 336 337
tests that are contributed alongside it. If you are uncertain on how to test, or document 
your work, please raise the question on the gpdb-dev mailinglist and the developer 
community will do its best to help you.
338 339 340 341

### Testing guidelines

At the very minimum you should always be running 
342
```make installcheck-world```
343 344 345 346 347
to make sure that you're not breaking anything.

### Changes applicable to upstream PostgreSQL

If the change you're working on touches functionality that is common between PostgreSQL
348
and Greenplum, you may be asked to forward-port it to PostgreSQL. This is not only so
349 350
that we keep reducing the delta between the two projects, but also so that any change
that is relevant to PostgreSQL can benefit from a much broader review of the upstream
351 352
PostgreSQL community. In general, it is a good idea to keep both code bases handy so
you can be sure whether your changes may need to be forward-ported.
353 354 355 356

### Submission timing

To improve the odds of the right discussion of your patch or idea happening, pay attention 
357
to what the community work cycle is. For example, if you send in a brand new idea in the 
358
beta phase, don't be surprised if no one is paying attention because we are focused on 
359 360 361 362 363 364 365
release work. Come back when the beta is done, please!

You can read more on Greenplum release policy and timing in the RELEASE.md

### Patch submission

Once you are ready to share your work with the Greenplum core team and the rest of
366
the Greenplum community, you should push all the commits to a branch in your own 
367 368
repository forked from the official Greenplum and [send us a pull request](https://help.github.com/articles/about-pull-requests/).

369
For now, we require all pull requests to be submitted against the main master
370
branch, but over time, once there are many supported open source releases of Greenplum
371
in the wild, you may decide to submit your pull requests against an active
372 373 374 375
release branch if the change is only applicable to a given release.

### Validation checks and CI

376 377 378 379 380 381
Once you submit your pull request, you will immediately see a number of validation
checks performed by our automated CI pipelines. There also will be a CLA check
telling you whether your CLA was recognized. If any of these checks fails, you
will need to update your pull request to take care of the issue. Pull requests
with failed validation checks are very unlikely to receive any further peer
review from the community members.
382 383 384 385 386

Keep in mind that the most common reason for a failed CLA check is a mismatch
between an email on file and an email recorded in the commits submitted as
part of the pull request.

387
If you can not figure out why a certain validation check failed, feel free to
388 389 390 391 392 393 394 395
ask on the developer's mailing list, but make sure to include a direct link
to a pull request in your email.

### Patch review

A submitted pull request with passing validation checks is assumed to be available 
for peer review. Peer review is the process that ensures that contributions to Greenplum 
are of high quality and align well with the road map and community expectations. Every
396 397
member of the Greenplum community is encouraged to review pull requests and provide
feedback. Since you don't have to be a core team member to be able to do that, we
398
recommend following a stream of pull reviews to anybody who's interested in becoming
399
a long-term contributor to Greenplum. As [Linus would say](https://en.wikipedia.org/wiki/Linus's_Law) 
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
"given enough eyeballs, all bugs are shallow".

One outcome of the peer review could be a consensus that you need to modify your
pull request in certain ways. GitHub allows you to push additional commits into
a branch from which a pull request was sent. Those additional commits will be then
visible to all of the reviewers.

A peer review converges when it receives at least one +1 and no -1s votes from
the participants. At that point you should expect one of the core team 
members to pull your changes into the project.

Greenplum prides itself on being a collaborative, consensus-driven environment. 
We do not believe in vetoes and any -1 vote casted as part of the peer review 
has to have a detailed technical explanation of what's wrong with the change.
Should a strong disagreement arise it may be advisable to take the matter onto
the mailing list since it allows for a more natural flow of the conversation.

417 418 419 420 421
At any time during the patch review, you may experience delays based on the
availability of reviewers and core team members. Please be patient. That being
said, don't get discouraged either. If you're not getting expected feedback for
a few days add a comment asking for updates on the pull request itself or send
an email to the mailing list.
422 423 424 425 426 427

### Direct commits to the repository

On occasion you will see core team members committing directly to the repository
without going through the pull request workflow. This is reserved for small changes
only and the rule of thumb we use is this: if the change touches any functionality
428
that may result in a test failure, then it has to go through a pull request workflow.
429 430 431
If, on the other hand, the change is in the non-functional part of the code base
(such as fixing a typo inside of a comment block) core team members can decide to
just commit to the repository directly.
432

433 434 435 436 437 438 439 440 441 442 443 444 445
## Glossary

* __QD__

  Query Dispatcher. A synonym for the master server.

* __QE__

  Query Executor. A synonym for a segment server.

## Documentation

For Greenplum Database documentation, please check online docs:
446
http://greenplum.org/docs/
J
Jignesh Patel 已提交
447

448
There is also a Vagrant-based quickstart guide for developers in `src/tools/vagrant/README.md`.