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

Fix plan view for DbHits over 32 bit integer max #1938

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/shared/services/bolt/boltMappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,26 @@ export function extractPlan(result: any, calculateTotalDbHits = false) {
if (result.summary && (result.summary.plan || result.summary.profile)) {
const rawPlan = result.summary.profile || result.summary.plan
const boltPlanToRESTPlanShared = (plan: any) => {
// `dbHits` and `Rows` are available both on the plan object and on plan.arguments
// there is a bug numbers that are larger than signed 32 bit integers overflow and become negative
// if we find that the value on arguments is available and above the max signed 32 bit integer
// we do a workaround and use that instead. Otherwise we prefer the original value

// sidenote: It is called "dbHits" in the plan object and "DbHits" in plan.arguments,
// it's not a typo, just a little confusing
const SIGNED_INT32_MAX = 2147483647
return {
operatorType: plan.operatorType,
DbHits: plan.dbHits,
Rows: plan.rows,
DbHits:
plan?.arguments?.DbHits?.toNumber() > SIGNED_INT32_MAX
? plan?.arguments?.DbHits?.toNumber()
: plan.dbHits,

Rows:
plan?.arguments?.Rows?.toNumber() > SIGNED_INT32_MAX
? plan?.arguments?.Rows?.toNumber()
: plan.rows,

identifiers: plan.identifiers,
children: plan.children.map((_: any) => ({
...transformPlanArguments(_.arguments),
Expand Down