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 writtenIntermediateBytes metric to capture correct intermediate w… #21626

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

jaystarshot
Copy link
Member

@jaystarshot jaystarshot commented Jan 4, 2024

The writtenIntermediateBytes metric was noop because plan.isOutputTableWriterFragment() will always be true and wrong metrics were updated when there are temporary table writes currently since there was a bug in plan Fragmenter where it would pass temporary tables' writer operator as output table writes hence populating the wrong metric.
code link.

Fixed by adding the information (whether temporary) to the tablewriterNode and filtering out those

Impact

Fixed writtenIntermediateBytes metric. Users of CTE and Exchange materialization should now be able to see the correct populated metric

Test Plan

Production tested

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

General Changes
* Fixed writtenIntermediateBytes metric by ensuring its correct population through temporary table writers.

@jaystarshot jaystarshot force-pushed the cte-written-metrics branch 4 times, most recently from 47e8b39 to ed8638a Compare January 4, 2024 02:29
@jaystarshot jaystarshot requested a review from arhimondr January 4, 2024 07:39
@jaystarshot jaystarshot marked this pull request as ready for review January 4, 2024 07:39
@jaystarshot jaystarshot requested review from shrinidhijoshi and a team as code owners January 4, 2024 07:39
@jaystarshot jaystarshot requested a review from presto-oss January 4, 2024 07:39
@tdcmeehan tdcmeehan self-assigned this Jan 22, 2024
@@ -81,7 +81,7 @@ public SubPlan createSubPlans(Session session, Plan plan, boolean forceSingleNod
sqlParser,
idAllocator,
variableAllocator,
getTableWriterNodeIds(plan.getRoot()));
Copy link
Member Author

Choose a reason for hiding this comment

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

Main fix

@@ -245,6 +245,16 @@ public static Set<PlanNodeId> getTableWriterNodeIds(PlanNode plan)
.collect(toImmutableSet());
}

public static Set<PlanNodeId> getOutputTableWriterNodeIds(PlanNode plan)
Copy link
Member Author

Choose a reason for hiding this comment

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

Clone of the above function with a filter on the temporaryTableWriters

@@ -25,6 +25,7 @@

public class CteUtils
{
public static final String TEMPORARY_TABLE_SCHEMA = "temporary_table_schema";
Copy link
Contributor

Choose a reason for hiding this comment

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

where is this used?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed thanks

Copy link
Contributor

@feilong-liu feilong-liu left a comment

Choose a reason for hiding this comment

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

LGTM. I also briefly checked the code to make sure that the "outputTableWriterFragment" variable is only used for accounting purpose.

Can you maybe add a comment for the "outputTableWriterFragment" member in "PlanFragment" class stating that this is true only for final output fragment, but not for temporary table writer?

@jaystarshot
Copy link
Member Author

cc: @tdcmeehan

@steveburnett
Copy link
Contributor

Nit (commenting because it's not enough for a review): in Description, suggest deleting the lines in the release note entry after the line Fixed writtenIntermediateBytes metric...

@jaystarshot jaystarshot merged commit 89f95d9 into prestodb:master Jan 30, 2024
56 checks passed
@steveburnett
Copy link
Contributor

Nit (commenting because it's not enough for a review): in Description, suggest deleting the lines in the release note entry after the line Fixed writtenIntermediateBytes metric...

Thanks!

@wanglinsong wanglinsong mentioned this pull request Feb 12, 2024
64 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants