You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by "jujoramos (GitHub)" <gi...@apache.org> on 2019/12/04 09:55:28 UTC

[GitHub] [geode] jujoramos commented on issue #4385: GEODE-7497: Check CQs prior to change authorizer

Thanks for reviewing @jhuynh1 
Please find my answers below, inline for an easier follow-up.

> I thought clearing the local cq cache was needed if we updated the cq context with the new authorizer.

The CQ will always pick up the latest configured authorizer, no matter wether the `forceUpdate` flag is set as `true` or `false`, this logic is part of the `reset` method invoked by CQs during the execution. See [`CqServiceImpl.evaluateQuery`](https://github.com/apache/geode/blob/develop/geode-cq/src/main/java/org/apache/geode/cache/query/cq/internal/CqServiceImpl.java#L1604-L1607) and [`ExecutionContext.reset`](https://github.com/apache/geode/blob/develop/geode-core/src/main/java/org/apache/geode/cache/query/internal/ExecutionContext.java#L587-L591).

> If they have the old authorizer, why do we need to clear the cache?

If we don't clear the cache, the CQ won't be evaluated for those keys that are part of the cache, which can result in invoking `onEvent` instead of `onError` for the associated `CqListener`.

---

As an example, let's say the user has the CQ  `SELECT * from /testRegion object WHERE object.getId() > -1` running in the cluster, the configured `MethodInvocationAuthorizer` allows `getId` to be invoked. Some time passes and the CQ internal cache builds up to improve performance.
At that point the user decides to install a new `MethodInvocationAuthorizer` that doesn't allow `getId`. If we don't invalidate the internal CQ cache, the engine will invoke `onError` for events **that are not part of the internal cache** (the CQ will be executed) and `onEvent` for those events that **that are part of the internal cache** (the CQ won't be executed), which is not consistent.
Long story short, by invalidating the internal cache we make sure the CQ will be re-executed for every event  no matter what, and the execution itself will result in error if the newly configured authorizer doesn't allow the execution of methods present in the CQ expression.
Hope it makes sense now, please let me know your thoughts.
Cheers.

[ Full content available at: https://github.com/apache/geode/pull/4385 ]
This message was relayed via gitbox.apache.org for notifications@geode.apache.org