Commit Graph

359 Commits (b783bb1967a5b7f5ab14a1240cdaa9693c01c0fd)

Author SHA1 Message Date
Dom Dwyer 6cf180738b
test: more exacting retention validation tests
The old tests used partial error string matching, with the whole error
message! So when I added more to the error message, the fixture tests
didn't fail.

This changes the tests to match the full string, and validate the
timestamps are included.
2023-05-23 12:04:52 +02:00
Dom Dwyer ec0d1375d4
feat(router): put timestamps in retention error
Include the minimum acceptable timestamp (the retention bound) and the
observed timestamp that exceeds this bound in the retention enforcement
write error response.
2023-05-23 11:50:32 +02:00
dependabot[bot] 6cb7619d83
chore(deps): Bump base64 from 0.21.0 to 0.21.1 (#7832)
Bumps [base64](https://github.com/marshallpierce/rust-base64) from 0.21.0 to 0.21.1.
- [Changelog](https://github.com/marshallpierce/rust-base64/blob/master/RELEASE-NOTES.md)
- [Commits](https://github.com/marshallpierce/rust-base64/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-22 09:50:06 +00:00
Andrew Lamb 6344fe8c3f
chore: Add rationale for `clippy::future_not_send` (#7822)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-18 16:58:56 +00:00
Dom Dwyer 82500720e4
refactor(cli): update replication help text
The replication flag defines the total number of copies of each write -
slightly less confusing than the additional copies it was previously,
and matches with the actual code.
2023-05-18 16:01:12 +02:00
wiedld 506bd80f6f
Merge branch 'main' into chore/router-metrics-for-auth-v2 2023-05-16 10:24:42 -07:00
Dom 3c47226244
Merge branch 'main' into dom/parallel-replicate 2023-05-16 11:05:10 +01:00
wiedld 2e2aac9ac8 refactor: with updated Authorizer interface, update the metric to delineate the different scenarios 2023-05-15 11:25:01 -07:00
Carol (Nichols || Goulding) 57bedb1c2d
refactor: Extract a test helper function to create a basic namespace 2023-05-15 14:20:38 -04:00
wiedld d087160112 chore: update naming conventions, and use assert_histogram in tests 2023-05-15 09:26:15 -07:00
wiedld 199daee0f6 chore: make AuthorizerInstrumentation use a constant topic (metric name) within the registry 2023-05-15 08:52:09 -07:00
wiedld d8661d043b chore: use new authorizer metric decorator, in the router 2023-05-15 08:52:06 -07:00
wiedld 867fd39dbf
Merge branch 'main' into authz/refactor-interface 2023-05-15 08:03:10 -07:00
Kaya Gökalp 5fe8affb18
refactor: accept NamespaceName with Namespace create (#7774)
Co-authored-by: Dom <dom@itsallbroken.com>
2023-05-15 10:03:55 +00:00
wiedld 4c30e7e04d refactor: Authorizer trait should have a single interface for requested permissions()
* returns an intersection of requested_perms and actual perms_on_token
* returns ok if any of the requested_perms is within the actual perms_on_token
2023-05-12 15:28:58 -05:00
Dom Dwyer dfe1a7dec8
perf(router): parallel write replication
This commit changes the write replication loop to concurrently write to
N distinct upstream ingesters, instead of the previous sequential logic.
2023-05-12 17:04:32 +02:00
Dom Dwyer bf93014bb7
feat: concurrent lending iterator
Changes the UpstreamSnapshot to be suitable for concurrent use. This
type contains the core logic to enable a caller to uphold the
responsibility of ensuring replicated writes land on distinct ingesters
in the presence of concurrent replication.

The clients within the snapshot are returned to at most one concurrent
caller at a time, by tracking the state of each client as a FSM:

                        ┌────────────────┐
                     ┌─▶│   Available    │
                     │  └────────────────┘
                     │           │
                   drop       next()
                     │           │
                     │           ▼
                     │  ┌────────────────┐
                     └──│    Yielded     │
                        └────────────────┘
                                 │
                              remove
                                 │
                                 ▼
                        ┌────────────────┐
                        │      Used      │
                        └────────────────┘

Once a client has been yielded it will not be yielded again until it is
dropped (transitioning the FSM from "yielded" to "available" again,
returning it to the candidate pool of clients) or removed (transitioning
to "used", permanently preventing it from being yielded to another
caller).
2023-05-12 17:04:32 +02:00
Dom Dwyer cdaf99268c
refactor: owned client in UpstreamSnapshot
Changes then UpstreamSnapshot to return owned clients, instead of
references to those clients.

This will allow the snapshot to have a 'static lifetime, suitable for
use across tasks.
2023-05-12 16:59:49 +02:00
Dom Dwyer dc27ae5fbf
refactor: eliminate impossible error
Because the number of candidate upstreams is checked to exceed the
number of desired data copies before starting the write loop, and
because the parallelism of the write loop matches the number of desired
data copies, it's not possible for any thread to observe an empty
snapshot.

This commit removes the unreachable error condition for clarity.
2023-05-12 16:59:49 +02:00
Dom Dwyer 465158e08e
test(router): replication prop/invariant fuzzing
Adds a property-based test of the RPC write handler's replication logic,
ensuring:

    1. If the number of healthy upstreams is 0, NoHealthyUpstreams is
       returned and no requests are attempted.

    2. Given N healthy upstreams (> 0) and a replication factor of R:
       if N < R, "not enough replicas" is returned and no requests are
       attempted.

    3. Upstreams that return an error are retried until the entire
       write succeeds or times out.

    4. Writes are replicated to R distinct upstreams successfully, or
       an error is returned.

    5. One an upstream write is ack'd as successful, it is never
       requested again.

    6. An upstream reporting as unhealthy at the start of the write is
       never requested (excluding probe requests).

These properties describe a mixture of invariants (don't replicate your
two copies of a write to the same ingester) and expected behaviour of
the replication logic (optimisations like "don't try writes when you
already know they'll fail").

This passes for the single-threaded replication logic used at the time
of this commit, and will be used to validate correctness of a concurrent
replication implementation - a concurrent approach should uphold these
properties the same way a single-threaded implementation does.
2023-05-12 16:59:48 +02:00
Dom Dwyer cf622c1b91
test: MockWriteClient tracks ACK response count
Changes the MockWriteClient to track how many success responses it has
returned in response to a write request.
2023-05-12 16:59:48 +02:00
Dom Dwyer ac656ab1f9
refactor: clearer NoHealthyUpstreams error name
Renames NoUpstreams -> NoHealthyUpstreams as it's confusing because we
also have "not enough replicas" which could be no upstreams? This has a
slightly clearer meaning.
2023-05-12 16:59:47 +02:00
Dom Dwyer 8e74f0a568
test: proptest upstream snapshot cycles
Adds a proptest that ensures the set of upstream ingesters is cycled
over indefinitely, with each element yielded an equal number of times.
2023-05-12 16:59:44 +02:00
Dom 3f0e7745c2
Merge branch 'main' into dom/rpc-client-error-split 2023-05-09 14:41:12 +01:00
Dom Dwyer ab666ea5fa
refactor: owned ColumnsByName constructor only
Refactors the From<BtreeMap> impl that accepted a &str name for
ColumnsByName construction, instead allowing only the owned String, and
updating the test that makes use of it appropriately.
2023-05-09 14:55:03 +02:00
Carol (Nichols || Goulding) 23c0110b32
feat: Create newtypes for different partition templates
So that the different kinds aren't mixed up. Also extracts the logic
having to do with which template takes precedence onto the
PartitionTemplate type itself.
2023-05-09 14:55:02 +02:00
Carol (Nichols || Goulding) ebceabb608
feat: Add an assertion for the new invariant that namespace partition templates never change 2023-05-09 14:55:02 +02:00
Carol (Nichols || Goulding) 70dca8f60b
fix: Pass the NamespaceSchema through the dml write traits 2023-05-09 14:55:02 +02:00
Carol (Nichols || Goulding) c062d2d890
fix: Change NamespaceResolver to return the whole cached NamespaceSchema
Rather than picking out the ID and partition template to be passed
around separately
2023-05-09 14:55:01 +02:00
Carol (Nichols || Goulding) e8a480f5f6
fix: Give up ownership of Column when adding to a table
To enable reuse of existing allocations rather than borrowing, creating
new allocations, then dropping them.
2023-05-09 14:55:00 +02:00
Carol (Nichols || Goulding) e8655af52d
fix: Change ColumnsByName::new to enable taking ownership if caller wants to give it 2023-05-09 14:55:00 +02:00
Carol (Nichols || Goulding) cc41216382
fix: Undo the addition of a TableInfo type; store partition_template on TableSchema 2023-05-09 14:54:59 +02:00
Carol (Nichols || Goulding) 596673d515
refactor: Create a new ColumnsByName type to abstract over TableSchema columns
And allow usage of just the columns when that's all that's needed
without leaking the BTreeMap implementation detail everywhere
2023-05-09 14:54:58 +02:00
Carol (Nichols || Goulding) 1f1dcc947d
fix: Don't change how the compactor gets the table schema 2023-05-09 14:54:58 +02:00
Carol (Nichols || Goulding) 58d9c40ffd
feat: If namespace or table partition templates are specified, use those 2023-05-09 14:54:57 +02:00
Carol (Nichols || Goulding) c1a8408572
fix: Consolidate the default partition template; remove --partition-key-pattern CLI option 2023-05-09 14:54:57 +02:00
Carol (Nichols || Goulding) 2aa8713d1d
fix: Remove partition TemplatePart::Table; partitioning is already per-table 2023-05-09 14:54:57 +02:00
Dom Dwyer 6aa657a649
refactor(router): separate RPC client error types
This commit splits out the RPC-request-centric errors in RpcWriteError
into their own RpcWriteClientError type.

This improves the separation of concerns - an RpcWriteError comes from
the RPC write handler, whereas an RpcWriteClientError comes from an
underlying client. It's definitely less confusing!
2023-05-09 14:33:56 +02:00
Carol (Nichols || Goulding) 3d5df5574a
fix: Remove vestiges of shards 2023-05-08 20:24:36 -04:00
Carol (Nichols || Goulding) b0959667d5
fix: Move topic and query pool within iox catalog (#7734)
Still insert them into the database and associate them with namespaces,
but don't ever query them back out.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-04 13:45:56 +00:00
Dom Dwyer c76129a7e8
refactor: fix lint failures 2023-04-27 13:19:06 +02:00
Dom be3256d1a7
Merge branch 'main' into dom/proptest-cache 2023-04-26 14:55:58 +01:00
Martin Hilton 4b24c988ad
feat(service_grpc_flight): JDBC compatible Handshake (#7660)
* refactor(authz): move extract_header_token into authz

Move the extract_header_token method into the authz package so that
it can be shared by the query path. The method is renamed to reflect
the fact that it can now also extract a token from gRPC metadata.

The extract_token function is now a little more generic to allow
it to be used with HTTP header values and gRPC metadata values.

* feat(service_grpc_flight): JDBC compatible Handshake

While testing some JDBC based clients we found that some, Tableau
in this case,  cannot be configured with authoriztion tokens. In
these cases we need to be able to support username/password. The
approach taken is to ignore the username and make the token the
password. This is the same approach being taken throughout the
product.

To facilitate this the Flight RPC Handshake command has been extended
to look for Basic authorization credentials and respond with the
appropriate Bearer authorization header.

While adding end-to-end tests the subprocess commands were causing
a deadlock. These have been changed to using the tonic::process
module.

There are also some small changes to the JDBC test application where
the hardcoded values were clashing with the authorization parameters.

* fix: lint

* chore: apply suggestions from code review

Co-authored-by: Andrew Lamb <alamb@influxdata.com>

* chore: review suggestion

---------

Co-authored-by: Andrew Lamb <alamb@influxdata.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-04-26 13:52:49 +00:00
Dom Dwyer 9cc58eb4e4
test: property test namespace schema merging
This commit adds a randomised property test, that compares the results
of the new namespace cache schema merging (#7555) with a known-good
stdlib HashSet union (the cache implementation is effectively a more
specialised set union operation).

This property test also validates the "last writer wins" semantics for
other, non-schema data within the namespace.

Additionally the ChangeSet values returned over a pair of updates are
asserted to reflect the actual values added to the cache (but not each
call individually) to ensure accurate metrics are reported.
2023-04-26 15:45:54 +02:00
Fraser Savage ffe4747cf2
fix(router): Fix new_columns calculation for namespace cache table merges
This commit adds logic to ensure that all pre-existing columns are
counted when no merge takes place and a test covering that.
2023-04-26 14:00:10 +01:00
Fraser Savage d9111e2a1a
Merge branch 'main' into savage/additive-namespace-schema-caching 2023-04-26 12:30:52 +01:00
Fraser Savage 2921a79ac3
refactor(router): Use sum to count new_columns instead of fold
Co-authored-by: Dom <dom@itsallbroken.com>
2023-04-26 12:21:45 +01:00
Fraser Savage 41ee990d68
fix(router): Re-introduce cache put metric insert/update attribute 2023-04-26 12:04:43 +01:00
Fraser Savage c837a6e8dc
docs(router): Explicitly document use of get() and insert() for schema merge
Co-authored-by: Dom <dom@itsallbroken.com>
2023-04-26 11:55:55 +01:00
dependabot[bot] 09d6b4ae50
chore(deps): Bump tokio-stream from 0.1.12 to 0.1.13 (#7666)
Bumps [tokio-stream](https://github.com/tokio-rs/tokio) from 0.1.12 to 0.1.13.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-stream-0.1.12...tokio-stream-0.1.13)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dom <dom@itsallbroken.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-04-26 09:31:04 +00:00