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

Vyacheslav Koptilin updated IGNITE-12783:
-----------------------------------------
    Description: 
It seems that IGNITE-12206 does not cover all possible cases. For instance, the 
following cache configurations are still validated and therefore it may be the 
reason for erroneously warning.


{code:java}
 String grpName = "test-group";

CacheConfiguration<Object, Object> cfg1 = new CacheConfiguration<>("cache-1")
 .setBackups(1)
 .setGroupName(grpName);

CacheConfiguration<Object, Object> cfg2 = new CacheConfiguration<>("cache-2")
 .setBackups(1)
 .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new 
Duration(TimeUnit.SECONDS, 1)))
 .setGroupName(grpName);
{code}

The following code takes into account only the first cache configuration for a 
particular cache group:

{code:java|title=GridDhtPartitionsExchangeFuture#validatePartitionsState()}
 CacheGroupContext grpCtx = cctx.cache().cacheGroup(grpDesc.groupId());
 ...
 // Do not validate read or write through caches or caches with disabled 
rebalance
 // or ExpiryPolicy is set or validation is disabled.
 boolean eternalExpiryPolicy = grpCtx != null && 
(grpCtx.config().getExpiryPolicyFactory() == null
 || grpCtx.config().getExpiryPolicyFactory().create() instanceof 
EternalExpiryPolicy);
 
 if (grpCtx == null
 ...
 || !eternalExpiryPolicy
 return null; // It means that validation should not be triggered.
{code}

The obvious way to fix the issue is to check all the configurations included in 
the cache group as follows:

{code:java|title=GridDhtPartitionsExchangeFuture#validatePartitionsState()}
 CacheGroupContext grpCtx = cctx.cache().cacheGroup(grpDesc.groupId());
 ...
 boolean customExpiryPolicy = Optional.ofNullable(grpCtx)
 .map((v) -> v.caches())
 .orElseGet(() -> Collections.emptyList())
 .stream()
 .anyMatch(ctx -> ctx.expiry() != null && !(ctx.expiry() instanceof 
EternalExpiryPolicy));

if (grpCtx == null
 ...
 || customExpityPolicy
 return null; // It means that validation should not be triggered.
{code}

> Partition state validation warnings erroneously logged when cache groups are 
> used
> ---------------------------------------------------------------------------------
>
>                 Key: IGNITE-12783
>                 URL: https://issues.apache.org/jira/browse/IGNITE-12783
>             Project: Ignite
>          Issue Type: Bug
>    Affects Versions: 2.8
>            Reporter: Vyacheslav Koptilin
>            Assignee: Vyacheslav Koptilin
>            Priority: Minor
>             Fix For: 2.9
>
>
> It seems that IGNITE-12206 does not cover all possible cases. For instance, 
> the following cache configurations are still validated and therefore it may 
> be the reason for erroneously warning.
> {code:java}
>  String grpName = "test-group";
> CacheConfiguration<Object, Object> cfg1 = new CacheConfiguration<>("cache-1")
>  .setBackups(1)
>  .setGroupName(grpName);
> CacheConfiguration<Object, Object> cfg2 = new CacheConfiguration<>("cache-2")
>  .setBackups(1)
>  .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new 
> Duration(TimeUnit.SECONDS, 1)))
>  .setGroupName(grpName);
> {code}
> The following code takes into account only the first cache configuration for 
> a particular cache group:
> {code:java|title=GridDhtPartitionsExchangeFuture#validatePartitionsState()}
>  CacheGroupContext grpCtx = cctx.cache().cacheGroup(grpDesc.groupId());
>  ...
>  // Do not validate read or write through caches or caches with disabled 
> rebalance
>  // or ExpiryPolicy is set or validation is disabled.
>  boolean eternalExpiryPolicy = grpCtx != null && 
> (grpCtx.config().getExpiryPolicyFactory() == null
>  || grpCtx.config().getExpiryPolicyFactory().create() instanceof 
> EternalExpiryPolicy);
>  
>  if (grpCtx == null
>  ...
>  || !eternalExpiryPolicy
>  return null; // It means that validation should not be triggered.
> {code}
> The obvious way to fix the issue is to check all the configurations included 
> in the cache group as follows:
> {code:java|title=GridDhtPartitionsExchangeFuture#validatePartitionsState()}
>  CacheGroupContext grpCtx = cctx.cache().cacheGroup(grpDesc.groupId());
>  ...
>  boolean customExpiryPolicy = Optional.ofNullable(grpCtx)
>  .map((v) -> v.caches())
>  .orElseGet(() -> Collections.emptyList())
>  .stream()
>  .anyMatch(ctx -> ctx.expiry() != null && !(ctx.expiry() instanceof 
> EternalExpiryPolicy));
> if (grpCtx == null
>  ...
>  || customExpityPolicy
>  return null; // It means that validation should not be triggered.
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to