Skip to content

Commit 39a31fe

Browse files
authored
Add DEVELOPING.md and Vagrantfile to improve developing documentation and flow. (#2955)
chore(docs, bootstrap): Add DEVELOPING.md and Vagrantfile to improve developer documentation and MCS bootstrap.
1 parent 8171e9d commit 39a31fe

File tree

2 files changed

+161
-0
lines changed

2 files changed

+161
-0
lines changed

DEVELOPING.md

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
This file documents helpful knowledge, commands and setup instructions for better developing flow.
2+
3+
## Logging
4+
5+
As MariaDB runs as a system service/daemon its logs (and print-outs to stdout) get collected by journalctl (which shows logs from the systemd journal). You can check it with:
6+
7+
```bash
8+
journalctl -u mariadb | tail
9+
```
10+
11+
**Logging different objects**
12+
13+
Rows:
14+
15+
```bash
16+
std::cout << row.toString() << std::endl;
17+
```
18+
19+
## Restarting services after a crash
20+
21+
Sometimes, e.g. during debugging, single processes can crash.
22+
23+
To restart a MCS specific unit process run:
24+
25+
```
26+
systemctl restart mcs-<process_name>
27+
```
28+
29+
(So e.g. `systemctl restart mcs-primproc` ).
30+
31+
If you need to restart the whole installation use
32+
33+
```
34+
systemctl restart mariadb-columnstore
35+
```
36+
37+
## Interaction with MariaDB Server
38+
39+
MCS is one of the many [storage engines](https://mariadb.com/kb/en/choosing-the-right-storage-engine/) offered by MariaDB. A storage engine handles the SQL operations for a certain table type, e.g. Columnstore is designed for big data, uses a columnar storage system and can process petabytes of data. The default engine for MariaDB is InnoDB. You can see all currently available engines on your server by running the SQL statement: `SHOW ENGINES;` in your MariaDB console. Columnstore needs to be explicitly installed, but if you’re reading this you probably built MariaDB and MCS from source for development purposes and should see it listed.
40+
41+
Storage Engines differ in their capabilities. E.g. InnoDB is a “dumb” engine, and doesn’t work itself with the parsed syntax tree and only provides basic (e.g. filtered) output. In contrast, Columnstore is a “smart” engine, which gets the parsed syntax tree and executes the whole query on its own.
42+
43+
For interaction with storage engines, MariaDB has a template that is basically a number of API methods that are used by MariaDB for processing a query. API methods are used by both dumb and smart engines. Handlers are used by smart handlers, e.g. the Select handler is a structure with a couple of methods. The constructor the select handler is another API method. This constructor either returns nullptr or Select handler instance. In the latter case MariaDB hands future processing to the Select Handler instance method via calling its `run`method.
44+
45+
## Troubleshooting
46+
47+
### Killing a process during Debugging
48+
49+
Especially during debugging you might end up killing a process, which leads to error messages like:
50+
51+
`ERROR 1815 (HY000): Internal error: MCS-2033: Error occurred when calling system catalog.`
52+
53+
This error message occurs when the `PrimProc` process is killed, but all other processes continue running and cannot access the system catalog which is served by `PrimProc`.
54+
55+
You can verified that this happened by having a look at all running processes for MariaDB/mysql via:
56+
57+
```bash
58+
ps -axwffu | grep mysql
59+
```
60+
61+
And restart any service via
62+
63+
```bash
64+
systemctl restart mcs-<process_name>
65+
```
66+
67+
### Zombie/Defunct processes
68+
69+
Sometimes Zombie/Defunct processes can cause problems, e.g. when one PrimProc process has become defunct, a new one has been started, but MariaDB still attaches to the defunct process. Refer to [here](https://www.linuxjournal.com/content/how-kill-zombie-processes-linux) for ways to kill Zombie processes. Sometimes a restart of the development machine can be the quickest way to resolve this problem, however.
70+
71+
## Development Setup with Local Linux VM for ARM-based Macs
72+
73+
As MCS only supports Linux-based operating systems, everyone working on a MacOS or Windows system will need some way to access a Linux system. This guide is written and tested for a M1 Mac, but will probably be easily adaptable to other operating systems.
74+
75+
Using the ssh remote development features of common IDEs (e.g. VSCode or CLion), makes developing on a remote Linux server the easiest solution for development from MacOS. However, this has two drawbacks:
76+
77+
1. Development requires a (stable) internet connection and even with sufficient connection can sometimes exhibit weird load times / freezes.
78+
2. Depending on the capabilities of the available remote server, building times might be better on a M1 Mac. (Virtualization, especially with VMWare, works quite nice performance wise.)
79+
80+
Additionally, Vagrant allows to specify provisioning steps, which make setting up a new develop VM as easy as running two commands. (And already have everything necessary installed and built.)
81+
82+
Using the provided Vagrantfile the setup of develop VM is as easy as:
83+
84+
1. Adapting the parameters in the provided Vagrantfile. Currently the following options can/need to be adapted:
85+
1. `MARIA_DB_SERVER_REPOSITORY` and `MCS_REPOSITORY` . These options expect the HTTPS GitHub URL of the referenced repositories. If a build with a fork of the official repos is wanted, this is where the fork URLs should be provided. (For any questions regarding a general build, please refer to the `BUILD.md`).
86+
2. `PROVIDER` . Vagrant allows to configure the underlying VM software used (the so called provider). The current version of the Vagrantfile uses VMWare as a VM provider. VMware provides free licenses for personal use, students and open-source development, otherwise it is a paid service. If you don’t have a license or want to use another provider either way, you can either use the out of the box provided VirtualBox provider or install another provider. Read more about Vagrant VM providers [here](https://developer.hashicorp.com/vagrant/docs/providers). Read more about how to install VMWare as a provider [here](https://developer.hashicorp.com/vagrant/docs/providers/vmware/installation).
87+
3. `BOX` . Vagrant uses boxes to package Vagrant environments. The box needs to match your system and architecture. The easiest way to obtain a a box is to select one from the publicly available, pre-defined boxes at [VagrantCloud](https://app.vagrantup.com/boxes/search).
88+
4. `MEMSIZE/NUMVCPUS`: Adapt the number of cores and the amount of RAM you want to give your VM.
89+
2. Run `vagrant up` to create and/or start the virtual machine as specified in the `Vagrantfile`.
90+
3. Run `vagrant ssh` to obtain a terminal directly in your VM - or to develop on the virtual machine in your preferred IDE, obtain the ssh config data of the machine with `vagrant ssh-config` and use it to connect. (For even easier connection add the ssh connection data to your `~/.ssh/config` .)

Vagrantfile

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# This Vagrantfile is used to create a local VM for MariaDB ColumnStore development.
5+
# If not disabled, it automatically installs the latest develop branch of MariaDB ColumnStore on the VM.
6+
# Basic usage:
7+
# 1. Install Vagrant and optionally VMWare as a provider.
8+
# 2. Configure the options below to your needs.
9+
# 3. Run "vagrant up" to create the VM and "vagrant ssh" to access it.
10+
# More documentation can be found in DEVELOPING.md.
11+
12+
VAGRANTFILE_API_VERSION = "2"
13+
14+
# Update with your own fork of MariaDB Server and MariaDB ColumnStore if needed.
15+
MARIA_DB_SERVER_REPOSITORY = "https://github.com/MariaDB/server.git"
16+
MCS_REPOSITORY = "https://github.com/mariadb-corporation/mariadb-columnstore-engine.git"
17+
18+
# Set provider for the VM.
19+
# PROVIDER = :virtualbox # default - if you don't have installed a specific provider use this one.
20+
PROVIDER = :vmware_fusion
21+
22+
# Choose image/"box" for the VM for your architecture from https://app.vagrantup.com/boxes/search
23+
BOX = "bento/ubuntu-20.04-arm64"
24+
25+
# Set hardware resources for the VM
26+
MEMSIZE = 16384 #MB
27+
NUMVCPUS = 8
28+
29+
$provision_script = <<-'SCRIPT'
30+
# enable autocompletion via arrow up and down keys using readline library
31+
cat > ~/.inputrc <<-'AUTOCOMPLETION'
32+
# Respect default shortcuts.
33+
$include /etc/inputrc
34+
## arrow up
35+
"\e[A":history-search-backward
36+
## arrow down
37+
"\e[B":history-search-forward
38+
AUTOCOMPLETION
39+
40+
# run setup for MariaDB ColumnStore
41+
42+
git clone $1
43+
cd server
44+
git submodule update --init --recursive --depth=1
45+
46+
cd storage/columnstore/columnstore
47+
git remote remove origin
48+
git remote add origin $2
49+
50+
cd server/storage/columnstore/columnstore
51+
git checkout develop
52+
git config --global --add safe.directory `pwd`
53+
54+
sudo -E build/bootstrap_mcs.sh --install-deps -t RelWithDebInfo
55+
SCRIPT
56+
57+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
58+
config.vm.define "mcs-dev"
59+
config.vm.box = BOX
60+
61+
config.vm.provider PROVIDER do |v|
62+
v.vmx["memsize"] = MEMSIZE
63+
v.vmx["numvcpus"] = NUMVCPUS
64+
end
65+
66+
config.vm.provision "shell" do |script|
67+
script.inline = $provision_script
68+
script.args = [MARIA_DB_SERVER_REPOSITORY, MCS_REPOSITORY]
69+
script.privileged = false
70+
end
71+
end

0 commit comments

Comments
 (0)