Queue Issues
Queue Issues
Section titled “Queue Issues”Mantis uses RabbitMQ for command dispatch from Mandible to Thorax. When RabbitMQ is unavailable, the system automatically falls back to a polling-based dispatch mode. This guide covers troubleshooting both queue connectivity and dispatch behavior.
Dispatch Modes
Section titled “Dispatch Modes”Mantis supports two dispatch modes, selected automatically based on RabbitMQ health:
| Mode | Description | When Used |
|---|---|---|
| RabbitMQ | Commands published to queue, consumed by Thorax | RabbitMQ healthy |
| Polling | Commands stored in database, Thorax polls the API | RabbitMQ unavailable or not configured |
The QueueHealthMonitor continuously checks RabbitMQ connectivity and switches modes as needed. This failover is transparent to deployment operations.
RabbitMQ Connectivity
Section titled “RabbitMQ Connectivity”Check Connection Status
Section titled “Check Connection Status”# Check Mandible logs for queue healthjournalctl -u mantis-mandible | grep -i "queue_health\|dispatch_mode\|rabbitmq" | tail -20
# Check RabbitMQ is runningsystemctl status rabbitmq-server# ordocker compose ps rabbitmq
# Test AMQP connectivity# (RabbitMQ management plugin must be enabled)curl -s -u guest:guest http://localhost:15672/api/overview | jq '.message_stats'Common Connection Errors
Section titled “Common Connection Errors”connection refused on port 5671/5672
RabbitMQ is not running or not listening on the expected port.
# Check which ports RabbitMQ is listening onss -tlnp | grep -E "(5671|5672|15672)"
# Verify RabbitMQ configurationrabbitmqctl statusTLS handshake failed
When using AMQPS (TLS), the certificate configuration may be incorrect.
# Test TLS connection to RabbitMQopenssl s_client -connect localhost:5671 \ -CAfile /etc/mantis/certs/ca.crtaccess refused / authentication failed
AMQP credentials are incorrect or the user lacks permissions.
# Verify user exists and has correct permissionsrabbitmqctl list_usersrabbitmqctl list_permissions -p /Dispatch Queue Issues
Section titled “Dispatch Queue Issues”Pending Dispatches Not Processing
Section titled “Pending Dispatches Not Processing”The DispatchQueueProcessor runs in Mandible and processes pending dispatch requests. It has the following behavior:
| Parameter | Value | Description |
|---|---|---|
| Max retries | 10 | Maximum retry attempts per dispatch |
| TTL | 24 hours | Requests expire after this duration |
Diagnosis:
# Check for dispatch queue activityjournalctl -u mantis-mandible | grep -i "dispatch_queue_processor" | tail -20
# Look for retry exhaustion or TTL expiry (both marked as Failed)journalctl -u mantis-mandible | grep -i "max_retries\|expired\|failed" | tail -10Common causes:
- No Thorax instance online to receive dispatches
- All targets assigned to an offline Thorax instance
- RabbitMQ down and polling fallback not yet activated
TTL-Expired Dispatches
Section titled “TTL-Expired Dispatches”Dispatch requests that exceed the 24-hour TTL are marked as Failed and will not be retried. If you see many failed dispatches due to TTL expiry:
- Check if Thorax was offline for an extended period
- Review the
ThoraxReassignmentServicelogs for target reassignment activity - Verify new deployments can be dispatched successfully
Duplicate Dispatches
Section titled “Duplicate Dispatches”In rare cases, a dispatch may be processed more than once (at-least-once delivery). The execution layer handles idempotency, but if you see duplicate deployment runs:
- Check for RabbitMQ connectivity flapping (rapid connect/disconnect cycles)
- Review the dispatch queue for duplicate entries
- Check if multiple Mandible instances are running without coordination
RabbitMQ Health Monitor
Section titled “RabbitMQ Health Monitor”The QueueHealthMonitor tracks the following metrics:
| Metric | Description |
|---|---|
is_healthy | Whether RabbitMQ is currently reachable |
consecutive_failures | Number of failed health checks in a row |
total_successes | Cumulative successful checks |
total_failures | Cumulative failed checks |
Failover Behavior
Section titled “Failover Behavior”When RabbitMQ becomes unhealthy:
- Health monitor detects a failed health check
- Dispatch mode switches from
RabbitMQtoPolling - Mandible stores commands in the database
- Thorax polls Mandible’s API for pending work
When RabbitMQ recovers:
- Health monitor detects successful connection
- Dispatch mode switches back to
RabbitMQ - New commands are published to the queue
- Pending polling-mode commands complete via their current mechanism
RabbitMQ Maintenance
Section titled “RabbitMQ Maintenance”Queue Management
Section titled “Queue Management”# List queues and their message countsrabbitmqctl list_queues name messages consumers
# Purge stuck queues (use with caution)rabbitmqctl purge_queue mantis.commands.thoraxrabbitmqctl purge_queue mantis.commands.priority.highrabbitmqctl purge_queue mantis.commands.priority.normalrabbitmqctl purge_queue mantis.commands.priority.low
# Check for unacknowledged messagesrabbitmqctl list_queues name messages_unacknowledgedConnection Management
Section titled “Connection Management”# List active connectionsrabbitmqctl list_connections name state
# List channelsrabbitmqctl list_channels name consumer_count messages_unacknowledgedDebugging Checklist
Section titled “Debugging Checklist”- Check RabbitMQ service status
- Verify AMQP credentials and permissions
- Test network connectivity to RabbitMQ port
- Review Mandible logs for queue health status
- Check current dispatch mode (RabbitMQ vs Polling)
- Verify TLS certificates if using AMQPS
- Check for message backlog in RabbitMQ queues
- Review
DispatchQueueProcessorlogs for errors
Next Steps
Section titled “Next Steps”- Deployment Failures — End-to-end deployment troubleshooting
- Connection Problems — General connectivity issues
- Common Issues — Broader troubleshooting guide
