Task #6121
closedTask #6116: EPIC: Speed up the stats updater daemon (scripts/workflow/update_stats.sh)
Make raw IIKO request/response logging to iiko_requests opt-in
100%
Description
Problem¶
Every IIKO call persists its full request and response payload to iiko_requests, as two separate DB round-trips — an INSERT before the call and an UPDATE after:
-
IikoOlapV2RequestsFetchingService.fetchOlapData—iikoRequestsService.saveline 39,updateline 53 (and again at 62 on parse failure) -
DepartmentsFetchingService.fetchDepartments,IikoServerEmployeesFetchingService.fetchEmployees— same pattern
At the current request volume this is write amplification on the hot path plus unbounded table growth: the table accumulates a full copy of every OLAP report body the daemon has ever downloaded, round after round.
Proposed change¶
- Put raw request/response capture behind a config flag (e.g.
iiko.server.log-raw-requests, defaultfalse). - With the flag off, still record failures — a row written only when the call errors or the response fails to parse, which is when the payload is actually worth having.
- Add a retention job (or a documented cleanup) for rows older than N days.
Acceptance¶
- Default configuration performs no
iiko_requestswrites on a successful call. - Failures still land a row with url, request, response, error and trace.
- Enabling the flag restores today's behaviour for debugging.
Updated by Redmine Admin about 9 hours ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
Реализовано в ветке speedup/stats-daemon, коммит 50a6ebef.
Новый IikoRequestLogService (adapters/iiko/server/common/services/) с флагом iiko.server.log-raw-requests (по умолчанию false, прописан в application.properties и application-test.properties):
-
begin(url, requestBody)— пишет строку только когда флаг включён, иначе возвращаетnull; -
success(entry, responseBody)— дописывает ответ, если строка была заведена; -
failure(entry, url, requestBody, responseBody, e)— заводит строку сам, если её не было, так что ошибки пишутся всегда, с телом,errorиerrorTrace.
Заодно redact(url) вырезает key=... — раньше ключ сессии iiko сохранялся в базу в открытом виде вместе с каждым url.
Подключено в IikoOlapV2RequestsFetchingService, DepartmentsFetchingService, IikoServerEmployeesFetchingService.
Не сделано: ретеншен старых строк iiko_requests. С выключенным флагом таблица больше не растёт, поэтому срочности нет, но исторические данные никто не чистит — стоит отдельной задачи или разовой команды.