-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(logs): Add better loading state for flex time strategy #102104
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -584,6 +584,27 @@ export function useInfiniteLogsQuery({ | |
|
|
||
| const {virtualStreamedTimestamp} = useVirtualStreaming({data, highFidelity}); | ||
|
|
||
| // Due to the way we prune empty pages, we cannot simply compute the sum of bytes scanned | ||
| // for all pages as most empty pages would have been evicted already. | ||
| // | ||
| // Instead, we watch the last page loaded, and keep a running sum that is reset when | ||
| // the last page is falsey which corresponds to a query change. | ||
| const [totalBytesScanned, setTotalBytesScanned] = useState(0); | ||
| const lastPage = data?.pages?.[data?.pages?.length - 1]; | ||
| useEffect(() => { | ||
| if (!lastPage) { | ||
| setTotalBytesScanned(0); | ||
| return; | ||
| } | ||
|
|
||
| const bytesScanned = lastPage[0].meta?.bytesScanned; | ||
| if (!defined(bytesScanned)) { | ||
| return; | ||
| } | ||
|
|
||
| setTotalBytesScanned(previousBytesScanned => previousBytesScanned + bytesScanned); | ||
| }, [lastPage]); | ||
|
Comment on lines
+596
to
+606
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. Bug: The 🔍 Detailed AnalysisThe 💡 Suggested FixModify the 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
||
| const _data = useMemo(() => { | ||
| const usedRowIds = new Set(); | ||
| const filteredData = | ||
|
|
@@ -694,6 +715,7 @@ export function useInfiniteLogsQuery({ | |
| isFetchingNextPage: _data.length > 0 && (waitingToAutoFetch || isFetchingNextPage), | ||
| isFetchingPreviousPage, | ||
| lastPageLength, | ||
| bytesScanned: totalBytesScanned, | ||
| }; | ||
| } | ||
|
|
||
|
|
||
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.
Bug: Stale Dependency Causes Duplicate Scans
The
useEffectfortotalBytesScanneduseslastPageas a dependency. Its reference changes on re-renders even when the underlying page data is the same, causing the effect to re-run. This adds the same page'sbytesScannedmultiple times, leading to an inflated and incorrect total displayed to users.