Skip to content

Fix pinot connector ignoring certain exceptions silently#25424

Closed
rhodo wants to merge 5 commits into
trinodb:masterfrom
rhodo:add_config_for_pinot_metadata_exception
Closed

Fix pinot connector ignoring certain exceptions silently#25424
rhodo wants to merge 5 commits into
trinodb:masterfrom
rhodo:add_config_for_pinot_metadata_exception

Conversation

@rhodo
Copy link
Copy Markdown

@rhodo rhodo commented Mar 26, 2025

Description

When making grpc requests towards pinot server, certain exceptions are carried back in response of metadata type, for example, query timeout exception, segment missing exception etc. Due to the fact that EndOfData() return too early pinot connector actually never has a chance to deserialize these exceptions, which means it may return empty or partial result instead of raising an exception. Fixing this by still allow payload of metadata response being inspected, and to optionally maintain backward compatibility, a config/session property knob is introduced to gate the new behavior.

To test this, I spinned up a pinot cluster with extremely small timeout pinot.server.query.executor.timeout=1 and let trino connect to it.

Before the fix, trino will silently return the empty result even underlying it hits timeout exception
Screenshot 2025-03-26 at 12 34 54 AM

with the pinot.grpc.query.enforce-metadata-exception=true set in pinot.properties in the pinot connector, timeout exception is raised to end user

Screenshot 2025-03-26 at 12 34 50 AM

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Mar 26, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@github-actions github-actions Bot added the pinot Pinot connector label Mar 26, 2025
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Mar 26, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Mar 26, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@rhodo rhodo changed the title Fix pinot connector ignoring the grpc certain request's exception silently Fix pinot connector ignoring certain exceptions silently Mar 26, 2025
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Mar 26, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

String responseType = response.getMetadataMap().get(MetadataKeys.RESPONSE_TYPE);
if (responseType.equals(ResponseType.METADATA)) {
if (responseType.equals(ResponseType.METADATA)
&& !PinotSessionProperties.isGrpcQueryEnforceMetadataException(session)) {
Copy link
Copy Markdown
Author

@rhodo rhodo Mar 26, 2025

Choose a reason for hiding this comment

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

The idea is that instead of using metadata type to signal the end of data, we rely on response iterator check here to signal the end of data

@rhodo rhodo marked this pull request as ready for review March 26, 2025 22:12
@ebyhr ebyhr removed their request for review March 26, 2025 22:14
Copy link
Copy Markdown
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

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

Just skimmed.

Comment thread plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotConfig.java Outdated
Comment thread plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotConfig.java Outdated
private boolean countDistinctPushdownEnabled = true;
private boolean proxyEnabled;
private DataSize targetSegmentPageSize = DataSize.of(1, MEGABYTE);
private boolean grpcQueryEnforceMetadataException;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not a fan of making exception handling configurable based on a configuration.

@elonazoulay Do you have any other idea?

Copy link
Copy Markdown
Member

@elonazoulay elonazoulay May 7, 2025

Choose a reason for hiding this comment

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

I agree, especially since it's a choice between empty results masking an exception or a query failure with detailed exception (so it can be investigated and resolved).

Is there any issue with always surfacing exceptions when the query fails?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for reviewing! One reason we were considering making this behavior configurable is that, today, there are cases where partial results are returned instead of raising an exception—for example, when one or a few segments are missing for a table. Some users may be fine with receiving most of the query's result, while others, especially those with stricter consistency requirements, might prefer to get an explicit segment-missing exception.

That said, if we can align on always surfacing exceptions, it would certainly simplify the logic.

(cc @xiangfu0)

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Mar 27, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@github-actions github-actions Bot added the docs label Mar 27, 2025
@rhodo
Copy link
Copy Markdown
Author

rhodo commented Mar 27, 2025

addressed comments, thanks for reviewing @ebyhr !

@rhodo rhodo requested a review from ebyhr March 27, 2025 17:44
@martint
Copy link
Copy Markdown
Member

martint commented Apr 4, 2025

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Apr 4, 2025
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 4, 2025

The cla-bot has been summoned, and re-checked this pull request!

@xiangfu0
Copy link
Copy Markdown
Contributor

xiangfu0 commented Apr 19, 2025

Can we please get this PR reviewed?

Copy link
Copy Markdown
Member

@elonazoulay elonazoulay left a comment

Choose a reason for hiding this comment

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

lgtm overall % exception comment!

@github-actions
Copy link
Copy Markdown

This pull request has gone a while without any activity. Ask for help on #core-dev on Trino slack.

@github-actions github-actions Bot added the stale label May 29, 2025
@github-actions
Copy link
Copy Markdown

Closing this pull request, as it has been stale for six weeks. Feel free to re-open at any time.

@github-actions github-actions Bot closed this Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants