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

[RPC] RPC server handle panic exceptions to output error msg #819

Closed
baichuan3 opened this issue Sep 15, 2023 · 4 comments · Fixed by #830
Closed

[RPC] RPC server handle panic exceptions to output error msg #819

baichuan3 opened this issue Sep 15, 2023 · 4 comments · Fixed by #830
Assignees
Labels
optimize skill::rust Need the rust language skill to complete the issue
Milestone

Comments

@baichuan3
Copy link
Collaborator

baichuan3 commented Sep 15, 2023

In #774 for implementing MoveFunctionCall for the RPC Server, the solution is to introduce another tokio Runtime.

Then it is discovered that the RPC server may not be able to directly capture and process an error. The phenomenon is that the call RPC returns a blank, but there is an error log in the console output.

The tokio Runtime implemented in AggrateService, both AggrateService and RPCService will occur the above situation.

Exception case

let coin_store_handle = coin_module.coin_store_handle(account_addr)?.except("Coin store handle does not exist");

error stack

thread 'tokio-runtime-worker' panicked at 'Coin store handle does not exist', crates/rooch-rpc-server/src/service/aggregate_service.rs:73:31

Normal case after rewriting

let coin_store_handle = coin_module.coin_store_handle(account_addr)?;
// Handle error due to `coin_store_handle` executed in another tokio Runtime
let coin_store_handle = match coin_store_handle {
    Some(v) => v,
    None => anyhow::bail!("Coin store handle does not exist"),
};

Relative #817

@baichuan3 baichuan3 added optimize skill::rust Need the rust language skill to complete the issue labels Sep 15, 2023
@baichuan3 baichuan3 added this to the Rooch v0.2 milestone Sep 15, 2023
@baichuan3 baichuan3 self-assigned this Sep 15, 2023
@baichuan3
Copy link
Collaborator Author

It is determined that it is not caused by the introduction of dual tikio runtime. The same problem existed in the earlier RPC Server. The reason is that methods such as expect or unwrap will cause panic exceptions, causing the program to exit directly.

@baichuan3 baichuan3 changed the title [RPC] RPC handle error after introduce another tokio Runtime [RPC] RPC server handle panic exceptions to output error msg Sep 17, 2023
@jolestar
Copy link
Contributor

I take this.

@jolestar
Copy link
Contributor

In the multi-thread executor, if a thread panics, the RPC will return nothing.
We need to fix the panic bug or convert it to an error.

This is not a bug. I close this issue. and record two:

  1. [Rpc server] Eliminate the static tokio runtime #826
  2. Check all expect and unwrap #827

@github-project-automation github-project-automation bot moved this to Done in Rooch Sep 18, 2023
@baichuan3
Copy link
Collaborator Author

I have almost handled over the expect and unwrap in RPC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimize skill::rust Need the rust language skill to complete the issue
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants