ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Valentin Kulichenko (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (IGNITE-3700) CacheWriter implementations should remove updated entries from the input collection
Date Tue, 16 Aug 2016 20:01:20 GMT

     [ https://issues.apache.org/jira/browse/IGNITE-3700?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Valentin Kulichenko updated IGNITE-3700:
----------------------------------------
    Description: 
According to {{CacheWriter}} JavaDoc, bulk operations ({{writeAll}} and {{deleteAll}}) should
remove successful entries from the input collection:

{code}
   * If this operation fails (by throwing an exception) after a partial success,
   * the writer must remove any successfully written entries from the entries
   * collection so that the caching implementation knows what succeeded and can
   * mutate the cache.
{code}

We properly handle this in the cache store manager and throw {{CachePartialUpdateException}}
with the list of keys not removed from the original collection. However, the implementations
provided by Ignite ({{CacheStoreAdapter}}, {{CacheAbstractJdbcStore}}, etc.) ignore this and
simply iterate through entries without removing successful ones.

Proper implementation should use {{Iterator}} and remove the entry after successful update:

{code}
@Override public void writeAll(Collection<Cache.Entry<? extends Integer, ? extends Integer>>
entries) throws CacheWriterException {
    Iterator<Cache.Entry<? extends Integer, ? extends Integer>> it = entries.iterator();

    while (it.hasNext()) {
        Cache.Entry<? extends Integer, ? extends Integer> entry = it.next();

        // Do actual update (can throw and exception).

        it.remove();
    }
}
{code}

  was:
According to {{CacheWriter}} JavaDoc, bulk operations ({{writeAll}} and {{deleteAll}}) should
remove successful entries from the input collection:

{code}
   * If this operation fails (by throwing an exception) after a partial success,
   * the writer must remove any successfully written entries from the entries
   * collection so that the caching implementation knows what succeeded and can
   * mutate the cache.
{code}

We properly handle this in the cache store manager and throw {{CachePartialUpdateException}}
with the list of keys not removed from the original collection. However, the implementations
provided by Ignite ({{CacheStoreAdapter}}, {{CacheAbstractJdbcStore}}, etc.) ignore this and
simply iterate through entries without removing successful ones.

Proper implementation should use {{Iterator}} and use it to remove the entry after successful
update:

{code}
@Override public void writeAll(Collection<Cache.Entry<? extends Integer, ? extends Integer>>
entries) throws CacheWriterException {
    Iterator<Cache.Entry<? extends Integer, ? extends Integer>> it = entries.iterator();

    while (it.hasNext()) {
        Cache.Entry<? extends Integer, ? extends Integer> entry = it.next();

        // Do actual update (can throw and exception).

        it.remove();
    }
}
{code}


> CacheWriter implementations should remove updated entries from the input collection
> -----------------------------------------------------------------------------------
>
>                 Key: IGNITE-3700
>                 URL: https://issues.apache.org/jira/browse/IGNITE-3700
>             Project: Ignite
>          Issue Type: Bug
>          Components: cache
>    Affects Versions: 1.7
>            Reporter: Valentin Kulichenko
>             Fix For: 1.8
>
>
> According to {{CacheWriter}} JavaDoc, bulk operations ({{writeAll}} and {{deleteAll}})
should remove successful entries from the input collection:
> {code}
>    * If this operation fails (by throwing an exception) after a partial success,
>    * the writer must remove any successfully written entries from the entries
>    * collection so that the caching implementation knows what succeeded and can
>    * mutate the cache.
> {code}
> We properly handle this in the cache store manager and throw {{CachePartialUpdateException}}
with the list of keys not removed from the original collection. However, the implementations
provided by Ignite ({{CacheStoreAdapter}}, {{CacheAbstractJdbcStore}}, etc.) ignore this and
simply iterate through entries without removing successful ones.
> Proper implementation should use {{Iterator}} and remove the entry after successful update:
> {code}
> @Override public void writeAll(Collection<Cache.Entry<? extends Integer, ? extends
Integer>> entries) throws CacheWriterException {
>     Iterator<Cache.Entry<? extends Integer, ? extends Integer>> it = entries.iterator();
>     while (it.hasNext()) {
>         Cache.Entry<? extends Integer, ? extends Integer> entry = it.next();
>         // Do actual update (can throw and exception).
>         it.remove();
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message