-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] graph server cache notifier mechanism is not working properly #2728
Comments
To address the issue with the graph server cache notifier mechanism, you can follow these steps:
The existing code already includes a mechanism to listen for cache events and handle invalid actions. Here is a relevant part of the code that ensures this functionality: private void listenChanges() {
this.cacheEventListener = event -> {
LOG.debug("Graph {} received graph cache event: {}", this.graph(), event);
Object[] args = event.args();
E.checkArgument(args.length > 0 && args[0] instanceof String, "Expect event action argument");
if (Cache.ACTION_INVALID.equals(args[0])) {
event.checkArgs(String.class, HugeType.class, Object.class);
HugeType type = (HugeType) args[1];
if (type.isVertex()) {
Object arg2 = args[2];
if (arg2 instanceof Id) {
Id id = (Id) arg2;
this.verticesCache.invalidate(id);
} else if (arg2 != null && arg2.getClass().isArray()) {
int size = Array.getLength(arg2);
for (int i = 0; i < size; i++) {
Object id = Array.get(arg2, i);
E.checkArgument(id instanceof Id, "Expect instance of Id in array, but got '%s'", id.getClass());
this.verticesCache.invalidate((Id) id);
}
} else {
E.checkArgument(false, "Expect Id or Id[], but got: %s", arg2);
}
} else if (type.isEdge()) {
this.edgesCache.clear();
}
return true;
} else if (Cache.ACTION_CLEAR.equals(args[0])) {
event.checkArgs(String.class, HugeType.class);
HugeType type = (HugeType) args[1];
this.clearCache(type, false);
return true;
}
return false;
};
EventHub graphEventHub = this.params().graphEventHub();
if (!graphEventHub.containsListener(Events.CACHE)) {
graphEventHub.listen(Events.CACHE, this.cacheEventListener);
}
} If the issue persists, further investigation into the event dispatching and handling logic across multiple graphs may be necessary. Ensure that the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other | Bug Report |
Bug Type (问题类型)
logic (逻辑设计问题)
Before submit
Environment (环境信息)
Expected & Actual behavior (期望与实际表现)
If we enable the RPC server and RPC client configurations in the rest-server.properties configuration file, intending to implement RPC communication among multiple Graph Servers to maintain cache data consistency, the current code logic does not support this functionality.
Existing Cache Notifier Mechanism:
In StandardHugegraph#registerRpcServices(), the HugeGraphCacheNotifier is registered as a service. During the construction of HugeGraphCacheNotifier, a cacheEventListener listening for Events.CACHE type events is added to the graphEventHub. This cacheEventListener specifically listens for actions of type Cache.ACTION_INVALIDATED.
In CachedGraphTransaction#listenChanges, another cacheEventListener is defined, which listens for Cache.ACTION_INVALID type events. However, when attempting to add this cacheEventListener to the graphEventHub, the current code logic checks whether there is already a listener for Events.CACHE type events in the graphEventHub. If one exists, it skips adding the new listener. As a result, the listener that should respond to Cache.ACTION_INVALID events is never added to the graphEventHub, causing the entire notifier mechanism to malfunction.
Proposed Fix:
Cache.ACTION_INVALID actions.
Vertex/Edge example (问题点 / 边数据举例)
Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
The text was updated successfully, but these errors were encountered: