Troubleshooting
Common operational issues and how to resolve them.
Engine suspension
Symptoms: An engine shows “suspended” status on the /admin/log page, or search results suddenly exclude a particular source.
Cause: The rate limiter auto-suspends engines after repeated failures (timeouts, HTTP errors, empty results). Suspension uses exponential backoff – each successive failure doubles the cooldown period.
Diagnosis:
- Visit
/admin/log(public) or/admin/health(owner). Suspended engines show a red “suspended” status badge. - Check the server logs for lines like
engine X: error ...orengine X: timeout. - Verify the upstream engine is actually reachable:
curl -I https://engine-url/.
Resolution:
- Engines auto-recover once the backoff period expires and the next request succeeds.
- Owner can force-unsuspend via the admin health dashboard.
- If the engine requires an API key, verify the key is valid and not rate-limited.
- For scraping-based engines (Google, Bing, Yahoo), verify the instance IP is not blocked. Rotating the IP or enabling deluxe mode (browser backend) may help.
PoW difficulty tuning
Symptoms: Users complain PoW takes too long, or bots are getting through too easily.
Configuration: Set pow-difficulty in config.kdl (default: 22 bits). Higher values require more computation:
- 18-20: fast solve (~100ms), low bot resistance
- 22-24: moderate (~500ms-2s), good balance for most instances
- 26+: strong bot resistance, may frustrate users on slow devices
The server applies adaptive difficulty automatically: +1 bit above 100 requests/minute, +2 bits above 500 RPM. The base difficulty in config is the floor.
Tuning tips:
- Monitor PoW success/fail rates on
/admin/log(IQ stats section). - If PoW fails are very high, bots may be attempting brute force – raise difficulty.
- If legitimate users report slow verification, lower the base or ensure the PoW JavaScript is loading correctly (check for CDN/proxy issues stripping scripts).
SQLite WAL growth
Symptoms: The 4got.db-wal file grows continuously, consuming disk space.
Cause: SQLite WAL (Write-Ahead Logging) mode checkpoints periodically, but under sustained write load the WAL file can grow before checkpointing catches up. The server opens the DB with _journal_mode=WAL&_busy_timeout=5000.
Resolution:
- Check WAL size:
ls -lh data/4got.db-wal - Force a checkpoint:
sqlite3 data/4got.db 'PRAGMA wal_checkpoint(TRUNCATE);' - If the WAL grows beyond a few hundred MB consistently, the write rate may be too high. Consider:
- Reducing search logging verbosity
- Raising the acceptable cache age (
cache_max_age) to reduce repeated engine calls - Disabling server-side history for non-owner users
- The
-shmfile is a shared memory index for WAL and is safe to ignore.
Prevention: The server uses separate read and write DB connections. The write connection handles checkpointing. Under normal operation, WAL files stay small (<50 MB).
Peer auth failures
Symptoms: Friend instances show errors in logs, peer cache sharing fails, proxy requests return 401/403.
Diagnosis:
- Verify
peer-secretinconfig.kdlmatches on both sides. - Check that the friend’s URL in
peers.kdlis reachable and includes the correct protocol (https://). - Look for TLS certificate errors in logs – self-signed certs need explicit trust.
- Verify the friend instance is running a compatible API version (
/ami4gotreturns version info).
Common issues:
- Clock skew: if timestamps are used in auth tokens, ensure NTP is synced on both instances.
- Firewall rules: peer cache uses
/api/v1/cacheand/api/v1/proxyendpoints – ensure they are not blocked. - Permissions: a friend needs no group. It is known by
peer-secret, and its push by itspubkeyin peers.kdl.
Memory usage
Symptoms: The server process consumes more memory than expected, or OOM-kills occur.
Common causes:
- Image proxy cache: In-memory image cache grows with traffic. Configure
max_cache_sizein the image proxy config, or rely on SQLite-backed caching with eviction. - Highlight regex cache: Capped at 10,000 entries, auto-evicts when full. Not usually a problem.
- Peer cache: Cached results from friend instances are held in memory. Large peer networks with high traffic multiply memory usage.
- AI research: The LLM research agent (if enabled) buffers responses. Each concurrent research session uses memory proportional to response length.
- Prerendered captchas: Image data is held in memory until served. The pool size is bounded.
Monitoring: Check /ami4got for basic stats. For detailed memory profiling, run with GODEBUG=gctrace=1 or attach pprof if built with the debug profile.
Mitigation:
- Set
GOGCenvironment variable to control GC aggressiveness (default 100; lower values like 50 trade CPU for less memory). - Reduce
max_cache_sizefor image proxy. - Limit concurrent AI research sessions.
Common Docker issues
Symptoms: Container fails to start, database errors, or static files not found.
Template/static file not found:
- The Dockerfile copies
go-server/templates/andstatic/into the image. If you modified the directory structure, update the Dockerfile paths. - Verify with
docker exec <container> ls /app/templates/andls /app/static/.
Database permissions:
- SQLite needs write access to the data directory. Mount a volume:
-v ./data:/app/data. - If the container runs as a non-root user, ensure the volume has correct ownership.
Port binding:
- Default port is 8080. Map it with
-p 8080:8080or setHOST/PORTenvironment variables. - In
docker-compose.yml, verify theportssection matches your config.
CGO / SQLite:
- The binary requires CGO for SQLite. The Dockerfile uses
CGO_ENABLED=1. If building a custom image, ensure gcc and sqlite-dev are installed.
Health checks:
- Use
/ami4gotas a Docker health check endpoint:HEALTHCHECK CMD curl -sf http://localhost:8080/ami4got || exit 1.
fly.io specific:
- The
fly.tomlmounts a persistent volume at/data. Ensure the volume exists:fly volumes create data. - Memory: fly.io shared-1x VMs have 256 MB. If using AI research or large peer networks, upgrade to at least 512 MB.