Skip to content

[Broker] Add operation timeout to metadata store - #13596

Closed
nodece wants to merge 1 commit into
apache:masterfrom
nodece:add_op_time_metadata
Closed

[Broker] Add operation timeout to metadata store#13596
nodece wants to merge 1 commit into
apache:masterfrom
nodece:add_op_time_metadata

Conversation

@nodece

@nodece nodece commented Jan 4, 2022

Copy link
Copy Markdown
Member

Signed-off-by: Zixuan Liu nodeces@gmail.com

Motivation

I notice that the metadata store hasn't any timeout settings when using zk API. When the call the zk.multi API and if the zk doesn't call the callback, the request will not be released.

Modifications

  • Add OperationTimeoutSeconds to metadata store config
  • Add timeout check task to ZKMetadataStore.batchOperation

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Add ZKMetadataStoreTest test

Documentation

Need to update docs?

  • no-need-doc

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Jan 4, 2022
@nodece
nodece force-pushed the add_op_time_metadata branch 6 times, most recently from c8b94d1 to 85481e1 Compare January 4, 2022 11:24
* The operation timeout in seconds.
*/
@Builder.Default
private final int operationTimeoutSeconds = 30;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will sessionTimeoutMillis apply ? Why do we need operationTimeoutSeconds?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The sessionTimeoutMillis is used for heartbeat checks between zk client and server, so I don't think we should use this field as config of operation timeout.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have any specific case for "the zk doesn't call the callback"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I made an issue for this, you can try to reproduce this by issue: #13211. This issue cannot find by the Unit test or Integration test.

@nodece

nodece commented Jan 5, 2022

Copy link
Copy Markdown
Member Author

/pulsarbot run-failure-checks

@@ -75,6 +78,11 @@ public abstract class AbstractMetadataStore implements MetadataStoreExtended, Co
protected abstract CompletableFuture<Boolean> existsFromStore(String path);

protected AbstractMetadataStore() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you should config operationTimeoutSeconds via PulsarService#createConfigurationMetadataStore.
And we can re-use the zooKeeperOperationTimeoutSeconds in ServiceConfiguration.

@nodece
nodece force-pushed the add_op_time_metadata branch 4 times, most recently from 3d8c3fd to 4049a65 Compare January 6, 2022 04:17
@nodece
nodece requested a review from Technoboy- January 6, 2022 06:16
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
@nodece
nodece force-pushed the add_op_time_metadata branch from 4049a65 to 96ca945 Compare January 8, 2022 15:35
@nodece

nodece commented Jan 10, 2022

Copy link
Copy Markdown
Member Author

/pulsarbot run-failure-checks

Comment on lines +192 to +196
executor.schedule(() -> {
if (!callback.get()) {
ops.forEach(n -> n.getFuture().completeExceptionally(new TimeoutException()));
}
}, getMetadataStoreConfig().getOperationTimeoutSeconds(), TimeUnit.SECONDS);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we don't need to change here? The batch operation just groups a few ops to one batch, each single ops has a future and if the caller requires an operation timeout, the caller can only use future.get(timeout)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If the caller use future.join(), the caller will be blocked.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, using future.join() means the caller expects an infinite timeout or without a timeout. it's dangerous here to add operation timeout. If the broker acquired a lock from Zookeeper but the operation timeout happened first, the callback happened later, how do we deal with this case?

I think the main point is to find the root cause of why the the zk doesn't call the callback, is the performance bottleneck or deadlock?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If the broker acquired a lock from Zookeeper but the operation timeout happened first, the callback happened later, how do we deal with this case?

We cannot determine the order, maybe we should avoid using future.join() in our project, but I still care when the zk doesn't call the callback, we should how to release a future.

I think the main point is to find the root cause of why the the zk doesn't call the callback, is the performance bottleneck or deadlock?

I have found the root cause of zk doesn't call the callback, and I submitted #13809 to fix this.

@nodece nodece closed this Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants