When a user rapidly moves waypoints in the Planner, BRouter's thread-priority watchdog kills older in-flight requests to free a thread for newer ones, surfacing to the user as "operation killed by thread-priority-watchdog" errors. Two fixes: 1. Bump the BRouter thread pool on the dedicated host from 4 to 16. `BROUTER_THREADS` is now a Dockerfile ENV (default 4 for flagship/CI/dev) overridden to 16 in `infrastructure/brouter-host/`. The host has 32 GB of RAM and idle cores; 4 threads was a flagship-era constraint that no longer applies. 2. Cancel the previous in-flight `/api/route` request when a new one starts. `use-routing.ts` now keeps an `AbortController` in a ref, aborts it at the top of each `computeRoute`, and bails quietly on `AbortError` so the newer call drives state. Together these eliminate both the "real" contention (at the BRouter level) and the wasted work (BRouter computing a route the client no longer cares about). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
2.4 KiB
Docker
53 lines
2.4 KiB
Docker
FROM eclipse-temurin:11-jre-jammy
|
|
|
|
WORKDIR /brouter
|
|
|
|
# Download latest BRouter release
|
|
ARG BROUTER_VERSION=1.7.9
|
|
RUN apt-get update && apt-get install -y --no-install-recommends wget unzip curl \
|
|
&& wget -q "https://github.com/abrensch/brouter/releases/download/v${BROUTER_VERSION}/brouter-${BROUTER_VERSION}.zip" \
|
|
&& unzip "brouter-${BROUTER_VERSION}.zip" \
|
|
&& mv "brouter-${BROUTER_VERSION}"/* . \
|
|
&& rmdir "brouter-${BROUTER_VERSION}" \
|
|
&& rm "brouter-${BROUTER_VERSION}.zip" \
|
|
&& apt-get purge -y wget unzip && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user and directories for segments and profiles
|
|
RUN addgroup --system app && adduser --system --ingroup app app \
|
|
&& mkdir -p /data/segments /data/profiles
|
|
|
|
# Copy default profiles from release and rename JAR for simpler CMD
|
|
RUN cp -r profiles2/* /data/profiles/ 2>/dev/null || true \
|
|
&& mv brouter-*-all.jar brouter.jar
|
|
|
|
# Patch profiles to include extra tags in WayTags output for visualization
|
|
# Each tag needs its own assign statement to appear in tiledesc WayTags
|
|
RUN for f in /data/profiles/*.brf; do \
|
|
if grep -q "dummyUsage" "$f"; then \
|
|
grep -q "maxspeed" "$f" || sed -i '/assign dummyUsage/a assign dummyUsage2 = maxspeed=' "$f"; \
|
|
grep -q "tracktype" "$f" || sed -i '/assign dummyUsage/a assign dummyUsage3 = tracktype=' "$f"; \
|
|
elif grep -q "context:node" "$f"; then \
|
|
sed -i '/---context:node/i assign dummyUsage2 = maxspeed=\nassign dummyUsage3 = tracktype=' "$f"; \
|
|
fi; \
|
|
done
|
|
|
|
USER app
|
|
EXPOSE 17777
|
|
|
|
# JAVA_OPTS can be overridden at runtime (e.g., `-Xmx8g` for planet-scale).
|
|
# The default keeps the flagship's single-instance footprint small.
|
|
ENV JAVA_OPTS="-Xmx1024M -Xms256M -Xmn64M"
|
|
|
|
# Routing thread pool. When saturated, BRouter's thread-priority watchdog
|
|
# kills the oldest in-flight request ("contention! ms killed …") to free a
|
|
# thread for the new one — the caller then sees a cancelled response. Bump
|
|
# this on hosts with spare cores/RAM to absorb burst traffic. Planet host
|
|
# sets it to 16; flagship/CI keep the default.
|
|
ENV BROUTER_THREADS=4
|
|
|
|
# BRouter server: <segmentdir> <profiledir> <customprofiledir> <port> <maxthreads>
|
|
# Shell form so $JAVA_OPTS and $BROUTER_THREADS expand at container start.
|
|
CMD java $JAVA_OPTS -DmaxRunningTime=300 -cp brouter.jar \
|
|
btools.server.RouteServer \
|
|
/data/segments /data/profiles /data/profiles \
|
|
17777 $BROUTER_THREADS
|