Commit Graph

603 Commits (e1e31637520a08421d93180b27e5c534571b6ea1)

Author SHA1 Message Date
Marco Neumann e1e3163752 refactor: rework DB init state machine
Since adding new features like "sequencer replay" or init retries would
make the current code too complex, a refactor is required:

Config:
The config struct now holds a `DatabaseState` which is a simple linear
state machine representing the different stages of the database init.

Init:
The init module now has a fixpoint-loop which looks at the state,
decides what to do based on it and repeats until either the DB is
initialized or an error occured. This also makes it easier to continue
the init process "in the middle", e.g. when the preserved catalog is
broken or the sequencer (e.g. Kafka) could not be reached.
2021-07-01 13:47:51 +02:00
Andrew Lamb cfa06e1497
chore: Add query tests for compacted chunks (#1861)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-06-30 20:59:29 +00:00
Raphael Taylor-Davies 99a15cd452
refactor: single lifecycle error enumeration (#1859)
* refactor: single lifecycle error enumeration

* fix: fmt

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2021-06-30 18:35:57 +00:00
Andrew Lamb 817a480cde
refactor: move lifecycle implementations out of db.rs and into their own modules (#1858)
* refactor: move lifecycle implementations out of db.rs and into their own modules

* fix: clippy
2021-06-30 17:24:04 +00:00
Andrew Lamb 9e1723620c
refactor: rename load_chunk_to_read_buffer to move_chunk_to_read_buffer (#1857)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-06-30 16:53:18 +00:00
Marco Neumann 043890369f refactor: make `MinMaxSequence` safer to use 2021-06-30 16:37:48 +02:00
kodiakhq[bot] 983062f6fa
Merge branch 'main' into crepererum/no_catalog_on_db_creation 2021-06-30 10:04:00 +00:00
Edd Robinson 2e430ac7f0 refactor: remove table name from read_filter schema 2021-06-30 09:50:53 +01:00
Edd Robinson 62f274cc1b refactor: remove table name from column_values 2021-06-30 09:46:54 +01:00
Edd Robinson 5737c9d962 refactor: remove table name from column_names 2021-06-30 09:43:41 +01:00
Marco Neumann c4e054f909 feat: do NOT load preserved catalogs on late DB creation
When a DB is created AFTER the server is initialized, then we can assume
it is a new DB (because the rules file did not exist beforehand). We
shall treat it as a new DB with no data and should not try to load some
leftover / stale / whatever preserved catalog for it. How this catalog
came into existence we do not know and it was certainly not properly
managed by IOx. So we error if there is a catalog.

Furthermore the old implementation was kinda broken since it loaded the
perserved catalog "in-sync" with the gRPC call that issued the DB
creation (we only have a delayed init concept for DBs that are loaded on
instance startup). In production that would very likely provoke nasty
timeouts.

On top of that this new behavior will also be somewhat more sane when we
think about sequencer (e.g. Kafka) replays. We certainly do not wanna do
any replays for newly created DBs.

TLDR: New behavior for DBs created via gRPC is "new empty DB". This does
NOT affect DBs loaded on instance startup (aka existing DBs).
2021-06-30 10:12:38 +02:00
Marco Neumann 58310abfee refactor: de-duplicate code in `server::db::load` 2021-06-30 10:08:25 +02:00
Marco Neumann 9d10ac9f6a refactor: write parquet files w/o holding the transaction lock
This allows to prepare writes per-tableXpartition before entering the
database-exclusive section that deals with catalog transactions.

Closes #1821.
2021-06-29 14:23:06 +02:00
Marco Neumann 3ebb6a3037 refactor: do not capture txn-specific information in parquet files
This helps with #1821.
2021-06-29 14:22:36 +02:00
Edd Robinson a7198ea78b refactor: use satisfies_predicate in apply_predicate 2021-06-29 11:58:28 +01:00
kodiakhq[bot] eda9532eb2
Merge branch 'main' into crepererum/issue1821-cleanup-lock 2021-06-29 10:48:43 +00:00
Andrew Lamb 3ee96c4618
fix: Do not sequence local writes (avoid panic under load) (#1826)
* fix: Do not sequence local writes

* fix: Update server/src/db.rs

Co-authored-by: Edd Robinson <me@edd.io>

* fix: review comments

* fix: restore passing sequence information down to mutable buffer

* fix: store min/max times even when there are no sequence numbers

Co-authored-by: Edd Robinson <me@edd.io>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-06-29 10:39:37 +00:00
Marco Neumann 2cd5ce98be refactor: do not pass locks around for catalog cleanup 2021-06-29 10:21:41 +02:00
Marco Neumann 730a23faa3 refactor: improve locking around the parquet file cleanup
Instead of (ab)using the transaction lock to prevent the cleanup job
from removing just-written parquet files, use a dedicated lock. This
will later allow us to write parquet files before starting a transaction
(i.e. w/o holding the transaction lock).

This will help with #1821.
2021-06-29 10:20:03 +02:00
Edd Robinson 12ae9b012a refactor: clarify intent of 2021-06-28 17:39:48 +01:00
Carol (Nichols || Goulding) 0f7c47d10e fix: Limit the number of errors per sequenced entry we'll collect 2021-06-28 09:29:17 -04:00
Carol (Nichols || Goulding) 1e171e2e9a refactor: Organize `use` statements and let rustfmt manage order 2021-06-28 09:29:15 -04:00
Carol (Nichols || Goulding) f3a3a9b267 fix: Try to write all partition_writes even if one fails, collect all errors and report at the end 2021-06-28 09:24:23 -04:00
Carol (Nichols || Goulding) 4d2954ec1d test: Write a failing tests for partition_writes being ignored after a failure 2021-06-28 09:24:23 -04:00
Marco Neumann 65e65412cc refactor: move catalog loading code into its own module 2021-06-28 12:46:25 +02:00
Paul Dix de236c5a6f feat: update persistence windows to support late arrival less than 30 seconds 2021-06-25 15:34:11 -04:00
Paul Dix 435b4b6a94 feat: add persistence windows to partition and update on write
This brings the persistence windows into the catalog partition. It adds a helper method on TableBatch to get the min and max times for a given write. Finally, it adds this logic to the db to update persistence windows on every write while the partition write lock is being held.
2021-06-25 15:34:11 -04:00
Raphael Taylor-Davies 3046b1692c
chore: include table name in compaction log (#1805)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-06-25 15:20:44 +00:00
Andrew Lamb 79446d45be
feat: Implement split_plans (#1794)
* feat: implement split plan / planner

* fix: Apply suggestions from code review

Co-authored-by: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com>

* fix: resolve merge conflicts

* fix: add values to panic

Co-authored-by: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com>
2021-06-24 18:38:00 +00:00
Raphael Taylor-Davies 297fc12db8
feat: compact chunks (#1776)
* feat: compact chunks

* chore: review feedback

* chore: clippy lints

* chore: document sort key algorithm

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-06-24 16:49:10 +00:00
Carol (Nichols || Goulding) c0c1c3fd8e refactor: Extract a struct to hold all the arguments needed to make a Db 2021-06-23 16:31:38 -04:00
Carol (Nichols || Goulding) f903b6eca8 fix: Create WriteBuffer outside of commit_db so committing can't fail 2021-06-23 13:56:50 -04:00
Carol (Nichols || Goulding) 51e72c8821 refactor: Extract a function for creating a write buffer from database rules 2021-06-23 13:33:29 -04:00
Carol (Nichols || Goulding) 57aee2f770 fix: Remove TODO that's a TODON'T 2021-06-23 13:18:28 -04:00
Carol (Nichols || Goulding) 6ec3c03b0a fix: Handle failure to create a Kafka producer rather than panicking 2021-06-23 10:51:23 -04:00
Carol (Nichols || Goulding) c66f9e5aeb feat: Write entries to Kafka when configured as the write buffer 2021-06-23 10:48:18 -04:00
Carol (Nichols || Goulding) 08f0696890 refactor: Extract a type alias for the trait's error type 2021-06-23 10:48:18 -04:00
Carol (Nichols || Goulding) 250b9362a6 fix: Pass the database to the KafkaBuffer to use as the topic 2021-06-23 10:48:18 -04:00
Carol (Nichols || Goulding) 93881da016 feat: Make Write Buffer store_entry async
In preparation for the Kafka write buffer implementation needing to call
async functions.
2021-06-23 10:48:18 -04:00
kodiakhq[bot] 59993e8b8f
Merge branch 'main' into crepererum/issue1623 2021-06-23 12:40:05 +00:00
Marco Neumann c395409b51 feat: include UUIDv4 into parquet file names
Change schema from

```text
<server_id>/<db_name>/data/<part_key>/<chunk_id>/<table_name>.parquet
```

to

```text
<server_id>/<db_name>/data/<table_name>/<part_key>/<chunk_id>.<uuid>.parquet
```

So parquet files will NEVER be overwritten. This is especially helpful
when dealing with old catalog leftovers (i.e. a parquet file that
belonged to an old but wiped catalog). It also simplifies the reasoning
about file references in the future and follows what other dataset
formats are usually doing (i.e. never replace files).

Also use `ChunkAddr` where it makes sense.
2021-06-23 14:30:28 +02:00
kodiakhq[bot] 70817a474c
Merge branch 'main' into crepererum/issue1740-d 2021-06-23 12:29:54 +00:00
Raphael Taylor-Davies 5cd911c74a
fix: correct row count for object store chunks (#1789) 2021-06-23 12:06:49 +00:00
kodiakhq[bot] d94a9ea94a
Merge branch 'main' into crepererum/better_served_uninit_error 2021-06-23 08:54:48 +00:00
Marco Neumann cf55df68b5 refactor: remove some `Arc`s around the in-mem catalog
This is for #1740.
2021-06-23 10:51:22 +02:00
Marco Neumann 39eac62d5d fix: improve "server not initialized" error
We've reported "databases not loaded" which is a bit confusing for
router nodes, so change the description to "server not initialized".
2021-06-23 10:47:51 +02:00
Marco Neumann d2be641864 refactor: make checkpointing easier to use
Don't mix commit+checkpoint in a single call so that the caller has to
reason about the error type and which of the two operations has failed.
Splitting it also makes it easier to create the correct checkpoint data.
2021-06-23 10:25:05 +02:00
Marco Neumann 4a961694ec refactor: make caller sync mem<>OS view during catalog transactions
This is for #1740. Greatly simplifies the integration of the persisted
catalog into the DB.
2021-06-23 10:25:05 +02:00
kodiakhq[bot] c3dbe4c571
Merge branch 'main' into crepererum/fix_auto_wipe 2021-06-22 13:50:53 +00:00
Marco Neumann a98b10745f fix: auto-wipe should still be enabled
Auto-wipe broken catalogs should be enabled until #1522 is closed.
2021-06-22 15:45:32 +02:00