dcapwell commented on code in PR #2144:
URL: https://github.com/apache/cassandra/pull/2144#discussion_r1106463911
##########
src/java/org/apache/cassandra/service/accord/AccordStateCache.java:
##########
@@ -51,71 +55,107 @@
{
private static final Logger logger =
LoggerFactory.getLogger(AccordStateCache.class);
- private static class WriteOnlyGroup<K, V extends AccordState<K>>
+ public interface LoadFunction<K, V>
{
- private boolean locked = false;
- private List<AccordState.WriteOnly<K, V>> items = new ArrayList<>();
+ AsyncResult<Void> apply(K key, Consumer<V> valueConsumer);
Review Comment:
we need result *after* the apply, we don't need it before. The current
logic is
* before complete, call `consumer`
* save result to a `AsyncResult`
We are reinventing call backs, so rather than push it in, if we return a
`AsyncChain` it has the same semantics as
```
apply(key)
.accept(r -> this.value = r)
.beginAsResult()
```
> Looking at PendingLoad it looks like we are bad about handling the
exception case
This is also another reason to switch to `AsyncChain` as the API is supposed
to make us think about failures, so by trying to create custom callbacks in the
execution we ignore errors, leading to us putting the cache in a bad state that
later gets rejected (due to value being null)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]