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][sql] Fix SQL query is blocked #20911

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

crossoverJie
Copy link
Contributor

Fixes #20910

Motivation

Fix SQL query is blocked.

Modifications

  1. Manually create a ManagedLedgerException instead of e.getCause().
  2. Catch the exception to avoid throwing the exception to the client.

Verifying this change

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: crossoverJie#11

@@ -443,7 +443,8 @@ public void asyncOpenReadOnlyManagedLedger(String managedLedgerName,

}).exceptionally(e -> {
log.error("[{}] Failed to initialize Read-only managed ledger", managedLedgerName, e);
callback.openReadOnlyManagedLedgerFailed((ManagedLedgerException) e.getCause(), ctx);
callback.openReadOnlyManagedLedgerFailed(
new ManagedLedgerException.ManagedLedgerNotFoundException(e.getMessage()), ctx);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we convert all of the exceptions to ManagedLedgerNotFoundException?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was my oversight, how about changing it to:

callback.openReadOnlyManagedLedgerFailed(
                    new ManagedLedgerException(e.getMessage()), ctx);

Copy link
Member

@mattisonchao mattisonchao left a comment

Choose a reason for hiding this comment

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

Is it possible to add a test for this fix?

@crossoverJie
Copy link
Contributor Author

crossoverJie commented Aug 1, 2023

Is it possible to add a test for this fix?

I have tried, but it's rather difficult to reproduce the java.util.NoSuchElementException exception in unit tests.

@mattisonchao
Copy link
Member

@gaoran10 would you mind taking a look at it here?

@gaoran10
Copy link
Contributor

gaoran10 commented Aug 4, 2023

Do you know why there is NoSuchElementException error? Does it mean the managed ledger of the topic doesn't exist yet?

@@ -443,7 +443,8 @@ public void asyncOpenReadOnlyManagedLedger(String managedLedgerName,

}).exceptionally(e -> {
log.error("[{}] Failed to initialize Read-only managed ledger", managedLedgerName, e);
callback.openReadOnlyManagedLedgerFailed((ManagedLedgerException) e.getCause(), ctx);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why need this change? Will this cause class cast exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because this is a PluginClassLoader, it did not directly throw the ClassCastException.
image
image

@@ -328,6 +328,9 @@ Collection<PulsarSplit> getSplitsForTopic(String topicNamePersistenceEncoding,
splits.add(pulsarSplit);
}
return splits;
} catch (ManagedLedgerException exception){
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to catch the case that the managed ledger of the topic is not existing yet? Many exceptions extend ManagedLedgerException, maybe we don't need to catch all ManagedLedgerException.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

If we do not catch exceptions, the client will directly get this exception, but for the user, they do not need to know about this exception, I think we only need to return an empty list.

As for whether to catch all ManagedLedgerException, do you have any suggestions?

void openReadOnlyManagedLedgerFailed(ManagedLedgerException exception, Object ctx);

After all, the callback function declares ManagedLedgerException and cannot know which specific ManagedLedgerException will be thrown.

@crossoverJie
Copy link
Contributor Author

crossoverJie commented Aug 4, 2023

@gaoran10

Do you know why there is NoSuchElementException error? Does it mean the managed ledger of the topic doesn't exist yet?

Yes, there are reproduction steps and the reason for this issue: #20910

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] When querying a newly created topic with Pulsar SQL, the query will be blocked.
3 participants