Bug/datafusion query#236
Merged
thorrester merged 3 commits intomainfrom Mar 18, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #236 +/- ##
==========================================
+ Coverage 77.38% 77.97% +0.59%
==========================================
Files 19 19
Lines 336 336
==========================================
+ Hits 260 262 +2
+ Misses 76 74 -2
🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request
Short Summary
Fixes stale DataFusion query results caused by
SessionContextcaching file metadata after Delta Lake writes. After each write,update_datafusion_session()is now called to re-register the table provider with the latest Delta log state. Also refactorsObjectStoreconstruction to use a shared instance across the trace engine, summary engine, and control table — preventing divergent caching on cloud backends.Context
Root cause — stale session state after writes
DataFusion's
SessionContextcaches the Delta table's file metadata at registration time. Before this fix, each write would update the in-memoryDeltaTablereference but leave the session holding a stale snapshot of the Delta log. Subsequent queries would silently return results from the pre-write state.The fix calls
update_datafusion_session()after every write inTraceSpanDBEngine,TraceSummaryDBEngine, andControlTableEngine:Before:
After:
Shared
ObjectStorerefactorObjectStoreis now constructed once inTraceSpanDBEngineand passed down toTraceSummaryDBEngineandControlTableEnginerather than each engine constructing its own fromObjectStorageSettings. On cloud backends (GCS/S3), eachObjectStoreinstance has its own caching layer — separate instances could return divergent views of the same bucket. Using a shared instance ensures all engines see consistent state.TraceSpanServicenow exposesobject_store: ObjectStoreso callers (e.g.,setup.rs) can pass the same instance toTraceSummaryService.update_incrementalremoved from summary write pathtable_guard.update_incremental()was removed fromTraceSummaryDBEngine::write_summary(). This engine runs as a single-writer actor — no other process commits to its Delta table, so the in-memory state is always current. Callingupdate_incrementalbefore a write could corrupt theDeltaTablesnapshot in intermediate error states, producing stale reads until restart.Additional fixes:
ControlTableEngine::write_task_updatenow propagates unexpected delete errors instead of silently swallowing them (only "no data / empty table" errors are suppressed as expected on a new table)micros_to_datetimereplacedUtc.timestamp_opt(...).unwrap()withDateTime::from_timestamp_micros(...).ok_or(...)— returns a proper error on out-of-range timestamps instead of panickingextract_map_attributesinsummary.rsreplacesunwrap()calls with?-stylelet-elsereturns withwarn!loggingmax(0)to avoid negative durations on clock skewdebug_recent_tracesendpoint added atGET /trace/debug/recent— returns the last 10 traces from the past 24 hours (dev/debug aid)type: ignoreadded toset_tracer_providercall in Python tracing module to suppress mypy false positiveRegression tests added:
test_span_write_visibility_across_multiple_writes— verifies span writes are immediately visible across sequential writestest_summary_write_visibility_across_multiple_writes— same for summary writesscouter_dataframe/src/parquet/control/engine.rs&ObjectStoreinstead of&ObjectStorageSettings; propagate delete errors; error-returning Arrow helpers;debug_assertontask_namescouter_dataframe/src/parquet/tracing/engine.rsupdate_datafusion_session()after every write; pass sharedobject_storeto control enginescouter_dataframe/src/parquet/tracing/service.rsobject_storefield; addtest_span_write_visibility_across_multiple_writesscouter_dataframe/src/parquet/tracing/summary.rs&ObjectStore; removeupdate_incremental; fixmicros_to_datetime; replaceunwrapinextract_map_attributes; add visibility regression testscouter_server/src/api/routes/trace/route.rsdebug_recent_traceshandler and routescouter_server/src/api/setup.rstrace_service.object_storetoTraceSummaryServicepy-scouter/python/scouter/tracing/__init__.py# type: ignoreto suppress mypy false positivepy-scouter/examples/tracing/README.mdpy-scouter/examples/tracing/instrumentor_example.pyIs this a Breaking Change?
No. All public interfaces (
TraceSpanService,TraceSummaryService) retain compatible signatures internally. TheObjectStorerefactor is internal to the engine constructors. The new debug route is purely additive.