-
Notifications
You must be signed in to change notification settings - Fork 625
chore: add tracing instrumentation to mem_wal module #6430
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
Open
hamersaw
wants to merge
1
commit into
lance-format:main
Choose a base branch
from
hamersaw:chore/instrument-mem-wal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ use tokio::sync::{RwLock, mpsc}; | |
| use tokio::task::JoinHandle; | ||
| use tokio::time::{Interval, interval_at}; | ||
| use tokio_util::sync::CancellationToken; | ||
| use tracing::instrument; | ||
| use uuid::Uuid; | ||
|
|
||
| pub use super::index::{ | ||
|
|
@@ -942,6 +943,7 @@ impl ShardWriter { | |
| /// | ||
| /// The `base_path` should come from `ObjectStore::from_uri()` to ensure | ||
| /// WAL files are written inside the dataset directory. | ||
| #[instrument(level = "info", skip(object_store, base_path, base_uri, schema, index_configs), fields(shard_id = %config.shard_id, index_count = index_configs.len()))] | ||
| pub async fn open( | ||
| object_store: Arc<ObjectStore>, | ||
| base_path: Path, | ||
|
|
@@ -1102,6 +1104,7 @@ impl ShardWriter { | |
| /// Fencing is detected lazily during WAL flush via atomic writes. | ||
| /// If another writer has taken over, the WAL flush will fail with | ||
| /// `AlreadyExists`, indicating this writer has been fenced. | ||
| #[instrument(level = "info", skip(self, batches), fields(batch_count = batches.len(), shard_id = %self.config.shard_id))] | ||
| pub async fn put(&self, batches: Vec<RecordBatch>) -> Result<WriteResult> { | ||
| if batches.is_empty() { | ||
| return Err(Error::invalid_input("Cannot write empty batch list")); | ||
|
|
@@ -1257,6 +1260,7 @@ impl ShardWriter { | |
| /// Close the writer gracefully. | ||
| /// | ||
| /// Flushes pending data and shuts down background tasks. | ||
| #[instrument(level = "info", skip(self), fields(shard_id = %self.config.shard_id, epoch = self.epoch))] | ||
| pub async fn close(self) -> Result<()> { | ||
|
Comment on lines
946
to
1264
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we want to give these traces names like sw_open, sw_put, sw_close? A lot of tracing tools will just give the span name unless you drill down and open/put/close are going to feel like regularly filesystem calls. |
||
| info!("Closing ShardWriter for shard {}", self.config.shard_id); | ||
|
|
||
|
|
@@ -1373,6 +1377,11 @@ impl WalFlushHandler { | |
| /// * `batch_store` - The batch store to flush from | ||
| /// * `indexes` - Optional indexes to update in parallel with WAL I/O | ||
| /// * `end_batch_position` - End batch ID (exclusive). Flush batches in (max_flushed, end_batch_position). | ||
| #[instrument( | ||
| level = "debug", | ||
| skip(self, batch_store, indexes), | ||
| fields(end_batch_position) | ||
| )] | ||
| async fn do_flush( | ||
| &self, | ||
| batch_store: Arc<BatchStore>, | ||
|
|
@@ -1486,6 +1495,7 @@ impl MemTableFlushHandler { | |
| /// This method waits for the WAL flush to complete (sent at freeze time), | ||
| /// then flushes to Lance storage. The WAL flush is already queued by | ||
| /// freeze_memtable to ensure strict ordering of WAL entries. | ||
| #[instrument(level = "info", skip(self, memtable), fields(generation = memtable.generation(), row_count = memtable.row_count()))] | ||
| async fn flush_memtable( | ||
| &mut self, | ||
| memtable: Arc<MemTable>, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice to generate something similar to the
plan_runevents that we have on the normal scanner (lance/rust/lance-datafusion/src/exec.rs
Line 545 in 6112a34