whoami

Lucas Jenß

cat /etc/motd

The Coding Journal ツ — Notes taken on an epic coding journey. Technical solutions, debugging notes, and practical guides from the trenches of software development.

Close-up of white dominoes with black dots standing on green felt surface, shallow depth of field, focused mood

ls -la ~/languages/

total 8
drwxr-xr-x
▶ PHP
▶ Ruby
▶ Scala
▶ C#
▶ JavaScript
▶ Objective-C
▶ Shell Scripting

ls -la ~/toolchain/

total 7
drwxr-xr-x
▶ Typo3
▶ Akka
▶ Capistrano
▶ Git
▶ MAMP
▶ Adobe Illustrator
▶ NSTrackingArea (Cocoa)

uname -a

platforms
drwxr-xr-x
▶ Mac OS X
▶ Unix

Debugging an Akka Actor System That Hangs on Message Delivery

An Akka application can appear frozen even when every actor is still alive. A message may sit in a mailbox, an actor may be blocked inside a future callback, or a dispatcher may have run out of threads. The result looks the same from the outside: a request waits, logs stop, and the system seems to ignore work that should be routine.

The useful approach is to treat the hang as a delivery-path problem. Follow the message from its sender to the receiver, inspect the dispatcher that carries it, and verify whether the sender is waiting for a response. This method applies to classic Akka actors and, with small naming changes, to Akka Typed systems running in a local development environment or in an Australian cloud region such as AWS ap-southeast-2.

Symptom Likely cause First check Practical fix
tell returns but nothing happens Receiver is stopped, suspended, or using the wrong ActorRef Log the sender and receiver paths Confirm actor lifecycle and reference identity
ask never completes No reply, blocked actor, or timed-out future Add a timeout and log every reply branch Reply on every path and isolate blocking work
All actors stop making progress Shared dispatcher starvation Inspect dispatcher threads and blocking calls Use a dedicated dispatcher or non-blocking API
Messages arrive out of order Multiple senders or asynchronous callbacks Record sender, sequence number, and timestamp Design for ordering instead of assuming it
System hangs during shutdown Mailbox or future waits for terminated resources Watch termination and coordinated shutdown logs Stop producers and drain work deliberately

Recognise What A Hang Actually Means

A call to actorRef ! message is asynchronous. It normally queues the message and returns immediately, so a paused caller does not prove that delivery itself is blocked. If the caller appears to stop at that line, inspect the code around it for logging, synchronisation, a saturated executor, or an overloaded application thread.

An ask operation has a different failure shape. It creates a temporary actor, sends the request, and waits for a reply represented by a future. If the target actor never replies, the future remains incomplete until its timeout expires. A missing reply can come from an exception, an early return, an unmatched message pattern, or a branch that performs work without sending a response.

Start with observable facts rather than assumptions. Give every important message a correlation ID, log the actor path and message type, and record when the message was sent, received, handled, and answered. In a busy Melbourne service, that small amount of structured logging is far more useful than scrolling through several thousand lines of mixed console output during an afternoon incident.

Trace The Full Delivery Path

Actor paths are easy to confuse, especially when systems create children dynamically. /user/orders and /system/orders are different paths, while a restarted child may have the same logical role with a different lifecycle. Log self.path, sender(), and the target ActorRef at the point of sending and receiving. Comparing object identity can also reveal that two references share a name in a log but point to different actors.

A message sent to a stopped actor is generally redirected to dead letters. Enable dead-letter logging temporarily, or subscribe a diagnostic actor to DeadLetter and SuppressedDeadLetter events. A flood of dead letters often identifies a shutdown race, a stale reference, or a parent that recreated a child while another component continued using the old reference.

Remember that tell has no delivery guarantee. It provides at-most-once message delivery: a message can be lost if the process fails, the receiver terminates, or an error occurs before handling completes. For workflows requiring confirmation, model an explicit acknowledgement, persistence, retry policy, or durable queue rather than expecting Akka to behave like a transactional broker.

For broader notes on practical debugging across software projects, the coding notes provide useful context for the hands-on style behind this kind of investigation. The principle is consistent: capture the state at the failure boundary instead of guessing from the final symptom.

Inspect Dispatchers And Mailboxes

A dispatcher supplies the threads that execute actors. If an actor performs blocking database, filesystem, HTTP, or legacy library calls on the default dispatcher, it can consume threads needed by unrelated actors. Enough blocked actors will make the entire system look stuck, even though messages are being queued correctly.

Search the codebase for Await.result, Thread.sleep, synchronous HTTP clients, JDBC calls, and locks inside receive or message handlers. A short wait multiplied across many actors can exhaust the pool. In Australia, a service using a local Sydney database may seem fine in testing, then stall under production latency when a remote dependency adds a few hundred milliseconds to every blocking call.

Use a dedicated dispatcher for unavoidable blocking operations, and keep its capacity bounded. In configuration, give that dispatcher a clearly named executor and tune its thread count for the external resource it protects. A larger pool is not a universal fix: creating hundreds of threads can increase context switching and pressure the database until the original hang becomes a wider outage.

Mailboxes deserve the same scrutiny. A bounded mailbox can reject or redirect messages when full, while an unbounded mailbox can grow until memory pressure slows the process. Check queue size, throughput settings, mailbox type, and whether a custom mailbox is throwing an exception. A mailbox that accepts messages faster than an actor can process them is a back-pressure problem, not a mysterious delivery failure.

Handle Ask Patterns And Futures Carefully

