Graylog2 / Graylog2/graylog2-server

Run database migrations before services start

Open
#6,671 1 comment 1 reaction 0 assignees View on GitHub
improvement infrastructure triaged
Dominant language
Java
Stars
8.1k
Forks
1.1k
Avg merge
1d 20h
Merged PRs (30d)
217

Description

Our database migrations are currently executed by the `Periodicals` sub-system. That means they execute at some point after the periodicals system has started. This is an issue because some services might start before the migrations have been executed and run into problems.

Examples:

- https://github.com/Graylog2/graylog2-server/issues/6414
- https://github.com/Graylog2/graylog2-server/pull/6643

To fix this, the database migrations should be executed **before** other services start.

Ideally we should also move the index creation out of the database services into a migration or a separate step during the bootstrap process. Right now the database indices are created on every instance creation of the database services.

**2020-01-10 update:** This becomes even more involved in a cluster of Graylog servers. Other servers should not start their services until the migrations are done. That means we need some kind of cluster state so all nodes wait until migrations are done and the cluster is "ready".

Refs https://github.com/Graylog2/graylog2-server/issues/5248

## Tasks

- [x] Remove database migrations from `Periodicals`
- [x] Execute migrations before starting other services in the bootstrap process
- [ ] Move creation of database indices into migrations as well or create a separate phase for that
- [ ] Move cluster ID creation out from `Periodicals` and put it into a migration: https://github.com/Graylog2/graylog2-server/issues/6414

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.