mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
Server: more logs and fix possible race when resyncing with more peers
This commit is contained in:
@@ -102,11 +102,20 @@ public class AutosyncProcessor {
|
||||
JObjectKey finalName = name;
|
||||
boolean ok = txm.run(() -> {
|
||||
var obj = remoteTx.getMeta(finalName).orElse(null);
|
||||
if (obj == null) return true;
|
||||
if (obj.hasLocalData()) return true;
|
||||
if (obj == null) {
|
||||
Log.debugv("Not downloading object {0}, not found", finalName);
|
||||
return true;
|
||||
}
|
||||
if (obj.hasLocalData()) {
|
||||
Log.debugv("Not downloading object {0}, already have local data", finalName);
|
||||
return true;
|
||||
}
|
||||
var data = remoteTx.getData(JDataRemote.class, finalName);
|
||||
return data.isPresent();
|
||||
});
|
||||
if (ok) {
|
||||
Log.debugv("Downloaded object {0}", name);
|
||||
}
|
||||
if (!ok) {
|
||||
Log.debug("Failed downloading object " + name + ", will retry.");
|
||||
_retries.add(name);
|
||||
|
||||
@@ -105,7 +105,10 @@ public class InvalidationQueueService {
|
||||
|
||||
for (var e : data) {
|
||||
// TODO: Race?
|
||||
if (peerInfoService.getPeerInfo(e.peer()).isEmpty()) continue;
|
||||
if (!peerInfoService.existsPeer(e.peer())) {
|
||||
Log.warnv("Will ignore invalidation of {0} to {1}, peer not found", e.key(), e.peer());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!remoteHostManager.isReachable(e.peer())) {
|
||||
deferredInvalidationQueueService.defer(e);
|
||||
|
||||
@@ -72,6 +72,7 @@ public class OpPusher {
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
Log.debugv("Pushing invalidation: entry {0}, sending {1}", entry, info);
|
||||
remoteObjectServiceClient.pushOps(entry.peer(), info);
|
||||
txm.run(() -> {
|
||||
var obj = curTx.get(JData.class, entry.key()).orElse(null);
|
||||
|
||||
@@ -49,6 +49,16 @@ public class PeerInfoService {
|
||||
|
||||
}
|
||||
|
||||
public boolean existsPeer(PeerId peer) {
|
||||
return jObjectTxManager.run(() -> {
|
||||
var gotKey = getTreeR().traverse(List.of(JKleppmannTreeNodeMetaPeer.peerIdToNodeId(peer).name()));
|
||||
if (gotKey == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public Optional<PeerInfo> getPeerInfo(PeerId peer) {
|
||||
return jObjectTxManager.run(() -> {
|
||||
var gotKey = getTreeR().traverse(List.of(JKleppmannTreeNodeMetaPeer.peerIdToNodeId(peer).name()));
|
||||
|
||||
Reference in New Issue
Block a user