Every ask request needs a clear success, failure, and timeout path. The receiving actor should reply for valid input, reject invalid input explicitly, and report failures rather than silently throwing. The caller should attach onComplete, recover, or equivalent handling so that a failed future does not disappear inside another asynchronous chain.

A common deadlock occurs when an actor waits synchronously for a future that needs the same dispatcher to complete. For example, an actor calls Await.result on a database future while all dispatcher threads are occupied by actors doing the same thing. No actor can release its thread, so the future never gets the execution time it needs.

Prefer composing futures with map, flatMap, and recover, then send the result back to the actor’s protocol. In classic Akka, capture the original sender before starting asynchronous work because sender() is meaningful during message processing and should not be read later from an arbitrary callback. In Akka Typed, carry the reply-to reference in the message and send the response through that explicit protocol.

Timeouts should expose a problem, not conceal one. Use a timeout appropriate to the dependency, include the correlation ID in the error, and distinguish a timeout from a business rejection. A five-minute timeout may reduce noisy errors while leaving thousands of temporary actors and queued requests alive, which makes the next failure harder to diagnose.

Instrument The System Before Changing It

Turn on useful actor lifecycle and dead-letter logging for a controlled reproduction, then turn it back down once the evidence is collected. Add metrics for mailbox depth, message processing duration, active dispatcher threads, rejected tasks, ask timeouts, and dead letters. A tracing system can connect the incoming HTTP request, actor message, database call, and response when a simple log line cannot show the complete chain.

Supervision logs are especially important. An actor that throws may restart and lose in-memory state, stop permanently, or escalate the failure depending on its supervision strategy. The sender may see no direct exception from tell, so the visible symptom can be “no reply” rather than “actor crashed”. Log restart counts and termination reasons beside the actor path.

Useful evidence can be gathered in two compact passes:

  • Capture the message ID, actor path, sender, timestamp, and processing duration.
  • Record dead letters, actor termination, supervision events, and ask timeouts.
  • Sample thread dumps while the application is unresponsive.
  • Compare mailbox growth with dispatcher utilisation.

Thread dumps distinguish a blocked system from a CPU-bound one. Look for many threads waiting on the same lock, parked in a synchronous client, or queued behind a saturated executor. If dispatcher threads are idle while messages remain pending, investigate mailbox configuration, actor suspension, incorrect references, and a receiver that is no longer running.

Keep diagnostics separate from unrelated application tooling. A note about tracking areas in Cocoa illustrates a broader debugging habit: inspect the event boundary where behaviour changes, whether that boundary is a UI callback or an actor mailbox.

Build A Reproducible Message Flow

Reduce the failing system to one sender, one receiver, one dispatcher, and one message sequence. Replace the external database or HTTP service with a controllable stub that can delay, fail, or never respond. This makes it possible to determine whether the hang is caused by Akka delivery, dependency latency, actor logic, or test code waiting incorrectly.

Use a deterministic sequence number in each message. Send a known batch, record the expected replies, and assert that every message reaches a terminal state. Test receiver termination, actor restart, dispatcher exhaustion, mailbox overflow, and shutdown while work is in flight. A small reproduction is more valuable than a production log containing thousands of unrelated events.

Run the same scenario under realistic resource limits. A laptop in Brisbane may have low network latency to a local service that behaves very differently from a container deployed across availability zones. Include the actual connection pool size, CPU limits, JVM settings, and timeouts used in the target environment. Local slang such as “she’ll be right” is handy in conversation, but it is a poor availability strategy when an ask future has no deadline.

Treat ordering as part of the protocol. Messages from one sender to one receiver preserve their relative order, but asynchronous callbacks, multiple senders, retries, and restarts can change what the business process observes. If order matters, include sequence information and reject or buffer unexpected values explicitly.

The Akka reference can help when checking framework concepts against the behaviour seen in a reproduction. Once the failing path is understood, document the actor protocol, dispatcher choice, timeout policy, and shutdown sequence beside the code so the same fault does not return during the next release cycle.

A reliable fix usually has three parts: remove blocking work from the default dispatcher, make every request produce an explicit outcome, and add enough telemetry to prove where time is spent. Apply those changes in a small branch, run the controlled reproduction, then verify the production metrics after deployment. That turns an actor system that merely appears to hang into one whose failures can be located, measured, and repaired.


cat ~/interests.json

KeyValue
editorTerminal-first workflow
osMac OS X / Unix
vcsGit, distributed version control
deployCapistrano, cron automation
graphicsSVG, Adobe Illustrator troubleshooting
networkingIP validation, SSH, VPN

git log --oneline --reverse

2013-10-30

Solving SVG import issues in Adobe Illustrator CS6 and CC

When importing an SVG into Illustrator, the operation fails with an unknown error [CANT]. A workaround for this Adobe-side bug.

2013

Solving NDK build issues on OS X

Troubleshooting native development kit compilation problems on Mac OS X.

2013

Programmatically adding PHP generated TypoScript to the backend configuration

Integrating dynamically generated TypoScript into Typo3 backend setups using PHP.

2013

ArgumentError: Could not parse PKey: no start line

Debugging an SSH key parsing error encountered during deployment.

2011-08-04

Validating IP-Addresses in PHP

Using PHP filter functions with flags like FILTER_FLAG_IPV4 and FILTER_FLAG_IPV6, and understanding how filter_var handles reserved IP addresses.

2011-07-09

Cocoa: Using NSTrackingArea

A short tutorial on using Cocoa's NSTrackingArea to capture mouseEntered and mouseExited events.


cat ~/contact.txt

github: github.com/x3ro
stackoverflow: x3ro
coderwall: coderwall.com/x3ro
twitter: @x3rames