Имея WSO2AM (API Manager) 2.1.0 с сервером Analytics (на PostgreSQL), мы видим следующую проблему:
если клиент вызывает API без заголовка User-Agent, сервер аналитики не может завершить обработку, и в журналах сервера аналитики (wso2carbon.log) есть следующие исключения:
TID: [-1] [] [2017-10-10 10:55:17,292] ERROR {org.apache.spark.executor.Executor} - Exception in task 0.0 in stage 41522.0 (TID 32785) {org.apache.spark.executor.Executor}
java.sql.BatchUpdateException: Batch entry 0 INSERT INTO API_REQ_USER_BROW_SUMMARY (api, version, apiPublisher, tenantDomain, total_request_count, year, month, day, requestTime, os, browser) VALUES ('agenda.brussels', '0.0.2', 'admin', 'carbon.super', 1, 2017, 10, 10, 1507625491000, NULL, NULL) ON CONFLICT (api,version,apiPublisher,year,month,day,os,browser,tenantDomain) DO UPDATE SET total_request_count=EXCLUDED.total_request_count, requestTime=EXCLUDED.requestTime was aborted: ERROR: null value in column "os" violates not-null constraint
Detail: Failing row contains (agenda.brussels, 0.0.2, admin, carbon.super, 1, 2017, 10, 10, 1507625491000, null, null). Call getNextException to see other errors in the batch.
at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:145)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2156)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:460)
at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:793)
at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1659)
...
Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "os" violates not-null constraint
Detail: Failing row contains (agenda.brussels, 0.0.2, admin, carbon.super, 1, 2017, 10, 10, 1507625491000, null, null).
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
... 16 more
По-видимому, поле «os» считается непустым. API и клиенты являются общедоступными, поэтому у нас нет возможности принудительно выполнить запрос, отправленный от клиентов.
я бы увидел временные меры
- установите некоторое значение User-Agent, если оно пусто на уровне прокси-сервера http (я не уверен, что нам разрешено)
- возможно ли обновить сценарий обработки, чтобы использовать функцию объединения postgresql? (используется возврат некоторого значения по умолчанию нулевого аргумента).
Вопросы:
- это ошибка (известная/неизвестная) или мы что-то упустили? Если да, то каков наилучший способ ее решения?
Спасибо всем за любую подсказку