Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
Release Branch 4.0, Trunk
-
None
-
None
-
any
-
Bug Crush Event - 21/2/2015
Description
org.ofbiz.webapp.stats.ServerHitBin.saveHit(...) causes transactions to be aborted due to duplicate PKs.
The problem is that said method will try to create two or more entries with identical startTimes (i.e. duplicate hitStartDateTime and the other fields composing the PK: visitId, contentId, hitStartDateTime, hitTypeId) if two or more subsequent requests are made in a sufficiently small interval. This can and will be the case for example if an application rapidly issues requests for similar data. It would usually not be observed when human users cause requests being issued.
The cause is that the above mentioned method uses
serverHit.create();
to store the entries.
A solution to this is to create or update an existing entry, thus overwriting an existing entry in case there already was an entry, but more importantly avoiding the actual transaction being aborted. This may not satisfy those who want to record each and every server hit even with equal startTimes. For these cases other approaches might be considered ...
This is an example where a transaction fails due to saveHit(...). In our case an applet tries to pull data off the server and fails ...
Failure in create operation for entity [ServerHit]: org.ofbiz.entity.GenericEntityException: Error while inserting: [GenericEntity:ServerHit][contentId,gdm.getProductFeatureApplAttrs(java.lang.String)][createdStamp,2009-02-24 10:34:29.454(java.sql.Timestamp)][createdTxStamp,2009-02-24 10:34:29.454(java.sql.Timestamp)][hitStartDateTime,2009-02-24 10:34:29.443(java.sql.Timestamp)][hitTypeId,REQUEST(java.lang.String)][lastUpdatedStamp,2009-02-24 10:34:29.454(java.sql.Timestamp)][lastUpdatedTxStamp,2009-02-24 10:34:29.454(java.sql.Timestamp)][partyId,KR(java.lang.String)][referrerUrl,(java.lang.String)][requestUrl,https://127.0.0.1:8443/gdm/control/getProductFeatureApplAttrs(java.lang.String)][runningTimeMillis,8(java.lang.Long)][serverHostName,Kitty(java.lang.String)][serverIpAddress,192.168.1.70(java.lang.String)][userLoginId,karim(java.lang.String)][visitId,11900(java.lang.String)] (SQL Exception while executing the following:INSERT INTO SERVER_HIT (VISIT_ID, CONTENT_ID, HIT_START_DATE_TIME, HIT_TYPE_ID, NUM_OF_BYTES, RUNNING_TIME_MILLIS, USER_LOGIN_ID, STATUS_ID, REQUEST_URL, REFERRER_URL, SERVER_IP_ADDRESS, SERVER_HOST_NAME, LAST_UPDATED_STAMP, LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP, INTERNAL_CONTENT_ID, PARTY_ID, ID_BY_IP_CONTACT_MECH_ID, REF_BY_WEB_CONTACT_MECH_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (Duplicate entry '11900-gdm.getProductFeatureApplAttrs-2009-02-24 10:34:29-REQUEST' for key 'PRIMARY')). Rolling back transaction.
Exception: org.ofbiz.entity.GenericEntityException
This issue seems to be related (it refers to the releae branch 4.0 and the same error shows up):
Attachments
Attachments
Issue Links
- is duplicated by
-
OFBIZ-3972 user of tenant generate errors on entity Server_Hit
- Closed
-
OFBIZ-1148 Bug when it register the visit in the tables with mysql 5
- Closed
- is related to
-
OFBIZ-9337 Update msyql sql-type for datetime field-type to support Fractional Seconds in Time Values
- Closed