Commit Graph

129 Commits (3f6bb3e330a8b6ba14dec6d30903ecca9d2c4620)

Author SHA1 Message Date
Dom Dwyer 6413362c72
refactor: use system-wide ingester ID
The query API exposes a unique-per-instance UUID to allow callers to
detect a crash of the ingester process - this was initialised directly
in the query RPC handler.

This commit turns the bare UUID into a type, and initialises it in the
top-level initialisation of the ingester, plumbing it down into the
query RPC handler.

This allows the UUID to be reused by other components/handlers.
2023-01-13 16:46:38 +01:00
Dom Dwyer 8dc18a9838
perf: remove double-ref Partition map
The ingester no longer needs to access a specific PartitionData by ID
(they are addressed either via an iterator over the BufferTree, or
shared by Arc reference).

This allows us to remove the extra map maintaining ID -> PartitionData
references, and the shared access lock protecting it.
2023-01-13 14:05:30 +01:00
Dom f7ff877582
Merge branch 'main' into cn/ingester-persist-tick 2023-01-13 12:31:45 +00:00
Carol (Nichols || Goulding) 02c7ed58a2
fix: Use up the first interval tick so we wait first and then persist 2023-01-12 14:55:58 -05:00
Carol (Nichols || Goulding) 0554194923
docs: Explain persist-on-demand use case and potential limitations 2023-01-12 11:52:11 -05:00
Carol (Nichols || Goulding) e1395f4f35
fix: Move PersistNow to grpc/PersistHandler 2023-01-12 11:09:33 -05:00
Carol (Nichols || Goulding) 642bab5db3
fix: Cloning persist handle for persist_partitions no longer needed 2023-01-12 11:05:25 -05:00
Carol (Nichols || Goulding) 27d58efa18
feat: Implement Persist Service on ingester2 2023-01-12 11:03:12 -05:00
Dom Dwyer 0d111c4672
refactor: delegate frontend shutdown to backend
Prior to this commit, the (happy path) shutdown sequence of an IOx
process was hard coded to:

    1. Stop gRPC & HTTP servers
    2. Stop backend server (i.e. ingester2)

After this commit, the execution of step 1 is delegated to the handler
for step 2; the server implementation (router / ingester / querier /
etc) now chooses when to shut down the RPC & HTTP servers.

This allows the server shutdown delegate to correctly sequence the
shutdown of all components of the IOx server. This allows ingester2 to
correctly sequence the shutdown of the query RPC server w.r.t the
graceful stop & persist, ensuring queries continue to be serviced.
2023-01-12 14:59:50 +01:00
Dom 0dd4afba74
Merge branch 'main' into dom/shutdown-persist 2023-01-11 16:16:30 +00:00
Dom Dwyer c01d5566b9
docs: reference WAL segement ref-counting ticket
Reference the WAL ref-counting ticket in the WAL rotation task.
2023-01-11 16:50:24 +01:00
Dom Dwyer bbd41228bc
feat(ingester2): persist on shutdown
Persist all buffered data when gracefully stopping an ingester2
instance.

This implementation accounts for both late-arriving writes, and
concurrent persist tasks - it's carefully constructed in a way that it
can discover the presence of, and wait for, outstanding persist tasks
started by other code without having to know about all the possible
places a persist task can be started (currently WAL rotation & hot
partition persistence, but later also a RPC endpoint).

There exists a small race that seems to be so incredibly unlikely to
occur, I didn't cover off (it would have a RPC write cost for little
gain). This is documented in the code comments.
2023-01-11 16:50:23 +01:00
Dom Dwyer 2fa12622c8
refactor: drop PersistState visibility
This is now an implementation detail internal to the persist subsystem.
2023-01-11 16:42:50 +01:00
Dom Dwyer 23280d0489
refactor: return persisted partition count
When calling persist_partitions(), return the number of partitions that
were persisted to the caller.
2023-01-11 16:31:40 +01:00
Dom Dwyer a80e66336b
refactor: avoid unnecessary PersistHandle clone
Avoid having to clone a persist handle in order to pass it into
persist_partitions().
2023-01-11 16:30:58 +01:00
dependabot[bot] 43a0280365
chore(deps): Bump prost from 0.11.5 to 0.11.6
Bumps [prost](https://github.com/tokio-rs/prost) from 0.11.5 to 0.11.6.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.11.5...v0.11.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-11 02:53:33 +00:00
Dom Dwyer 63b1e4a3a4
refactor: replace PersistState with IngestState
Prior to this commit, when initialising the persist system it would
return a PersistState instance, used to communicate the saturation
status of the persistence system. The RPC write path used this
information to accept or deny write requests accordingly.

This was unfortunate in that it tightly coupled the ingest handler to
the persist system - in order to initialise the RPC handler, you had to
provide a PersistState; this required us to initialise a persist system
when testing only the RPC handler (which had nothing to do with
persisting). This smells!

This commit inverts the dependency, and decouples the subsystems via a
shared type (IngestState). Instead of the persist system telling ingest
to stop, the ingest system provides a means to be told to stop - this
subtle difference decouples the ingest handler from all components that
need to block ingest. This allows a fast O(1) error state read for N
components and prevents us from having to start N components to test a
RPC handler.

Additionally this commit introduces an unused ingest error state
(GracefulStop) as part of figuring out the API (to be used shortly).
2023-01-10 16:30:10 +01:00
Dom 2ee307f8e0
Merge branch 'main' into dom/reuse-partition-iter 2023-01-10 11:55:29 +00:00
Dom Dwyer 94c71dace7
refactor: reuse PartitionIter
Allows any code that interacts with a set of PartitionData to be
abstracted from the underlying data structure.
2023-01-10 10:52:12 +01:00
dependabot[bot] b49cc2e35e
chore(deps): Bump tokio from 1.24.0 to 1.24.1 (#6545)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.24.0 to 1.24.1.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.24.0...tokio-1.24.1)

---
updated-dependencies:
- dependency-name: tokio
  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>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-01-10 09:48:44 +00:00
Dom d666bf6d22
Merge branch 'main' into dom/track-seq-num 2023-01-09 13:47:40 +00:00
Dom Dwyer aab4f6c651
refactor: remove unused QueryExec impl
This is completely unused and left over from the initial skeleton.
2023-01-09 14:28:16 +01:00
Dom Dwyer 1f509f47b1
refactor: log number of writes in persist batch
Include the number of DML operations applied to the persisted buffer
in the "persisted partition" message.

Partly because I'm intrigued / it's useful information, and partly to
ensure LLVM doesn't get snazzy and dead-code the sequence number
tracking because it was never read.
2023-01-09 13:31:42 +01:00
Dom Dwyer ca2b8afbb1
refactor(ingester2): track buffer sequence numbers
Changes the ingester2 buffer FSM to track the sequence numbers that have
been applied to it.

This is a pre-requisite for replication & correct WAL segment dropping.
2023-01-09 13:27:18 +01:00
Dom Dwyer 0916529cfb
docs: remove outdated monotonicity comment
Previously the ingester(1) required ordered writes to be applied, this
requirement has been relaxed, and the asserts (previously) removed in
ingester2.
2023-01-09 13:24:51 +01:00
dependabot[bot] e31c84a794
chore(deps): Bump async-trait from 0.1.60 to 0.1.61 (#6533)
Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.60 to 0.1.61.
- [Release notes](https://github.com/dtolnay/async-trait/releases)
- [Commits](https://github.com/dtolnay/async-trait/compare/0.1.60...0.1.61)

---
updated-dependencies:
- dependency-name: async-trait
  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>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-01-09 07:44:35 +00:00
Nga Tran b856edf826
feat: function to get parttion candidates from partition table (#6519)
* feat: function to get parttion candidates from partition table

* chore: cleanup

* fix: make new_file_at the same value as created_at

* chore: cleanup

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-01-06 16:20:45 +00:00
Raphael Taylor-Davies e1036a0c63
refactor: cleanup schema boxing (#6511)
* refactor: cleanup Schema boxing

* chore: clippy
2023-01-06 10:57:39 +00:00
Andrew Lamb 6843eee1d2
feat: Extract encoding from `RecordBatch` --> `FlightData` from flight implementations (#6460)
* feat: Extract encoding from `RecordBatch` --> `FlightData` from flight implementations

Refactor existing flight server impl

* fix: Apply suggestions from code review

Co-authored-by: Carol (Nichols || Goulding) <193874+carols10cents@users.noreply.github.com>

* fix: fixup code review comments

* fix: update for more details

* fix: Update names / types

Co-authored-by: Carol (Nichols || Goulding) <193874+carols10cents@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-01-04 13:36:16 +00:00
dependabot[bot] 0aacef3c59
chore(deps): Bump once_cell from 1.16.0 to 1.17.0 (#6473)
* chore(deps): Bump once_cell from 1.16.0 to 1.17.0

Bumps [once_cell](https://github.com/matklad/once_cell) from 1.16.0 to 1.17.0.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.16.0...v1.17.0)

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

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

* chore: Change once_cell version specifier to major.minor for less churn

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Carol (Nichols || Goulding) <carol.nichols@gmail.com>
2023-01-02 17:07:15 +00:00
Dom Dwyer 2636eefe03
fix: only replay non-empty segments
If the WAL file was dropped because it is empty, do not retry dropping
it.
2022-12-22 17:18:19 +01:00
Dom Dwyer 66f1628238
fix: drop WAL segments after replay
Changes the WAL replay logic to:

    * Replay a segment file
    * Persist all replayed data
    * Drop segment file
    * ...repeat...

This ensures old WAL segments are removed once their contents have been
made durable, fixing #6461.
2022-12-22 16:56:47 +01:00
Dom Dwyer 456368f71d
refactor(persist): no PersistQueue Clone bound
Removes the Clone bound from PersistQueue, also removing the Clone impl
from the PersistHandle.

Instead of wrapping all internal PersistHandle state in Arcs, this
commit changes the system to use a single Arc wrapping the PersistHandle
which is shared.
2022-12-22 15:04:52 +01:00
Dom Dwyer 26eea6078d
refactor(ingester2): decouple persist subsystem
Multiple components of the ingester depend on being able to enqueue a
partition's data for persistence. This commit decouples those components
from the concrete PersistHandle by introducing a PersistQueue trait that
defines the desired behaviour, on which the components depend.

This is a much needed clean-up of something I knowingly punted on for
the MVP, and I feel much better about the situation now!
2022-12-22 15:04:51 +01:00
Dom Dwyer dee9743e52
refactor(persist): decoupled PartitionIter
The persist_buffer() fn iterates over all the partitions in a BufferTree
and persists them - however it only depends on one behaviour; getting an
iterator of partitions.

This commit introduces the PartitionIter, an abstraction over anything
that can produce an iterator of PartitionData, decoupling the
persist_buffer() helper (and the callers!) from the concrete BufferTree
type.
2022-12-22 14:53:30 +01:00
Dom Dwyer e54896e5f8
refactor: extract BufferTree persist helper
Extract an existing function for re-use (from the WAL rotation task)
that marks & enqueues all non-empty partitions in a BufferTree for
persistence.
2022-12-22 11:58:41 +01:00
Dom 6df3c1d4ca
Merge branch 'main' into dom/persist-saturation-metric 2022-12-21 17:07:42 +00:00
Dom Dwyer 23dc2c4e06
refactor: consistent metric naming
Removes _ns (and incorrect _ms) suffix.
2022-12-21 18:04:20 +01:00
Dom Dwyer 23b781f274
fix(persist): invalidate cached sort key
The sort-key conflict path invalidated the cached sort key in the
PartitionData, but not the cached sort key in the persist's Context. Now
both are invalidated.
2022-12-21 17:45:48 +01:00
Dom Dwyer 679c6a7896
feat(ingester2): persist saturation metric
Expose a metric ("ingester_persist_saturated_duration_ns") that records
the cumulative duration of time the persist system has spent in the
"saturated" state.
2022-12-21 17:01:22 +01:00
Dom Dwyer 15cff11b08
refactor(persist): explicit worker module
Separate out persist worker types & routines into a separate worker
module rather than commingling them with the persist handle, and rename
the unimaginative "inner" to reflect the actual usage.
2022-12-21 14:28:30 +01:00
Dom Dwyer 7b133f85a1
docs: rust doclink failure
Rustdoc is so picky about indented text.
2022-12-20 17:13:24 +01:00
Dom Dwyer b3363639f5
chore: nudge CI 2022-12-20 17:05:03 +01:00
Dom Dwyer 5f4acf186d
docs: fix bad doc link
Rust hates indented URLs.
2022-12-20 15:25:34 +01:00
Dom Dwyer e083f3276c
feat(persist): accept concurrent matching updates
As an optimisation, allow a persist task to progress if it observes a
concurrent catalog sort key update that exactly matches the sort key it
was committing.
2022-12-20 15:15:39 +01:00
Dom Dwyer f64ffbe035
fix(ingester2): handle concurrent sort key updates
Allow an ingester2 instance to tolerate concurrent partition sort key
updates in the catalog.

A persist job is optimistically executed with the locally cached sort
key. If an ingester2 instance observes a concurrent update, it aborts
both the sort key update, and the overall persist operation (before
making the parquet file visible) and retries the operation with the
newly observed sort key. Concurrent sort key updates are theorised to be
relatively rare overall.

Any orphaned parquet files uploaded as part of a persist job that aborts
due to a concurrent sort key update are eventually removed by the
(external) object store GC task.

See https://github.com/influxdata/influxdb_iox/issues/6439
2022-12-20 15:15:39 +01:00
Dom Dwyer adc6fcfb04
feat(catalog): linearise sort key updates
Updating the sort key is not commutative and MUST be serialised. The
correctness of the current catalog interface relies on the caller
serialising updates globally, something it cannot reasonably assert in a
distributed system.

This change of the catalog interface pushes this responsibility to the
catalog itself where it can be effectively enforced, and allows a caller
to detect parallel updates to the sort key.
2022-12-20 12:31:00 +01:00
Dom dbbe43f241
Merge branch 'main' into dom/query-types-refactor 2022-12-19 15:03:16 +00:00
Dom Dwyer 84e29791e5
docs: fix incomplete comment
Finishes the incomplete sentence that
2022-12-19 12:46:21 +01:00
dependabot[bot] 299f0e99f9
chore(deps): Bump thiserror from 1.0.37 to 1.0.38
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.37 to 1.0.38.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.37...1.0.38)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-19 10:33:32 +00:00