ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gordon Reid (Nine Mile)" <gordon.r...@ninemilefinancial.com>
Subject CacheAbstractJdbcStore batch deleteAll bug.
Date Wed, 26 Apr 2017 02:05:01 GMT
Hi Guys,

I think there is a problem in CacheAbstractJdbcStore.deleteAll

I find that sometimes, I see messages like this

[DEBUG] 2017-04-26 11:08:54.097 [flusher-0-#31%null%] CacheJdbcPojoStore - Delete entries
from db [cache=D9Cache, keyType=com.nmf.model.trading.TradeKey, cnt=2]
[WARN ] 2017-04-26 11:08:54.097 [flusher-0-#31%null%] CacheJdbcPojoStore - Batch deleteAll
returned unexpected updated row count [table=public.nmfctrade, entry=RiskRuleKey [id=1], expected=1,
actual=0]
[WARN ] 2017-04-26 11:08:54.097 [flusher-0-#31%null%] CacheJdbcPojoStore - Batch deleteAll
returned unexpected updated row count [table=public.nmfctrade, entry=RiskRuleKey [id=2], expected=1,
actual=0]

Note the entity types are different!

Also look at the attached image. You can see the statement is still targeting Trade, but our
entity is now Position.

You can see in the code, that the delStmt never gets refreshed, when changing over to a different
entity type.


for (Object key : keys) {
    Object keyTypeId = typeIdForObject(key);

    em = entryMapping(cacheName, keyTypeId);

    if (delStmt == null) {
        delStmt = conn.prepareStatement(em.remQry);

        currKeyTypeId = keyTypeId;
    }

    if (!currKeyTypeId.equals(keyTypeId)) {
        if (log.isDebugEnabled())
            log.debug("Delete entries from db [cache=" + U.maskName(cacheName) +
                    ", keyType=" + em.keyType() + ", cnt=" + prepared + "]");

        executeBatch(em, delStmt, "deleteAll", fromIdx, prepared, lazyKeys);

        fromIdx += prepared;

        prepared = 0;

        currKeyTypeId = keyTypeId;

    }


I believe should be something like this


for (Object key : keys) {
    Object keyTypeId = typeIdForObject(key);

    em = entryMapping(cacheName, keyTypeId);

    if (delStmt == null) {
        delStmt = conn.prepareStatement(em.remQry);

        currKeyTypeId = keyTypeId;
    }

    if (!currKeyTypeId.equals(keyTypeId)) {
        if (log.isDebugEnabled())
            log.debug("Delete entries from db [cache=" + U.maskName(cacheName) +
                    ", keyType=" + em.keyType() + ", cnt=" + prepared + "]");

        executeBatch(em, delStmt, "deleteAll", fromIdx, prepared, lazyKeys);

        fromIdx += prepared;

        prepared = 0;

        currKeyTypeId = keyTypeId;

        delStmt = conn.prepareStatement(em.remQry);
    }

Thanks,
Gordon.


This email and any attachments are proprietary & confidential and are intended solely
for the use of the individuals to whom it is addressed. Any views or opinions expressed are
solely for those of the author and do not necessarily reflect those of Nine Mile Financial
Pty. Limited. If you have received this email in error, please let us know immediately by
reply email and delete from your system. Nine Mile Financial Pty. Limited. ABN: 346 1349 0252

Mime
View raw message