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

enhancement: extract better error messages from indexers #1435

Merged
merged 10 commits into from
Oct 30, 2023

Conversation

lostman
Copy link
Contributor

@lostman lostman commented Oct 25, 2023

Description

Closes #1434.

This PR improves the error messages from indexers. Block height, transaction ID, the name of decoded struct, failing handlers, etc., are automatically included in the error output.

This is implemented using anyhow with the error propagating upwards, accumulating more context.

Since we now use anyhow internally, it is also added to indexer's Cargo.toml (existing users will have to update manually).

Since #1425, users can also use Result type in the handler functions, so having anyhow already included should prove useful (the handlers can return (), or Result).

cargo run -p forc-index -- status

✅ Successfully fetched service health:

client status: OK
database status: OK
uptime: 44m 38s

Indexers:

┌─ fuellabs
|  ├─ explorer
|  |  • id: 107
|  |  • created at: 2023-10-19 19:23:02.325661 UTC (5days 16h 15m 35s ago)
|  |  • status: error
|  |  • status message:
|  |      Failed processing Block #128821
|  |
|  |      Caused by:
|  |          Failed executing index_block_3()
|  |
|  |          Caused by:
|  |              Another error.
|  |
|  |          Failed executing index_block_2()
|  |
|  |          Caused by:
|  |              Bleep blop Error. Bleep.
|  |
|  └─ hello_world
|     • id: 99
|     • created at: 2023-10-17 16:06:58.930780 UTC (7days 19h 31m 39s ago)
|     • status: running
|     • status message:
|         Indexed 1401240 blocks
|
└─ other
   └─ other_indexer
      • id: 108
      • created at: 2023-10-24 14:26:00.129558 UTC (21h 12m 37s ago)
      • status: error
      • status message:
          Failed processing Block #4000231

          Caused by:
              0: Failed processing Transaction 1d0fb5d1bee5534a1f904d9ff511eae80f219538a1d389728779106f2cf550b4
              1: [codegen] Failed decoding struct SomeStruct
              2: Invalid data: tried to read 64 bytes from response but only had 32 remaining!

Testing steps

Same testing steps as #1425.

The following handlers can be added to fuel-explorer:

    fn index_block_3(_block_data: BlockData) -> anyhow::Result<()> {
        anyhow::bail!("Another error.".to_string())
    }

    fn index_block_2(_block_data: BlockData) -> anyhow::Result<()> {
        anyhow::bail!("Bleep blop Error. Bleep.".to_string())
    }

And then, after building and deploying, the status output should be as above.

The other_indexer is an example of failing codegen, which is harder to reproduce but can be done based on:
#1424

Changelog

Please add neat Changelog info here, according to our Contributor's Guide.

@lostman lostman self-assigned this Oct 25, 2023
@lostman lostman changed the title Maciej/1434 better error messages from indexers enhancement: extract better error messages from indexers Oct 25, 2023
@lostman lostman force-pushed the maciej/1434-better-error-messages-from-indexers branch from 045e4e9 to 29a419c Compare October 25, 2023 11:50
@lostman lostman force-pushed the maciej/1434-better-error-messages-from-indexers branch from 7bea332 to d506f90 Compare October 25, 2023 13:19
@lostman lostman marked this pull request as ready for review October 25, 2023 14:20
Copy link
Contributor

@ra0x3 ra0x3 left a comment

Choose a reason for hiding this comment

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

@lostman

  • The look of it is fine, however needs to be organized a bit differently

examples/fuel-explorer/fuel-explorer/Cargo.toml Outdated Show resolved Hide resolved
@lostman lostman force-pushed the maciej/1434-better-error-messages-from-indexers branch from 7fcea42 to 1ff69fe Compare October 25, 2023 16:03
@lostman lostman requested a review from ra0x3 October 25, 2023 16:41
@lostman lostman enabled auto-merge (squash) October 25, 2023 16:48
Copy link
Contributor

@ra0x3 ra0x3 left a comment

Choose a reason for hiding this comment

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

@lostman Could you also include a QA report with this - for maybe 30K blocks each run - given how much of a critical path this PR touches?

packages/fuel-indexer-macros/src/indexer.rs Outdated Show resolved Hide resolved
Co-authored-by: rashad <spam.rashad@protonmail.com>
@lostman
Copy link
Contributor Author

lostman commented Oct 26, 2023

@lostman lostman requested a review from ra0x3 October 26, 2023 03:53
@lostman lostman requested a review from deekerno October 26, 2023 15:27
@lostman lostman merged commit 1c80bda into develop Oct 30, 2023
19 checks passed
@lostman lostman deleted the maciej/1434-better-error-messages-from-indexers branch October 30, 2023 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

enhancement: improve error messages from indexers
3 participants