title: WSO2 API Manager Analytics "Error on 'APIM_ACCESS_SUMMARY'. Error in adding events to 'ApiUserPerAppAgg_SECONDS'
body: <p>We are using WSO2 API Manager Analytics with a clustered API Manager configuration.
  We have only a worker and a dashboard (API Manager Analytics).
  After some times, we have this error</p>
  
  <pre><code>ERROR {org.wso2.siddhi.core.stream.input.source.InputEventHandler} - Error on 'APIM_ACCESS_SUMMARY'. Error in adding events to 'ApiUserPerAppAgg_SECONDS' store: Duplicate entry '1553785980000-1553785980000-/parix/2.0-api-extgw.umbriadigitale.' for key 'PRIMARY' Error in applying transport property mapping for 'inMemory' source at 'Request' stream. org.wso2.extension.siddhi.store.rdbms.exception.RDBMSTableException: Error on 'APIM_ACCESS_SUMMARY'. Error in adding events to 'ApiUserPerAppAgg_SECONDS' store: Duplicate entry '1553785980000-1553785980000-/parix/2.0-api-extgw.umbriadigitale.' for key 'PRIMARY'
      at org.wso2.extension.siddhi.store.rdbms.RDBMSEventTable.add(RDBMSEventTable.java:438)
      at org.wso2.siddhi.core.table.record.AbstractRecordTable.add(AbstractRecordTable.java:98)
      at org.wso2.siddhi.core.table.Table.addEvents(Table.java:139)
      at org.wso2.siddhi.core.aggregation.IncrementalExecutor.dispatchEvents(IncrementalExecutor.java:244)
      at org.wso2.siddhi.core.aggregation.IncrementalExecutor.dispatchAggregateEvents(IncrementalExecutor.java:212)
      at org.wso2.siddhi.core.aggregation.IncrementalExecutor.execute(IncrementalExecutor.java:119)
      at org.wso2.siddhi.core.aggregation.AggregationRuntime.processEvents(AggregationRuntime.java:350)
      at org.wso2.siddhi.core.aggregation.IncrementalAggregationProcessor.process(IncrementalAggregationProcessor.java:91)
      at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.processAndClear(ProcessStreamReceiver.java:186)
      at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.process(ProcessStreamReceiver.java:96)
      at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.receive(ProcessStreamReceiver.java:132)
      at org.wso2.siddhi.core.stream.StreamJunction.sendEvent(StreamJunction.java:179)
      at org.wso2.siddhi.core.stream.StreamJunction$Publisher.send(StreamJunction.java:380)
      at org.wso2.siddhi.core.stream.input.InputDistributor.send(InputDistributor.java:34)
      at org.wso2.siddhi.core.stream.input.InputEntryValve.send(InputEntryValve.java:44)
      at org.wso2.siddhi.core.stream.input.InputHandler.send(InputHandler.java:61)
      at org.wso2.siddhi.core.stream.input.source.PassThroughSourceHandler.sendEvent(PassThroughSourceHandler.java:35)
      at org.wso2.siddhi.core.stream.input.source.InputEventHandler.sendEvent(InputEventHandler.java:76)
      at org.wso2.siddhi.core.stream.input.source.PassThroughSourceMapper.mapAndProcess(PassThroughSourceMapper.java:66)
      at org.wso2.siddhi.core.stream.input.source.SourceMapper.onEvent(SourceMapper.java:136)
      at org.wso2.siddhi.core.stream.input.source.InMemorySource$1.onMessage(InMemorySource.java:66)
      at org.wso2.siddhi.core.util.transport.InMemoryBroker$MessageBroker.broadcast(InMemoryBroker.java:110)
      at org.wso2.siddhi.core.util.transport.InMemoryBroker$MessageBroker.publish(InMemoryBroker.java:117)
      at org.wso2.siddhi.core.util.transport.InMemoryBroker.publish(InMemoryBroker.java:41)
      at org.wso2.siddhi.core.stream.output.sink.InMemorySink.publish(InMemorySink.java:95)
      at org.wso2.siddhi.core.stream.output.sink.Sink.publish(Sink.java:135)
      at org.wso2.siddhi.core.stream.output.sink.PassThroughSinkMapper.mapAndSend(PassThroughSinkMapper.java:74)
      at org.wso2.siddhi.core.stream.output.sink.SinkMapper.mapAndSend(SinkMapper.java:165)
      at org.wso2.siddhi.core.stream.output.sink.SinkCallback.receive(SinkCallback.java:54)
      at org.wso2.siddhi.core.stream.output.StreamCallback.receive(StreamCallback.java:72)
      at org.wso2.siddhi.core.stream.StreamJunction.sendEvent(StreamJunction.java:156)
      at org.wso2.siddhi.core.stream.StreamJunction$Publisher.send(StreamJunction.java:375)
      at org.wso2.siddhi.core.query.output.callback.InsertIntoStreamCallback.send(InsertIntoStreamCallback.java:56)
      at org.wso2.siddhi.core.query.output.ratelimit.OutputRateLimiter.sendToCallBacks(OutputRateLimiter.java:88)
      at org.wso2.siddhi.core.query.output.ratelimit.PassThroughOutputRateLimiter.process(PassThroughOutputRateLimiter.java:46)
      at org.wso2.siddhi.core.query.selector.QuerySelector.process(QuerySelector.java:98)
      at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.processAndClear(ProcessStreamReceiver.java:186)
      at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.process(ProcessStreamReceiver.java:96)
      at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.receive(ProcessStreamReceiver.java:132)
      at org.wso2.siddhi.core.stream.StreamJunction.sendEvent(StreamJunction.java:179)
      at org.wso2.siddhi.core.stream.StreamJunction$Publisher.send(StreamJunction.java:380)
      at org.wso2.siddhi.core.stream.input.InputDistributor.send(InputDistributor.java:34)
      at org.wso2.siddhi.core.stream.input.InputEntryValve.send(InputEntryValve.java:44)
      at org.wso2.siddhi.core.stream.input.InputHandler.send(InputHandler.java:61)
      at org.wso2.siddhi.core.stream.input.source.PassThroughSourceHandler.sendEvent(PassThroughSourceHandler.java:35)
      at org.wso2.siddhi.core.stream.input.source.InputEventHandler.sendEvent(InputEventHandler.java:76)
      at org.wso2.extension.siddhi.map.wso2event.source.WSO2SourceMapper.mapAndProcess(WSO2SourceMapper.java:227)
      at org.wso2.siddhi.core.stream.input.source.SourceMapper.onEvent(SourceMapper.java:136)
      at org.wso2.extension.siddhi.io.wso2event.source.AgentCallbackImpl.receive(AgentCallbackImpl.java:72)
      at org.wso2.carbon.databridge.core.internal.queue.QueueWorker.run(QueueWorker.java:80)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: java.sql.BatchUpdateException: Duplicate entry '1553785980000-1553785980000-/api/2.0-api-extgw.xxxx.' for key 'PRIMARY'
      at sun.reflect.GeneratedConstructorAccessor81.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at com.mysql.cj.util.Util.handleNewInstance(Util.java:191)
      at com.mysql.cj.util.Util.getInstance(Util.java:166)
      at com.mysql.cj.util.Util.getInstance(Util.java:173)
      at com.mysql.cj.jdbc.exceptions.SQLError.createBatchUpdateException(SQLError.java:224)
      at com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchSerially(ClientPreparedStatement.java:870)
      at com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchInternal(ClientPreparedStatement.java:452)
      at com.mysql.cj.jdbc.StatementImpl.executeBatch(StatementImpl.java:814)
      at com.zaxxer.hikari.proxy.StatementProxy.executeBatch(StatementProxy.java:127)
      at com.zaxxer.hikari.proxy.HikariPreparedStatementProxy.executeBatch(HikariPreparedStatementProxy.java)
      at org.wso2.extension.siddhi.store.rdbms.RDBMSEventTable.batchExecuteQueriesWithRecords(RDBMSEventTable.java:1198)
      at org.wso2.extension.siddhi.store.rdbms.RDBMSEventTable.add(RDBMSEventTable.java:435)
      ... 54 more
  Caused by: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '1553785980000-1553785980000-/api/2.0-api-extgw.xxxx.' for key 'PRIMARY'
      at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:117)
      at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
      at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
      at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:970)
      at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1109)
      at com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchSerially(ClientPreparedStatement.java:849)
      ... 60 more
  </code></pre>
  
  <p>We are using MySQL as database. 
  At the beginning, we have supposed this problem was caused by the gateways. Anyway, even if we turn off one of these two gateways the problem happens again.
  Thank you for your support!</p>