Commit Graph

226 Commits (table-index-cache_oss-port)

Author SHA1 Message Date
wayne c91d556edf feat: introduce TableIndexSnapshot, TableIndex, and TableIndexCache
This commit brings over `TableIndexCache` support from the enterprise
repo. It primarily focuses on efficient automatic cleanup of expired
gen1 parquet files based on retention policies and hard deletes. It

- Adds purge operations for tables and retention period expired data.
- Integrates `TableIndexCache` into `PersistedFiles` for the sake of
  parquet data deletion handling in `ObjectDeleter` impl.
- Introduces a new background loop for applying data retention polices
  with a 30m default interval.
- Includes comprehensive test coverage for cache operations, concurrent
  access, persisted snapshot to table index snapshot splits, purge
  scenario, object store path parsing, etc.

\## New Types

- `influxdb3_write::table_index::TableIndex`:
  - A new trait that tracks gen1 parquet file metadata on a per-table
    basis.

- `influxdb3_write::table_index::TableIndexSnapshot`:
  - An incremental snapshot of added and removed gen1 parquet files.
  - Created by splitting a `PersistedSnapshot` (ie a whole-database
    snapshot) into individual table snapshots.
  - Uses the existing snapshot sequence number.
  - Removed from object store after successful aggregation into
    `CoreTableIndex`.

- `influxdb3_write::table_index::CoreTableIndex`:
  - Implements of `TableIndex` trait.
  - Aggregation of `TableIndexSnapshot`s.
  - Not versioned -- assumes that we will migrate away from Parquet in
    favor of PachaTree in the medium/long term.

- `influxdb3_write::table_index_cache::TableIndexCache`
  - LRU cache
  - Configurable via CLI parameters:
    - Concurrency of object store operations.
    - Maximum number of `CachedTableIndex` to allow before evicting
      oldest entries.
  - Entrypoint for handling conversion of `PersistedSnapshot` to
    `TableIndexSnapshot` to `TableIndex`

- `influxdb3_write::table_index_cache::CachedTableIndex`
  - Implements `TableIndex` trait
  - Accessing ParquetFile or TableIndex causes last access time to be
    updated.
  - Stores a mutable `CoreTableIndex` as implementation detail.

- `influxdb3_write::retention_period_handler::RetentionPeriodHandler`
  - Runs a top-level background task that periodically applies retention
    periods to gen1 files via the `TableIndexCache`.
  - Configurable via CLI parameters:
    - Retention period handling interval

\## Updated Types

- `influxdb3_write::persisted_files::PersistedFiles`
  - Now holds an `Arc` reference to `TableIndexCache`
  - Uses its `TableIndexCache` to apply hard deletion to all historical
    gen1 files and update associated `CoreTableIndex` in the object
    store.
2025-07-25 14:37:31 -08:00
praveen-influx 2392878850
feat: additional logging in the write path to capture db and ip (#26616)
* feat: additional logging in the write path to capture db and ip

closes: https://github.com/influxdata/influxdb_pro/issues/519

* refactor: address PR feedback
2025-07-18 16:40:12 +01:00
Michael Gattozzi 015933f5c1
fix: URL encoded table name failures (#26586)
This commit fixes queries that could come back as failures due to
improperly quoted table names in queries. It also fixes issues in
Enterprise where compaction would fail due to double escaped names.

The fix is relatively simple:

- Use the parse not from function for the Path type in the object_store
  crate
- Quote escape table names in queries
2025-07-14 16:05:53 -04:00
Stuart Carnie d396921aa0
chore: Update to Rust 1.88 (#26567)
* chore: Update to Rust 1.88

* chore: Fixes missed by Claude
2025-06-27 07:38:45 +10:00
praveen-influx 3fe9aa5802
chore: fix failing test (#26558) 2025-06-24 13:53:02 +01:00
Stuart Carnie 01c907de0e
fix: handle corrupt WAL files during replay without panic (#26556)
Add bounds checking to prevent panic when WAL files are empty or
truncated. Introduces `--wal-replay-fail-on-error` flag to control
behavior when encountering corrupt WAL files during replay.

- Add WalFileTooSmall error for files missing required header bytes
- Validate minimum file size (12 bytes) before attempting
  deserialization
- Make WAL replay configurable: skip corrupt files by default or fail
  on error
- Add comprehensive tests for empty, truncated, and header-only files

Closes #26549
2025-06-24 12:57:40 +01:00
Stuart Carnie 4c8283dd6f
feat: Hard delete database and table (#26553)
* feat: Hard delete database and table

* feat: Enable hard-deletion in OSS
2025-06-24 12:36:23 +01:00
wayne 8e0688912f
feat: allow users to specify lookback duration for PersistedFiles buffer (#26528) 2025-06-18 09:41:05 -06:00
praveen-influx 6bb0401c69
chore: porting some utilities that were created in pro (#26529)
- `AbortableTaskRunner` and it's friends in influxdb3_shutdown
- `ProcessUuidWrapper` and it's friends in influxdb3_process
- change sleep time in test

They're not used currently in any of the core code, but helps when
sync'ing core back to enterprise
2025-06-17 17:24:41 +01:00
Trevor Hilton ac75103e52
feat: track gen1 duration in catalog (#26508)
* Tracks the generation duration configuration for the write buffer
  in the catalog.
* Still leverages the CLI arguments to set it on initial start up of
  the server.
* Exposes a system table on the _internal database to view the configured
  generation durations.
* This doesn't change how the gen1 duration is used by the write buffer.
* Adds several tests to check things work as intended.
2025-06-10 15:52:01 -04:00
wayne fa646a6f64
chore: backport retention period implementation from enterprise (#26501)
Includes two main components:

* Removal of expired data from `PersistedFiles`.
* Modified `ChunkFilter` that precisely excludes expired data from query
  results even if the expired data hasn't been removed from the object
  store yet.

---------

Co-authored-by: Michael Gattozzi <mgattozzi@influxdata.com>
2025-06-06 18:07:34 -06:00
wayne d499c59bb1
chore: backport hard delete time in Catalog and deleter service from enterprise (#26500)
* Merge pull request #881 from influxdata/sgc/26156/hard_delete_table_apis

feat: Catalog tracks hard delete time; implement deleter service

* Merge pull request #885 from influxdata/sgc/26156/pr_881_followup

chore: PR #881 followup

---------

Co-authored-by: Stuart Carnie <stuart.carnie@gmail.com>
2025-06-05 14:41:01 -06:00
praveen-influx e392a3803e
chore: fix flakey test in write buffer (#26494) 2025-06-03 22:27:21 +01:00
praveen-influx a67b50dac5
feat: add concurrency limit for WAL replay (#26483)
WAL replay currently loads _all_ WAL files concurrently running into
OOM. This commit adds a CLI parameter `--wal-replay-concurrency-limit`
that would allow the user to set a lower limit and run WAL replay again.

closes: https://github.com/influxdata/influxdb/issues/26481
2025-06-03 16:34:31 +01:00
wayne acdb8f650e
feat: add retention period to catalog (#26479)
* feat: add retention period to catalog

* fix: handle humantime parsing error properly

* refactor: use new iox_http_util types

---------

Co-authored-by: Michael Gattozzi <mgattozzi@influxdata.com>
2025-06-02 18:36:04 -06:00
Trevor Hilton 4dc61df77f
chore: update to latest influxdb3_core (#26429)
* chore: update to latest core

* chore: allow CDLA permissive 2 license

* chore: update insta snapshot for new internal df tables

* test: update assertion in flightsql test

* fix: object store size hinting workaround in clap_blocks

Applied a workaround from upstream to strip size hinting from the object
store get request options. See:

https://github.com/influxdata/influxdb_iox/issues/13771

* fix: query_executor tests use object store size hinting workaround

* fix: insta snapshot test for show system summary command

* chore: update windows- crates for advisories

* chore: update to latest sha on influxdb3_core branch

* chore: update to latest influxdb3_core rev

* refactor: pr feedback

* refactor: do not use object store size hint layer

Instead of using the ObjectStoreStripSizeHint layer, just provide the
configuration to datafusion to disable the use of size hinting from
iox_query.

This is used in IOx and not relevant to Monolith.

* fix: use parquet cache for get_opts requests

* test: that the parquet cache is being hit from write buffer
2025-05-26 14:11:06 -04:00
Stuart Carnie c5ed113c5b
chore: Update rust toolchain to 1.87.0 (#26456)
Changes were due to a number of clippy improvements
2025-05-26 09:22:32 -04:00
Stuart Carnie 1abbb525db
fix: Ensure series key metadata is persisted to Parquet snapshots (#26449)
* chore: Ensure Parquet sort key is serialised with snapshots

* chore: PR feedback, rename state variable to match intent

* chore: Use `Default` trait to implement `TableBuffer::new`

* chore: Fix change in file size with extra metadata

* chore: Add rustdoc for `sort_key` field
2025-05-26 09:27:07 +10:00
Trevor Hilton 760c89873d
fix: add key variant back to wal to fix bitcode deserialization (#26453) 2025-05-23 13:04:18 -04:00
Trevor Hilton 6e9446a8bb
test: reproduce problem with NULL backfill of omitted tag cols (#26448)
* test: reproduce problem with NULL backfill of omitted tag cols

* fix: do not fill tag columns with empty string on persist

* chore: clippy
2025-05-22 12:31:53 -04:00
Trevor Hilton d1c10f4b29
fix: backfill new tags with NULL instead of empty string (#26446)
* fix: backfill new tags with NULL instead of empty string

* refactor: use helper for append_null

* test: add a test to check null back/forward fill
2025-05-21 17:23:51 -04:00
Trevor Hilton 4a917c5a9f
refactor: remove variants for unused series key type (#26443)
* refactor: remove unused Key type from write buffer

The write buffer had a Key variant for handling the experimental v3
write API that was phased out and removed from an earlier iteration
of influxdb3.

* refactor: remove key column type from last cache
2025-05-21 15:45:23 -04:00
Trevor Hilton 5d7cb88f87
feat: track catalog retries as prometheus metric (#26251)
Adds a metric to track total retried catalog operations due to the catalog
being updated elsewhere. Includes a test to check the counter increments
on basic catalog operations.
2025-04-11 15:24:10 -04:00
praveen-influx 1983818e36
feat: porting token work from enterprise (#26239)
* feat: generate persistable admin token

- this commit allows admin token creation using `influxdb3 create token
  --admin` and also allows regeneration of admin token by `influxdb3
  create token --admin --regenerate`
- `influxdb3_authz` crate hosts all low level token types and behaviour
- catalog log and snapshot types updated to use the token repo
- tests that relied on auth have been updated to use the new token
  generation mechanism and new admin token generation/regeneration tests
  have been added

* feat: list admin tokens

- allows listing admin tokens
- uses _internal db for token system table
- mostly test fixes due to _internal db
2025-04-09 16:31:59 +01:00
Trevor Hilton 7d95c48ecf
fix: empty writes do not corrupt wal (#26223)
* test: reproducer for empty write issue

* fix: empty writes do not corrupt wal
2025-04-05 16:44:34 -04:00
praveen-influx e653f736d9
chore: couple of updates to fix cargo audit job (#26209)
* chore: couple of updates to fix cargo audit job

- remove humantime ignore in deny.toml
- update pyo3 to use 0.24.1 (https://rustsec.org/advisories/RUSTSEC-2025-0020.html)

* chore: moved pyo3 version to root cargo.toml
2025-04-01 15:36:01 +01:00
Trevor Hilton 9401137825
feat: handle graceful shutdown (#26197)
* feat: add influxdb3_shutdown crate

provides basic wait methods for unix/windows OS's

* feat: graceful shutdown

* docs: add rust docs and test to influxdb3_shutdown

Added rustdoc comments to types and methods in the influxdb3_shutdown
crate as well as a test that shows the ordering of a shutdown.
2025-03-31 09:58:40 -04:00
Michael Gattozzi b792f70960
fix: maybe fix flakiness for parquet cache test (#26159)
This adds a sleep so that the parquet cache has a little bit of time to
populate before we make another request to the query buffer. Sometimes
it does not populate and so we have a race condition where the new
request comes in and actually goes to object store. This is fine in
practice because it would also take time to fill the cache in production
as well. I haven't really seen the test fail since adding this, but
triggering it in the first place is really hard and in practice does not
happen all that often.
2025-03-18 11:31:30 -04:00
Trevor Hilton 863a6d0b4a
feat: ack catalog update broadcast (#26118)
This creates a CatalogUpdateMessage type that is used to send
CatalogUpdates; this type performs the send on the oneshot Sender so
that the consumer of the message does not need to do so.

Subscribers to the catalog get a CatalogSubscription, which uses the
CatalogUpdateMessage type to ACK the message broadcast from the catalog.

This means that catalog message broadcast can fail, but this commit does
not provide any means of rolling back a catalog update.

A test was added to check that it works.
2025-03-17 20:20:07 -04:00
Jamie Strandboge ba7e6c6986
feat(python): update to python-build-standalone 3.13.2 (#26125)
* feat(python): update to python-build-standalone 3.13.2

References:
- https://github.com/influxdata/influxdb/issues/26044

* fix: update fetch-python-standalone.bash to properly set 'executable'

* fix: use PYO3_CONFIG_FILE to find PYTHONHOME.

* fix: add comment about PYO3_CONFIG_FILE.

* fix: remove ensure_pyo3().

* fix: add some sleep so catalog is updated.

---------

Co-authored-by: Jackson Newhouse <jnewhouse@influxdata.com>
2025-03-14 14:44:05 -05:00
Trevor Hilton 0c8d17fb89
refactor: use repositories in catalog (#26135)
* refactor: use repository in catalog

The catalog was refactored to use identifiers on everything, and store
everything in a consistent structure. This structure makes use of the
`Repository` type that holds a `SerdeVecMap` of Id to Resource, along
with the next Id, and a bi-map of Id to resource name.

The `Repository` type is used at each level of the catalog where a
resource is stored.

This simplified repeated logic for snapshot'ing, insert and update of
resources in the catalog, as well as accessor methods for getting by id
or name, and mapping names to ids and vice-versa.

In addition, the process for catalog batch verification and permit was
altered so that the permit process induces a retry if the catalog was
updated while the catalog batch function was producing the batch, i.e, if
the catalog sequence incremented while the caller was waiting for a permit.
This eliminated the need for verifying the catalog batch after it had been
generated, and allows for a single path to apply a catalog batch after it
has been persisted to object store.

This assumes that the generation of the catalog batch implies validity.

Irelevant tests were removed.

Last and Distinct cache's now rely more heavily on Ids, though the proc-
essing engine still needs to switch over to use Ids for starting/stopping
triggers.
2025-03-13 22:42:18 -04:00
Michael Gattozzi 00aa90fe6f
feat: Add PeristedSnapshotVersion for snapshots (#26117)
Continuing our work of creating versioned files before Beta, this commit
adds a PersistedSnapshotVersion which is used at the boundary of
serializing and deserializing so that we can easily upgrade to a newer
version and handle old versions without breaking things for users.
2025-03-12 13:21:54 -04:00
Trevor Hilton b6cb6dd51e
chore: back-port catalog debug log cleanup from enterprise (#26128)
* chore: back-port debug log cleanup for catalog

* chore: back-port debug log cleanup for wal

* chore: back-port debug log cleanup for write
2025-03-12 13:20:21 -04:00
Trevor Hilton 503819468e
feat: catalog checkpoints (#26126) 2025-03-11 18:20:36 -04:00
Trevor Hilton 72dc4458fd
chore: backport changes to catalog from enterprise (#26116)
* chore: backport changes to influxdb3_catalog crate

* chore: backport changes to influxdb3_cache crate

* chore: backport changes to influxdb3_write crate

* chore: backport changes to influxdb3_proc_eng crate

* chore: backport influxdb3 crate changes for catalog

* chore: backport changes to influxdb3_id crate

* chore: backport changes to influxdb3_wal crate

* chore: backport changes to influxdb3_clap_blocks crate

* chore: backport changes to influxdb3_client crate

* chore: backport influxdb3_server crate changes

* chore: fix after full backport

* fix: ordering of catalog broadcast
2025-03-11 12:11:51 -04:00
Jackson Newhouse 5fa417c3f0
feat: remove system-py (#26087)
* feat: remove system-py

* chore: allow Apache-2.0 WITH LLVM-exception license.
2025-03-10 11:10:33 -07:00
Michael Gattozzi 329ef2f11b
feat: allow new tags in schema again (#26108)
This commit restores the old behavior we had where new tags can be added
to a schema. To do this we made tags nullable and brings us in line with
our other products. These changes were made in this PR:

https://github.com/influxdata/influxdb3_core/pull/41.

Changes to accomplish this new behavior were:

- Queries now do not return an empty string for null tags instead they
  are returned as null, or in many formats not at all.
- References to v1 for parsing and validating lines were removed as we
  only have one path for doing so these days shared amongst all the
  write_lp endpoints.
- We fixed failing tests that expected us to not be able to have new
  tags or depended on that functionality indirectly
- Tests had their snapshot files updated to reflect that tags are
  nullable by default
- Behavior for making a schema and checking whether a column can be null
  were updated in a separate repo and integrated here
- The series_key is updated whenever we get a new tag added to the
  schema
- New tests were added to show that you can add a new tag and that the
  series key is updated as part of that

With the above changes we can now allow tags to be added again by users
like they would expect, especially with v1 and v2 apis and Telegraf
plugins.
2025-03-06 13:59:15 -05:00
praveen-influx c724e06e3f
feat: query path instrumentation (#26106)
- spans added for buffer, parquet chunks along with number of files that
  are already in parquet cache along with the sql
2025-03-06 17:24:34 +00:00
Michael Gattozzi 1f72bfcc33
feat: Update to Rust 1.85 and 2024 Edition (#26046) 2025-02-20 14:58:07 -05:00
Trevor Hilton 9646691d96
fix: serialize distinct cache in catalog (#25990)
The distinct cache info for tables was not serialized in the catalog.
This fixes it, but also updates the catalog serialization to use the
snapshot type serialization from the Catalog type all the way down.

The Eq and PartialEq impls were removed from Catalog and InnerCatalog
as they were only used in tests, and wer replaced by pure insta snapshot
tests.

A test was added to check that the distinct cache serializes/deserializes
2025-02-11 11:04:31 -05:00
praveen-influx 5b2354c7ab
feat: port changes back to core from enterprise (#25975)
Includes 2 main changes
- update the function signature for `cache_parquet_files`
- bring in `Evict` variant for parquet `CacheRequest`
2025-02-05 22:22:04 +00:00
wayne 27653f5a76
fix: enable workspace lints on all crates, fix all lints (#25961) 2025-02-03 17:38:20 -07:00
wayne 0fffcc8c37
refactor: introduce influxdb3_types crate (#25946)
Partially fixes https://github.com/influxdata/influxdb/issues/24672

* move most HTTP req/resp types into `influxdb3_types` crate
* removes the use of locally-scoped request type structs from the `influxdb3_client` crate
* fix plugin dependency/package install bug
  * it looks like the `DELETE` http method was being used where `POST` was expected for `/api/v3/configure/plugin_environment/install_packages` and `/api/v3/configure/plugin_environment/install_requirements`
2025-02-03 11:28:47 -07:00
praveen-influx 911ba92ab4
feat: clear query buffer incrementally when snapshotting (#25948)
* feat: clear query buffer incrementally when snapshotting

This commit clears the query buffer incrementally as soon as a table's
data in buffer is written into parquet file and cached. Previously,
clearing the buffer happened at the end in the background

* refactor: only clear buffer after adding to persisted files

* refactor: rename function
2025-02-02 16:51:53 +00:00
Trevor Hilton 23b77946f4
refactor: remove buffer index and literal guarantee analysus in filter (#25949)
This removes the buffer index from the write buffer in core and lifts the
literal guarantee analysis from the ChunkFilter.
2025-01-31 14:43:10 -05:00
praveen-influx 56ca85ef8e
feat: introduce parquet caching in query path (#25937)
* feat: introduce parquet caching in query path

This commit scans the parquet files that will be used in query to check
if they can be cached. There are three conditions to satisfy,
  - not cached already
  - cache has enough space
  - file times overlap with the cache policy times

closes: https://github.com/influxdata/influxdb/issues/25906

* refactor: rename env var
2025-01-30 21:16:37 +00:00
wayne 05da40fa9b
fix: clarify table creation conflict error message (#25936)
Also include a basic CLI integration test to exemplify the new error message.
2025-01-30 13:08:35 -07:00
Jackson Newhouse 8840d99e9d
feat(processing_engine): integration with virtual environments. (#25895)
* feat(processing_engine): integration with virtual environments.

* feat: Initial scaffolding for environment managers (pip, pipx, uv).

* feat(processing_engine): CLI for package management, remove pipx support.

* feat(processing_engine): test installations in virtualenvs.

* feat(processing_engine): Automatically setup virtual environment on startup.
2025-01-28 15:30:17 -08:00
Michael Gattozzi b9a8adbe98
feat: persist snapshots in parallel (#25901)
This speeds up snapshot persistence by taking all of the persist jobs
and running them simultaneously on a JoinSet. With this we can speed
things up a bit by not waiting for each file to persist before the next
one can be persisted. Instead we now can run all the persisting at the
same time using the tokio runtime.

Closes #24658
2025-01-27 11:44:23 -05:00
Paul Dix d49276a7fb
feat: Refactor plugins to only require creating trigger (#25914)
This refactors plugins and triggers so that plugins no longer need to be "created". Since plugins exist in either the configured local directory or on the Github repo, a user now only needs to create a trigger and reference the plugin filename.

Closes #25876
2025-01-27 11:26:46 -05:00