Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: reduce catalog locks when getting chunks #25896

Merged
merged 4 commits into from
Jan 22, 2025

Conversation

hiltontj
Copy link
Contributor

The main refactor was to change the ChunkContainer trait to use the DatabaseSchema and TableDefinition types directly in the signature, vs. their names; using their names led to an additional catalog lock and lookups for both entities, because there was already a catalog lock/lookup upstream in the QueryTable.

However, using the names in the ChunkContainer::get_table_chunks was convenient, specifically for tests, so I included a test helper trait in influxdb3_write::test_helpers called WriteBufferTester that provides convenience methods for getting record batches from a WriteBuffer implementation. Alongside the definition of WriteBufferTester is a blanket impl on that any T that implements WriteBuffer.

We have been implementing similar methods manually in several places when testing in Enterprise, so this should give us a unified implementation for that.

Some other house cleaning was included 🧹

  • Changed influxdb3_wal::TableDefinition to WalTableDefinition to reduce naming conflicts.
  • Renamed BufferFilter to ChunkFilter, and within that, BufferGuarantee was changed to HashedLiteralGuarantee
  • Reduced some lookups in the table_buffer code

@hiltontj hiltontj added the v3 label Jan 22, 2025
@hiltontj hiltontj requested a review from a team January 22, 2025 01:58
@hiltontj hiltontj self-assigned this Jan 22, 2025
The main refactor was to change the ChunkContainer trait to use the
DatabaseSchema and TableDefinition types directly in the signature, vs.
the names, which then required an additional catalog lock and lookups for
both entities. This was already handled upstream in the QueryTable, so
there was no need to do the lookups again.

This required the addition of a test helper in influxdb3_write::test_helpers
that provides convenience methods for getting record batches from the
WriteBuffer. We have been implementing such a method manually in several
places, so this is nice to have it unified. This provides a blanket impl
so that anything implementing WriteBuffer gets the method.

Some other house cleaning was included.
@hiltontj hiltontj force-pushed the hiltontj/simplify-query-buffer-traits branch from 4cc402a to 57d5ab9 Compare January 22, 2025 02:01
Copy link
Contributor

@praveen-influx praveen-influx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the whole, it looks good - the read lock I guess is held to lookup DatabaseSchema by name in order to create Database? - just wanted to confirm if that's the one you were referring to in PR comment.

@hiltontj
Copy link
Contributor Author

On the whole, it looks good - the read lock I guess is held to lookup DatabaseSchema by name in order to create Database? - just wanted to confirm if that's the one you were referring to in PR comment.

Yep, that is correct. I am referring to the read lock when calling Catalog::db_schema (or whichever related method it uses to get the Arc<DatabaseSchema>)

I am going to hold off on merging this for a bit as I reason through some downstream changes needed in enterprise (see https://github.com/influxdata/influxdb_pro/issues/451#issuecomment-2607704757). I need to make sure this doesn't break things for that work.

@hiltontj
Copy link
Contributor Author

I made some additional changes:

  • 51385c5 - cleans up the test helper code in influxdb3_write
  • 4e27a83 - retains the &[Expr] on ChunkFilter so it can be accessed by anything that needs it downstream, e.g., in enterprise.

Copy link
Contributor

@praveen-influx praveen-influx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hiltontj hiltontj merged commit 44ca7a4 into main Jan 22, 2025
13 checks passed
@hiltontj hiltontj deleted the hiltontj/simplify-query-buffer-traits branch January 22, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants