空用户代理导致sql异常列" os"违反非空约束

时间:2017-10-10 09:13:01

标签: wso2 wso2-am wso2-das

让WSO2AM(API Manager)2.1.0与Analytics服务器(在PostgreSQL上)我们看到以下问题:

如果客户端调用没有 User-Agent 标头的API,则分析服务器无法完成处理,并且在分析服务器的日志中(wso2carbon.log)存在以下例外情况:< / p>

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

显然&#34; os&#34;字段被假定为非空。 API和客户端是公共的,因此我们无法强制执行客户端发送的请求。

我看到临时措施

  • 在http代理级别设置一些User-Agent值为空(我不确定是否允许)
  • 更新处理脚本以使用coalesce postgresql函数是否可行? (返回使用null参数的一些默认值)。

问题:

  • 这是一个错误(已知/未知)还是我们错过了什么?如果是这样,解决它的最佳方法是什么?

感谢所有提示

0 个答案:

没有答案