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

Convert the Redisson lock span into an async span #667

Merged
merged 12 commits into from
Jan 21, 2024
Merged

Conversation

peachisai
Copy link
Contributor


RFuture<Object> future = (RFuture) ret;
CompletableFuture<Object> completableFuture = future.toCompletableFuture();
completableFuture.whenCompleteAsync((res, ex) -> {
Copy link
Member

Choose a reason for hiding this comment

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

AFAIK, as you picked #whenCompleteAsync, you can't guarantee the given execution(span#asyncFinish) called in time. The execution time could be longer than expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK, as you picked #whenCompleteAsync, you can't guarantee the given execution(span#asyncFinish) called in time. The execution time could be longer than expected.

How about this

        RFuture<Object> future = (RFuture) ret;
        CompletableFuture<Object> completableFuture = future.toCompletableFuture();

        CompletableFuture.runAsync(()->{
            completableFuture.join();
            span.asyncFinish();
        });

Copy link
Member

Choose a reason for hiding this comment

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

Isn't this simpler?

completableFuture.whenComplete((result, error) -> { span.asyncFinish(); });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't this simpler?

completableFuture.whenComplete((result, error) -> { span.asyncFinish(); });

Okay, I thought you mean the whenComplete may not notify listener as soon, consequently, i choose join method。so the question is the thread context change could cause another cost time

Copy link
Member

Choose a reason for hiding this comment

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

whenComplete should be a sync call when the future completed. Isn't it? Am I getting anything wrong?

Copy link
Contributor Author

@peachisai peachisai Jan 20, 2024

Choose a reason for hiding this comment

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

whenComplete

Yes,you are right.This is a sync call
)1CCYEXAHY}_RU2M4%YO5
Concern that Redisson also use whenComplete frequently, i think it is ok

peachisai and others added 2 commits January 20, 2024 23:54
@wu-sheng wu-sheng added enhancement New feature or request plugin labels Jan 20, 2024
@wu-sheng wu-sheng added this to the 9.2.0 milestone Jan 20, 2024
@wu-sheng wu-sheng merged commit eebc451 into apache:main Jan 21, 2024
188 checks passed
@peachisai peachisai deleted the uat branch February 6, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugin
Projects
None yet
2 participants