Faucet top-up intermittently fails or hangs: local state query sent while agent is Idle
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start at AddressController.topup, which discards the writer output, and AccountService.topup, which turns logging off; the stack trace points into LocalStateQueryClient.executeQuery's auto-acquire path. Run the reproduction loop with LOGGING_LEVEL_ROOT=DEBUG under taskset -c 0,1 and look for Current state [Idle] in the log. Done means top-ups stop returning 500 or hanging under that load, and a timed-out query fails instead of waiting forever. The race itself sits in the yaci library classes, so confirm the fix against the agent's state transitions before changing this repo.
Written by the indexing model from the issue text.
Description
Problem
Under CPU pressure, about 1 in 10 calls to POST /local-cluster/api/addresses/topup either fail with 500 {"status":false,"message":"Topup failed"} in ~100 ms, or hang (no response after 60s). We see it in CI on 2-core GitHub runners, where it makes devnet-based integration tests flaky.
With LOGGING_LEVEL_ROOT=DEBUG (otherwise AccountService.topup turns logging off, and AddressController discards the writer output), every failed top-up logs:
ERROR c.b.c.y.l.service.AccountService - Error
java.lang.IllegalStateException: Current state [Idle] doesn't support this message : MsgQuery(query=com.bloxbean.cardano.yaci.core.protocol.localstate.queries.UtxoByAddressQuery@16db8274, ...)
at com.bloxbean.cardano.yaci.core.protocol.State.verifyMessageType(State.java:35)
at com.bloxbean.cardano.yaci.core.protocol.localstate.LocalStateQueryAgent.query(LocalStateQueryAgent.java:137)
at com.bloxbean.cardano.yaci.helper.LocalStateQueryClient.lambda$executeQuery$3(LocalStateQueryClient.java:176)
...
at com.bloxbean.cardano.yaci.helper.LocalStateQueryClient$1.acquired(LocalStateQueryClient.java:67)
at com.bloxbean.cardano.yaci.core.protocol.localstate.LocalStateQueryAgent.onMessageAcquired(LocalStateQueryAgent.java:124)
at com.bloxbean.cardano.yaci.core.protocol.localstate.LocalStateQueryAgent.processResponse(LocalStateQueryAgent.java:87)
at com.bloxbean.cardano.yaci.core.protocol.Agent.receiveResponse(Agent.java:44)
preceded by ERROR reactor.core.publisher.Operators - Operator called default onErrorDropped with the same cause. When the error is dropped rather than delivered, the query's Mono never completes, which is presumably the hang.
So executeQuery's auto-acquire path sends the MsgQuery from the acquired callback while the agent still reports Idle. Reading the code, Agent.receiveResponse sets the new state before calling processResponse, so this looks like a race on the agent's state between the caller thread (acquire() / sendNextMessage()) and the Netty event loop, rather than a wrong transition. I haven't confirmed that part.
Reproduce
@bloxbean/yaci-devkit 0.12.0 on Linux x64, with the devkit restricted to 2 cores:
LOGGING_LEVEL_ROOT=DEBUG taskset -c 0,1 yaci-devkit up --enable-yaci-store > up.log 2>&1 &
# once the devnet is up:
for i in $(seq 30); do
curl -s -m 60 -o /dev/null -w '%{http_code}\n' -X POST -H 'Content-Type: application/json' \
-d '{"address":"addr_test1qrqfxwuz8rm0xvewfrp5eudgup24jsan8n22h3f6a7mavyjt0njqm4ykhhqzkdrq9ua8w0lhen8wsuuerexgsehn5u9syjlrxr","adaAmount":10}' \
http://localhost:10000/local-cluster/api/addresses/topup
done
grep -c "Current state \[Idle\]" up.log
Two runs of 30–40 top-ups gave 3 failures each: in the first, one fast 500 and two hangs; in the second, three fast 500s. Without taskset, it rarely shows up locally.
Suggestions
- Fix the race in the local state query client (e.g. make the agent's state transitions and the send path synchronize on the same lock, or have
executeQuerysend the query from the event loop after the state has moved toAcquired). - Separately, it would help if
AddressController.topupreturned the error message instead of discarding it (msg -> {}), and if a top-up that can't get a query result within its timeout failed instead of hanging.
Related, same wrapper version: #220.
- Dominant language
- Java
- Stars
- 70
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bloxbean/yaci-devkit
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
bloxbean/yaci-devkit#87 · 1 comment ·
-
npm wrapper: SIGTERM/SIGINT orphans yaci-cli and leaves a stale PID filePossibly taken @satran004 claimed this 17 days ago. Open
Difficulty 3/5 Half a day Newbie friendliness 55/100
bloxbean/yaci-devkit#220 · 1 assignee ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 28/100
bloxbean/yaci-devkit#207 ·
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 30/100
bloxbean/yaci-devkit#197 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
bloxbean/yaci-devkit#187 ·
All issues in bloxbean/yaci-devkit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bloxbean/yaci-store#1445 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100