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 the operation timeout is not honored for GetSchema requests #383

Merged

Conversation

BewareMyPower
Copy link
Contributor

Fixes #357

Motivation

In Client::getSchemaInfoAsync, the underlying
LookupService::getSchema is called, which does not register a timer according to the operation timeout.

Modifications

Register a timer and cache it and the GetSchema promise in ClientConnection::pendingGetSchemaRequests_, then remove the entry and complete the promise with ResultTimeout.

To verify the timeout is honored, modify the timeout type from int to chrono::nanoseconds so that a smaller timeout can be configured. Then test a small enough timeout (1 ns) in
LookupServiceTest.testGetSchemaTimeout.

@BewareMyPower BewareMyPower self-assigned this Jan 8, 2024
@BewareMyPower BewareMyPower added the bug Something isn't working label Jan 8, 2024
@BewareMyPower BewareMyPower added this to the 3.5.0 milestone Jan 8, 2024
@BewareMyPower
Copy link
Contributor Author

There are other requests that don't honor the operation timeout as well. In future, we might refactor the logic to send any request with a timeout like:

sendRequest(request, timeout).thenApply(response -> handleXxx(response.getXxxResponse());

@BewareMyPower BewareMyPower marked this pull request as draft January 8, 2024 16:13
@BewareMyPower BewareMyPower marked this pull request as ready for review January 9, 2024 01:19
@BewareMyPower
Copy link
Contributor Author

The main branch is broken. I pushed a PR to fix: #384

@BewareMyPower BewareMyPower force-pushed the bewaremypower/get-schema-timeout branch 2 times, most recently from 616a120 to 8858744 Compare January 9, 2024 06:22
@@ -40,8 +41,8 @@ class RetryableOperationCache : public std::enable_shared_from_this<RetryableOpe
explicit PassKey() {}
};

RetryableOperationCache(ExecutorServiceProviderPtr executorProvider, int timeoutSeconds)
: executorProvider_(executorProvider), timeoutSeconds_(timeoutSeconds) {}
RetryableOperationCache(ExecutorServiceProviderPtr executorProvider, std::chrono::nanoseconds timeoutMs)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this nanoseconds or milliseconds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh the name is wrong. It should be nanoseconds. I will address it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed all Ms or Seconds prefixes and use TimeDuration as the type now, PTAL again.

@BewareMyPower BewareMyPower marked this pull request as draft January 19, 2024 01:56
Fixes apache#357

### Motivation

In `Client::getSchemaInfoAsync`, the underlying
`LookupService::getSchema` is called, which does not register a timer
according to the operation timeout.

### Modifications

Register a timer and cache it and the GetSchema promise in
`ClientConnection::pendingGetSchemaRequests_`, then remove the entry and
complete the promise with `ResultTimeout`.

To verify the timeout is honored, modify the timeout type from `int` to
`chrono::nanoseconds` so that a smaller timeout can be configured. Then
test a small enough timeout (1 ns) in
`LookupServiceTest.testGetSchemaTimeout`.
@BewareMyPower BewareMyPower force-pushed the bewaremypower/get-schema-timeout branch from 8858744 to 25bd34b Compare January 19, 2024 09:33
@BewareMyPower BewareMyPower marked this pull request as ready for review January 19, 2024 09:34
@merlimat merlimat merged commit 72b7311 into apache:main Jan 19, 2024
12 checks passed
@BewareMyPower BewareMyPower deleted the bewaremypower/get-schema-timeout branch January 21, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] getSchemaInfoAsync is not honoring the PulsarClient timeout
2 participants