Commit Graph

253 Commits (2277fcf08ac487c73e5765dbcff7405058061fad)

Author SHA1 Message Date
Dom Dwyer cd4087e00d style: add no todo!() or dbg!() lints
Some crates had theme, some not - lets be consistent and have the
compiler spot dbg!() and todo!() macro calls - they should never be in
prod code!
2022-09-29 13:10:07 +02:00
Dom Dwyer a5e5dfda6f refactor: remove dbg!
Left over from debugging.
2022-09-29 13:08:47 +02:00
Dom Dwyer 5f49c568c9 fix: remove future offset read check
In https://github.com/influxdata/influxdb_iox/pull/5754 I added code at
seek() time to check if the offset exists, and refuse to seek if that's
not the case, effectively making this check redundant - I left it in on
the assumption that some cases previously added would work!

Unfortunately this doesn't seem to be the case -
performing a read-ahead-of-data and read-behind-data seems to cause the
high_watermark to be returned as -1, meaning this code never worked?!
This new read-ahead-of-data match arm took priority over the
SequenceNumberNoLongerExists arm, effectively preventing the ingester
from taking the desired remediation (skipping to most recent write, or
erroring, depending on configuration).
2022-09-29 11:39:57 +02:00
Dom Dwyer 82b7479f97 refactor(write_buffer): seek error at seek time
Moves the "you've tried to seek into the future!" error to the point at
which the seek attempt was made.

This makes more sense than deferring the seek error until read time, and
is easier to determine this is the case rather than at read time (where
the read response error contains an invalid high_watermark value of -1,
making it impossible to conclusively determine what has happened).
2022-09-28 16:44:59 +02:00
Dom Dwyer 5f2f735c7e fix: spurious watermark < read offset panic
In staging we observed an ingester panic due to the write buffer stream
yielding an WriteBufferErrorKind::SequenceNumberAfterWatermark,
suggesting the ingester was attempting to read from an offset that
exceeds the current max write offset in Kafka (high watermark offset).

This turned out not to be the case - the partition had a single write at
offset 2, and the ingester was attempting to seek to offset 1. The first
read would fail (offset 1 does not exist) and the error handling did not
account for the high watermark not being correctly set (-1 in the
response).

I have no idea why rskafka returns this watermark / doesn't retry / etc
but this change will allow the ingesters to recover.
2022-09-28 15:22:34 +02:00
Carol (Nichols || Goulding) c8108f01e7
chore: Upgrade to Rust 1.64 (#5727)
* chore: Upgrade to Rust 1.64

* fix: Use iter find instead of a for loop, thanks clippy

* fix: Remove some needless borrows, thanks clippy

* fix: Use then_some rather than then with a closure, thanks clippy

* fix: Use iter retain rather than filter collect, thanks clippy

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-09-22 18:04:00 +00:00
dependabot[bot] b6fb481b0f
chore(deps): Bump dotenvy from 0.15.3 to 0.15.5 (#5689)
Bumps [dotenvy](https://github.com/allan2/dotenvy) from 0.15.3 to 0.15.5.
- [Release notes](https://github.com/allan2/dotenvy/releases)
- [Changelog](https://github.com/allan2/dotenvy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/allan2/dotenvy/compare/v0.15.3...v0.15.5)

---
updated-dependencies:
- dependency-name: dotenvy
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-20 05:28:47 +00:00
dependabot[bot] 786ce75e26
chore(deps): Bump tokio-util from 0.7.3 to 0.7.4 (#5596)
Bumps [tokio-util](https://github.com/tokio-rs/tokio) from 0.7.3 to 0.7.4.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-util-0.7.3...tokio-util-0.7.4)

---
updated-dependencies:
- dependency-name: tokio-util
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-09 07:40:16 +00:00
Dom Dwyer 33b78eb5d2 build: bump rskafka
Update rskafka to HEAD, picking up:

d7e14a8 test: increase timeouts, CircleCI is slow
4e92ed2 refactor: replace `time` w/ `chono`
c0ba668 fix: never leak flusher background tasks
786d6e1 refactor: move batch into producer mod
82862df perf: use RwLock for BroadcastOnce
e12c812 perf: async batch flushing & lock contention
ad126c5 test: increase timeouts
6565321 test: improve testing config
3379959 refactor: also invalidate broker cache when erroring on "unknown topic/partition"
14ae812 refactor: clarify binding mechanism
b59d9ad docs: fix spelling
e73fef5 test: increase timeouts
0dd1bda feat: introduce bind mode for partition client
a3633c6 fix: disable topic auto creation in tests
72c6dd2 fix: make redpanda happy
ae6df2e ci: bump redpanda version
a1ff3e5 chore: update Rust to 1.63
1ca7c5f ci: shellcheck
01a648b ci: yammlint
3248dd6 ci: check that versions are in-sync
ebf87b5 ci: run doctests
32c34ec fix: address deprecation warnings
0f6ad6c chore: fix `cargo bench -- --save-baseline`
2022-09-07 14:00:19 +02:00
Dom a57748d741
Merge branch 'main' into dom/ingester-shard-connect 2022-09-07 12:25:40 +01:00
Dom Dwyer d1ca29c029 fix(ingester): connect to assigned Kafka partition
During initialisation, the ingester connects to the Kafka brokers - this
involves per-partition leadership discovery & connection establishment.
These connections are then retained for the lifetime of the process.

Prior to this commit, the ingester would establish a connection to all
partition leaders for a given topic. After this commit, the ingester
connects to only the partition leaders it is going to consume from
(for those shards that it is assigned.)
2022-09-07 13:21:06 +02:00
Marco Neumann adeacf416c
ci: fix (#5569)
* ci: use same feature set in `build_dev` and `build_release`

* ci: also enable unstable tokio for `build_dev`

* chore: update tokio to 1.21 (to fix console-subscriber 0.1.8

* fix: "must use"
2022-09-06 14:13:28 +00:00
dependabot[bot] 9ba9128887
chore(deps): Bump httparse from 1.7.1 to 1.8.0 (#5516)
Bumps [httparse](https://github.com/seanmonstar/httparse) from 1.7.1 to 1.8.0.
- [Release notes](https://github.com/seanmonstar/httparse/releases)
- [Commits](https://github.com/seanmonstar/httparse/compare/v1.7.1...v1.8.0)

---
updated-dependencies:
- dependency-name: httparse
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-09-01 10:27:36 +00:00
Carol (Nichols || Goulding) 74c9529062
fix: Rename KafkaPartition to ShardIndex 2022-08-29 14:07:18 -04:00
Dom Dwyer 175cae2f56 feat: capture Kafka message size distribution
Adds instrumentation to the low-level (post-aggregation) Kafka client,
capturing the uncompressed, approximate message size (calculated as the
sum of all Record::approximate_size() returns, ignoring largely static
framing overhead).
2022-08-29 14:08:51 +02:00
Dom Dwyer 80eb8efbe5 refactor: WARN for full aggregators
Emit a WARN log line whenever an aggregator becomes full - this will
help identify tuning opportunities.
2022-08-29 14:08:51 +02:00
Marko Mikulicic 4beb721a9a
fix: Revert Bump dotenvy from 0.15.1 to 0.15.2 (#5450) (#5455)
This reverts commit 84acbd2fad.

Closes #5454

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-08-24 09:10:09 +00:00
dependabot[bot] 84acbd2fad
chore(deps): Bump dotenvy from 0.15.1 to 0.15.2 (#5450)
Bumps [dotenvy](https://github.com/allan2/dotenvy) from 0.15.1 to 0.15.2.
- [Release notes](https://github.com/allan2/dotenvy/releases)
- [Changelog](https://github.com/allan2/dotenvy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/allan2/dotenvy/commits/v0.15.2)

---
updated-dependencies:
- dependency-name: dotenvy
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-23 11:24:42 +00:00
Dom Dwyer 8b054c14a8 test: update batching tests for new aggregator
Previously aggregated writes were merged into a single Kafka Record -
this meant that all merged ops would be placed into the same Record, and
therefore receive the same sequence number once published to Kafka.

The new aggregator batches at the Record level, therefore aggregated
writes now get their own distinct sequence number. This commit updates
the batching tests to reflect this new sequence number assignment
behaviour.
2022-08-22 12:59:43 +02:00
Dom Dwyer 312def5acd refactor: assert writes partitioned
The previous aggregator impl would assert that writes had been
partitioned before aggregating them (or rather, that the DML write had a
partition key assigned).

This should be true for all writes passing through the write buffer,
irrespective of which aggregator is used, therefore this assert is moved
"up" into the write buffer itself.
2022-08-22 12:52:37 +02:00
Dom Dwyer a66d16576d refactor: use dyn TimeProvider in RecordAggregator
For ease of integration with the existing tests, use dyn TimeProvider in
the RecordAggregator.
2022-08-22 12:50:50 +02:00
Dom Dwyer 37727105b5 refactor: remove redundant timestamp conversions
Removes the existing, copy-pasted timestamp conversion code to remove
redundant conversions.
2022-08-22 11:06:36 +02:00
Dom Dwyer 59c2d84d1e refactor: use RecordAggregator
Replaces the DmlAggregator with the simpler RecordAggregator.

Metrics gathered as part of #5323 shows there is practically no benefit
to the additional complexity of the DmlAggregator over the simpler
RecordAggregator impl.
2022-08-18 17:12:23 +02:00
Dom Dwyer 30e23f6e82 feat: simple RecordAggregator for write buffer
This commit adds a new write buffer aggregator used by rskafka to
increase the size of Kafka messages on the wire. The Kafka write buffer
impl is the only impl to perform aggregation.

This Aggregator impl maps IOx-specific DML operations to rskafka Records
with no additional processing - it can be thought of as an IOx-specific
adaptor over rskafka's RecordAggregator.

By delegating batching of Record instances to rskakfa's simple
RecordAggregator, we minimise code complexity / bug surface area / LoC.
2022-08-18 11:42:58 +01:00
Dom Dwyer bd88ac6149 refactor: parallelise Kafka partition client init
Changes the Kafka write buffer impl to parallelise initialisation of the
PartitionClient instances.

Now that the PartitionClient constructor also performs leader discovery
(using cached metadata, influxdata/rskafka#164) and establishes a broker
connection (influxdata/rskafka#166) executing them in parallel will
cause a proportional decrease in the time taken to bring IOx up.
2022-08-12 14:45:23 +02:00
Dom dbe6b4947c
Merge branch 'main' into dom/bump-rskafka 2022-08-12 09:20:37 +01:00
Dom Dwyer 7118334774 build: bump rskafka
Bump rskafka to pick up connection pre-warming:

    https://github.com/influxdata/rskafka/pull/166
2022-08-12 10:13:25 +02:00
Carol (Nichols || Goulding) 3a501a4a10
fix: Remove an immediate ref to a deref
Caught by clippy now. https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref
2022-08-11 15:04:14 -04:00
Dom Dwyer faa1db9a24 build: bump rskafka
Bump rskafka & fix minor breakage in order to pick up client
pre-warming:

    https://github.com/influxdata/rskafka/pull/165
2022-08-11 17:26:06 +02:00
Dom Dwyer 7174f38f3f build: bump rskafka
Bumps rskafka to HEAD to pick up:

    https://github.com/influxdata/rskafka/pull/164
2022-08-11 14:00:21 +02:00
Marco Neumann 6b8b922fe7
fix: do not loose data when Kafka reports that offset is above watermark (#5322)
* fix: do not loose data when Kafka reports that offset is above watermark

This can happen in certain cluster rebalance settings.

This is also linked to https://github.com/influxdata/rskafka/issues/147
but for the upstream issue I currently have no idea how to fix it, so
let's at least harden IOx against it.

Fixes #5128.

* refactor: panic for `SequenceNumberAfterWatermark`
2022-08-11 07:32:04 +00:00
Andrew Lamb 16ddc5efc6
chore: Update datafusion / arrow/parquet/arrow-flight and prost/tonic ecosystem (#5360)
* chore: Update datafusion and arrow

* chore: Update Cargo.lock

* chore: update to Decimal128

* chore: Update tonic/prost/pbjson/etc

* chore: Run cargo hakari tasks

* fix: doctest in generated types

Co-authored-by: CircleCI[bot] <circleci@influxdata.com>
2022-08-09 17:30:44 +00:00
Dom Dwyer 87e4290e1f refactor(write_buffer): database_name -> topic_name
Previously IOx mapped a single database to a single kafka topic - this
is no longer the case, so referring to the kafka topic name as the
"database name" name is confusing.
2022-08-08 15:24:35 +02:00
Dom Dwyer c133cf22c6 refactor: use kafka produce instrumentation
This commit changes the IOx write buffer initialisation code to add the
KafkaProducerMetrics instrumentation to the per-partition Kafka clients.
2022-08-08 15:24:35 +02:00
Dom Dwyer 284a3069ce feat: Kafka client produce() instrumentation
Adds a decorator over the underlying kafka client to capture the latency
distribution of the low-level kafka writes, independent of the
aggregation/DML batching framework that sits "above" this client.

The latency measurements include the serialisation overhead, protocol
overhead, and actual network I/O.
2022-08-08 15:24:35 +02:00
kodiakhq[bot] 0ba3ae1e0d
Merge branch 'main' into dom/instrument-kafka-produce 2022-08-04 15:13:49 +00:00
Dom Dwyer 77fd967517 feat: instrument kafka aggregated DML batch size
The Kafka write buffer implementation (and only the Kafka impl) merges
together successive DML writes for the same namespace & partition within
a window of time.

This commit records the number of DML writes that have been merged
together to form a single batched op before it is dispatched to Kafka.
2022-08-04 16:48:56 +02:00
Dom Dwyer 1cad7e13ec build: bump rskafka to latest
Includes minor code changes needed to support the rskafka HEAD commit.

Breaking changes made in
    https://github.com/influxdata/rskafka/issues/160
2022-08-04 15:02:11 +02:00
Marco Neumann 273b3cc165
chore: replace `dotenv` with `dotenvy` (#5285)
The latter one is a maintained fork. This avoids having both crates
after #5282.
2022-08-03 12:41:38 +00:00
Marco Neumann 87bdabb38a
feat: log external span for query gRPC requests (#5187)
* feat: log external span for query gRPC requests

This should simplify the correlation with our binlog data.

* refactor: address review comments

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-07-28 12:53:12 +00:00
dependabot[bot] 9b67de2f43
chore(deps): Bump tokio from 1.19.2 to 1.20.0
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.19.2 to 1.20.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.19.2...tokio-1.20.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-14 01:21:43 +00:00
Marco Neumann 9e09f77a45
fix: fix overeager Kafka message flushing (#5113)
* test: add (failing) test to ensure that interleaved partition writes are aggregated correctly

* fix: fix overeager Kafka message flushing
2022-07-13 12:32:03 +00:00
Andrew Lamb 280698f9f5
feat: Increase `DmlWrite` operation throughput by pipelining kafka read and decode (#5066)
* feat: pipeline kafka read and decode

* docs: Update write_buffer/src/kafka/mod.rs

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-07-08 13:18:21 +00:00
Andrew Lamb 8f5210ea3e
test: add test for "duration since production" in kafka `write_buffer` implementation (#5043)
* test: add test for timestamps in kafka write buffer

* refactor: move timestamp batching test to generic tests

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-07-07 10:27:27 +00:00
Andrew Lamb 5944f27e77
refactor: avoid write buffer cloning in `store_operation` (#5042)
* refactor: avoid write buffer cloning in `store_operation`

* fix: update usage

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-07-06 06:57:03 +00:00
Andrew Lamb 0c705fecf1
refactor: Clean up timestamp handling logic and avoid a conversion (#4988)
* refactor: Clean up timestamp handling logic

* fix: Remove unused timestamp function

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-07-01 01:07:21 +00:00
Marco Neumann 751bdce88a
fix: pass write buffer tests w/o Kafka (#4923)
Fixes interaction of `maybe_skip_kafka_integration!` and `should_panic`
by ensuring that `maybe_skip_kafka_integration!` panics to skip
`should_panic` tests.

Without that it is not possible to just run `cargo test -p write_buffer`.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-06-22 10:41:40 +00:00
Dom Dwyer c1f7154031 feat: propagate partition key through kafka
Changes the kafka message wire format to include the partition key for
serialised DML writes on the wire.

After this commit, the kafka messages will contain the partition key for
each op, but this information will go unused in the ingester - this
enables us to roll out the producer side, before making the value's
presence necessary on the consumer side.

A follow-up PR will change the ingester to utilise this embedded
partition key.

This has the unfortunate side effect of making the partition key part of
the public gRPC write API:

    https://github.com/influxdata/influxdb_iox/issues/4866
2022-06-20 13:42:51 +01:00
Marco Neumann 0fbff981ec
chore(deps): Bump sqlx to 0.6.0 and uuid to 1 (#4894)
Closes #4889.
Closes #4890.

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-17 10:28:28 +00:00
Dom Dwyer 43b3f22411 fix: respect partition key when batching dml ops
This commit changes the kafka write aggregator to only merge DML ops
destined for the same partition.

Prior to this commit the aggregator was merging DML ops that had
different partition keys, causing data to be persisted in incorrect
partitions:

    https://github.com/influxdata/influxdb_iox/issues/4787
2022-06-16 14:05:32 +01:00