Page MenuHomePhabricator

[chronik-client] Patch failoverProxy to recognize another type of server failure
ClosedPublic

Authored by bytesofman on Mon, Mar 17, 23:14.

Details

Summary

We have a challenge with failoverProxy in that some chronik errors are the result of bad input (for example we try to get a tx with a bad txid) and other errors are server errors.

We only want to "try the next server" when we have a server error. So, we need some kind of filter where we only do this on a server error.

Our current criteria comes from real world experience, i.e. seeing how servers fail and isolating those error msgs. Today, observed a new type of failure. chronik-native3 returns a normal failure msg but without a reason. I also observed this in servers that are reachable but indexing.

Add this condition.

Test Plan

npm test and CI to confirm current behavior is not impacted.

Using 3.0.0 chronik-client:
Create a chronik url array with chronik-native3 during node maintenance as the first server and another reachable server as the second server. Attempt a normal tx call. Note that failover proxy does not go to the next server.

Using this version:
Do the same thing and note a switch occurs, we do get the tx

Try the same thing with a bad request i.e. chronik.tx('notatxid') and observe the server does switch over from native-3 but not from the next one in the stack; instead that error is returned

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bytesofman added inline comments.
modules/chronik-client/src/failoverProxy.ts
145 ↗(On Diff #53144)

expanding on this test condition

here is a "normal" chronik error, i.e. one we SHOULD NOT switch servers for

Error: Failed getting /tx/notatxid: 400: Not a txid: notatxid

Here is what the same error looks like from an indexing server or ovh-maintenance server

Error: Failed getting /tx/notatxid:

so -- we test for this specific condition, and switch servers if we see it

This revision is now accepted and ready to land.Tue, Mar 18, 04:07