CONTRIBUTING.md 9.8 KB
Newer Older
1
# Contributing to QuestDB
2

3 4
Hi, glad to know that you're interested in contributing to QuestDB. Here are
some topics that can help you to get started:
5

6 7 8 9 10
- 💡 [Bugs and features](#bugs-and-features)
- 🧭 [Navigation](#navigation)
- 🔧 [Environment setup](#environment-setup)
-[Before you submit](#before-you-submit)
- 📢 [For maintainers](#for-maintainers)
11

12
# Bugs and features
13

14 15 16
Whether it's a bug report or feature request, you're welcome to raise an
**[issue](https://github.com/questdb/questdb/issues)** using the respective
template.
17

18 19 20 21
If you're not sure whether you should raise an issue, you can also join our
community **[Slack channel](https://slack.questdb.io/)** and post your questions
there.

22 23
If you find any **security bug**, kindly refer to [SECURITY.md](https://github.com/questdb/questdb/blob/master/SECURITY.md) file for more info.

24 25 26 27 28 29 30
We aim to respond to your issues and questions soonest. If you wish to receive a
faster response, we recommend you always describe your steps and provide
information about your environment in the bug reports. And if you're proposing a
new feature, it'll help us to evaluate the priority if you explain why you need
it.

# Navigation
31 32 33 34 35 36 37 38 39 40 41 42

## Repository overview

- QuestDB database and libraries source in Java:
  [`core/src/main/java/`](https://github.com/questdb/questdb/tree/master/core/src/main/java)
- QuestDB database tests:
  [`core/src/test/java/`](https://github.com/questdb/questdb/tree/master/core/src/test/java)
- QuestDB libraries in C:
  [`core/src/main/c/`](https://github.com/questdb/questdb/tree/master/core/src/main/c)
- QuestDB Windows service wrapper:
  [`win64svc/`](https://github.com/questdb/questdb/tree/master/win64svc/)
- QuestDB web console (frontend):
43
  [`github.com/questdb/ui`](https://github.com/questdb/ui/tree/main/packages/web-console)
44 45 46 47 48 49
- Micro benchmarks:
  [`benchmarks/`](https://github.com/questdb/questdb/tree/master/benchmarks/)

Compiled binaries (for C libraries and Windows service wrapper) are committed to
git to make build of development process Java-centric and simplified.

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
## Finding suitable issues

Our maintainers label issues with relevant categories so you can use that to
search for certain type of issues you'd like to work on. If you don't know where
to start, try search for issues labeled with
[`good first issue`](https://github.com/questdb/questdb/labels/Good%20first%20issue)
or [`help wanted`](https://github.com/questdb/questdb/labels/Help%20wanted). If
you wish to understand how our maintainers work together, you can refer to
[this section](#for-maintainers).

# Environment setup

## Requirements

- Operating system - **x86-64**: Windows, Linux, FreeBSD and OS X
- Java 11 64-bit or later
- Maven 3 (from your package manager on Linux / OSX
  ([Homebrew](https://github.com/Homebrew/brew)) or
  [from the jar](https://maven.apache.org/install.html) for any OS)
- C-compiler, CMake - to contribute to C libraries - _OPTIONAL_

## Local environment
72

73
### Setting up Java and `JAVA_HOME`
74

75 76 77 78 79
`JAVA_HOME` is required by Maven. It is possible to have multiple versions of
Java on the same platform. Please set up `JAVA_HOME` to point to Java 11 or
later. Other versions of Java may not work. If you are new to Java please check
that `JAVA_HOME` is pointing to the root of Java directory:
`C:\Users\me\dev\jdk-11.0.8` and **not** `C:\Users\me\dev\jdk-11.0.8\bin\java`.
80

81
Linux/OS X
82

83 84 85
```bash
export JAVA_HOME="/path/to/java/"
```
86

87
Windows
88

89 90 91
```bash
set JAVA_HOME="c:\path\to\java directory"
```
92

93
### Compiling Java and frontend code
94

95 96
You can compile the database and build the web console with the following
command:
97

98
```bash
99
mvn clean package -DskipTests -P build-web-console
100 101
```

102 103 104
You can then run QuestDB with:

```bash
105
java -p core/target/questdb-<version>-SNAPSHOT.jar -m io.questdb/io.questdb.ServerMain -d <root_dir>
106 107
```

108
The web console will be available at [localhost:9000](http://localhost:9000).
109

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
### Code formatting

Code is formatted using configuration files in `.idea` directory .
To minimize conflicts when merging and problems in CI all contributed code should be formatted
before submitting PR.

In IntelliJ IDEA you can : 
- automate formatting (preferrable):
  - open File | Settings
  - choose Tools | Actions On Save 
  - select  Reformat & Rearrange Code
  - click Apply

  or
- format files manually by selecting them and choosing Code | Reformat File .

126
### Compiling C-libraries
127

128
C-libraries will have to be compiled for each platform separately. Cmake will
129 130
also need `JAVA_HOME` to be set. The following commands will compile on
Linux/OSX.
131 132

```text
133 134 135
cd core
cmake -B build/release -DCMAKE_BUILD_TYPE=Release .
cmake --build build/release --config Release
136 137
```

138 139
For more details, see [CMake build instructions](core/CMAKE_README.md).

140 141
For C/С++ development we use CLion. This IDE "understands" cmake files and makes
compilation easier.
142

143
The build will copy artifacts as follows:
144

145
```
146
core/src/main/c -> core/src/main/resources/io/questdb/bin
147
```
148

149
## Local setup for frontend development
150

151 152
The frontend code (i.e. web console) is located in a [separate repository](https://github.com/questdb/ui/tree/main/packages/web-console).
To set it up you should follow instructions provided in that repository.
153

154
The development environment for frontend can run on it's own, but will require QuestDB instance running in the background. You can achieve this in multiple ways:
155

156 157 158 159
1. Run development version of QuestDB from this repository. Consult
   [environment setup](#environment-setup) section of this document
2. Run published QuestDB version, for example, with docker. More details
   can be found in the [readme of this repository](./README.md)
160

161 162 163
# Before you submit

## Testing
164

165
We have a lot of tests, most of which are of "integration" type, e.g. test
166
starts a server, interacts with it and asserts the outcome. We expect all
167 168
contributors to submit PRs with tests. Please reach out to us via Slack if
you're uncertain on how to test, or you think an existing test can be improved.
169

170
## Dependencies
171

172 173 174 175 176
QuestDB does not have Java dependencies. This may sound unorthodox but in
reality we try not to reinvent the wheel but rather than using libraries we
implement algorithms on first principles to ensure perfect fit with existing
code. With that in mind we expect contributions that do not add third-party
dependencies.
177

178
## Allocations, "new" operator and garbage collection
179 180 181 182 183

QuestDB is zero-GC along data pipelines. We expect contributions not to allocate
if possible. That said we would like to help you to contribute zero-GC code, do
not hesitate to reach out!

184
## Committing
185 186 187 188 189 190

We use [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) to
auto-generate release notes. We require all commit comments to conform. To that
end, commits have to be granular enough to be successfully described using this
method.

191
## FAQ
192

193
### Why does the server work, but the UI returns a `404` on [localhost:9000](http://localhost:9000)?
194 195

This means that the web console artifacts are not present in
196 197
`core/src/main/resources/io/questdb/site/public.zip`. To fix this, you can
simply run:
198

199 200 201
```bash
mvn clean package -DskipTests -P build-web-console
```
202

203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
### Why do some tests fail on Windows?

Some antivirus software may cause tests to fail. Typical indicators that
antivirus is interfering with tests are that tests
[pass on CI](https://github.com/questdb/questdb/blob/master/ci/new-pull-request.yml)
but are failing in the following cases:

- HTTP chunk size assertion (missing initial zeroes in e.g. `IODispatcherTest`)
- Test timeout
- JVM crash

In case of ESET products, the following steps may resolve the issue:

- Disable "application protocol content filtering" explicitly **or**
- Add `127.0.0.1` to "Excluded IP addresses" list in the **advanced settings**
  menu because disabling all top-level mechanisms doesn't turn protocol
  filtering off.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254

# For maintainers

We have an
[engineering project board](https://github.com/orgs/questdb/projects/2/views/8)
to help us organize pending GitHub issues among engineers across different
timezones. And there are configured views for bug reports and feature requests
respectively.

This is what you can do to organize open issues:

- Add new issues to project board
- Always assign yourself when you pick up an issue
- Label the issues correctly after you assess them
- Close the issue when no further action is required

Stages of our project board:

| Stage            | Description                                                                                   |
| ---------------- | --------------------------------------------------------------------------------------------- |
| New              | When users reported a bug, await for someone to reproduce or follow up                        |
| More info needed | When more communication with OP is required before we can begin triage                        |
| To do            | Once issues are confirmed and engineers can pick up. Order of items should imply the priority |
| In progress      | If an engineer picks up an issue, self-assign and move the issue to `In progress` stage       |
| Done             | Once the linked pull request is merged, the issue is closed and moved to `Done` automatically |

We also use labels to organize GitHub issues to have better overview. The
current labels can be roughly categorized as below:

| Categories | Labels                                                                                     |
| ---------- | ------------------------------------------------------------------------------------------ |
| Type       | `Bug`, `New features`, `Enhancement`, `Test`, `Tidy up`, `Question`, `Performance`, `Java` |
| Component  | `ILP`, `Rest API`, `Postgres wire`, `SQL`, `Core`, `UI`                                    |
| Priority   | `Immediate`, `Minor`, `Won't fix`, `Later`                                                 |
| Difficulty | `Good first issue`                                                                         |