CONTRIBUTING.md 9.9 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 22 23 24 25 26 27 28
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.

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
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

## 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):
  [`ui/`](https://github.com/questdb/questdb/tree/master/ui/)
- 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.

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
## 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)
- Node.js 16 / npm 8 (to manage your Node.js versions we recommend
  [`nvm`](https://github.com/nvm-sh/nvm) for OSX/Linux/Windows WSL, and
  [`nvm-windows`](https://github.com/coreybutler/nvm-windows) for Windows) -
  _OPTIONAL_
- C-compiler, CMake - to contribute to C libraries - _OPTIONAL_

## Local environment
74

75
### Setting up Java and `JAVA_HOME`
76

77 78 79 80 81
`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`.
82

83
Linux/OS X
84

85 86 87
```bash
export JAVA_HOME="/path/to/java/"
```
88

89
Windows
90

91 92 93
```bash
set JAVA_HOME="c:\path\to\java directory"
```
94

95
### Compiling Java and frontend code
96

97 98
You can compile the database and build the web console with the following
command:
99

100
```bash
101
mvn clean package -DskipTests -P build-web-console
102 103
```

104 105 106
You can then run QuestDB with:

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

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

112
### Compiling C-libraries
113

114
C-libraries will have to be compiled for each platform separately. Cmake will
115 116
also need `JAVA_HOME` to be set. The following commands will compile on
Linux/OSX.
117 118

```text
119
cmake .
120 121 122
make
```

123 124
For C/С++ development we use CLion. This IDE "understands" cmake files and makes
compilation easier.
125

126
The build will copy artifacts as follows:
127

128
```
129
core/src/main/c -> core/src/main/resources/io/questdb/bin
130
```
131

132
## Local setup for frontend development
133

134
### Development server
135

136 137
This is useful when you want to work on the web console without having to
rebuild the artifacts and restart QuestDB. Instead, we use `webpack-dev-server`:
138

139 140 141 142
0. Make sure QuestDB is running
1. `cd ui/`
2. Install the dependencies with `npm install`
3. Start the development web server with `npm start`
T
TheTanc 已提交
143

144 145
The web console should now be accessible at
[localhost:9999](http://localhost:9999)
T
TheTanc 已提交
146

147 148 149
Development server running on port 9999 will monitor for web console file
changes and will rebuild/deploy on the fly. The web console front end will be
connecting to QuestDB REST API on port 9000. Keep QuestDB server running.
150

151
### Building web console bundle into questdb.jar
V
Vlad Ilyushchenko 已提交
152

153
Run the command:
V
Vlad Ilyushchenko 已提交
154

155
```bash
156
mvn clean package -DskipTests -P build-web-console
157
```
V
Vlad Ilyushchenko 已提交
158

159
The build will copy artifacts as follows:
V
Vlad Ilyushchenko 已提交
160

161
```
162
ui -> core/src/main/resources/io/questdb/site/public.zip
163 164
```

165 166 167
# Before you submit

## Testing
168

169
We have a lot of tests, most of which are of "integration" type, e.g. test
170
starts a server, interacts with it and asserts the outcome. We expect all
171 172
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.
173

174
## Dependencies
175

176 177 178 179 180
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.
181

182
## Allocations, "new" operator and garbage collection
183 184 185 186 187

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!

188
## Committing
189 190 191 192 193 194

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.

195
## FAQ
196

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

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

203 204 205
```bash
mvn clean package -DskipTests -P build-web-console
```
206

207
### How can I easily manage the `Node.js` installation?
208

209 210 211
You can use [`nvm`](https://github.com/nvm-sh/nvm) for OS X/Linux/Windows WSL,
and [`nvm-windows`](https://github.com/coreybutler/nvm-windows) for Windows. To
have multiple active versions.
212

213
Otherwise, you can use the dedicated Maven profile to build the code:
214 215

```bash
216
mvn clean package -DskipTests -P build-web-console,build-binaries
217
```
V
Vlad Ilyushchenko 已提交
218

219 220
That way, Maven will install Node on the fly in `ui/node` so you don't have to
install it locally.
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238

### 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.
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

# 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`                                                                         |