Skip to content

Commit c2d4f4b

Browse files
committed
attempting to fix a regression in HistorySynchornizer
1 parent d3e0730 commit c2d4f4b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/mesh/agents/state/history/HistorySynchronizer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,6 @@ class HistorySynchronizer {
893893

894894
}
895895

896-
897-
898896
reqInfo.status = 'accepted-response';
899897

900898
await this.attemptToProcessLiterals(reqInfo);
@@ -968,6 +966,9 @@ class HistorySynchronizer {
968966

969967
reqInfo.nextOpSequence = reqInfo.nextOpSequence as number + 1;
970968

969+
await this.syncAgent.store.save(this.syncAgent.mutableObj); // Since we provided this obj to the context,
970+
// the store is gonna believe that it was already
971+
// saved, which may not be the actual case.
971972
await this.syncAgent.store.saveWithContext(literal.hash, reqInfo.receivedObjects as Context);
972973

973974
// FIXME: there's no validation of the op matching the actual causal history op

test/mesh/agents/state.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ async function syncInSmallPeerGroup(done: () => void, network: 'wrtc'|'ws'|'mix'
224224
const peerGroupAgent = pods[i].getAgent(PeerGroupAgent.agentIdForPeerGroup(peerNetworkId)) as PeerGroupAgent;
225225

226226
//let agent = new TerminalOpsSyncAgent(peerGroupAgent, s.hash(), stores[i], MutableSet.opClasses);
227-
let agent = new HeaderBasedSyncAgent(peerGroupAgent, s.hash(), await Resources.create({store: stores[i]}), MutableSet.opClasses);
227+
let agent = new HeaderBasedSyncAgent(peerGroupAgent, s.clone(), await Resources.create({store: stores[i]}), MutableSet.opClasses);
228228
let gossip = pods[i].getAgent(StateGossipAgent.agentIdForGossip(peerNetworkId)) as StateGossipAgent;
229229
gossip.trackAgentState(agent.getAgentId());
230230
//agent;
@@ -358,7 +358,7 @@ async function stagedSyncInSmallPeerGroup(done: () => void, network: 'wrtc'|'ws'
358358
for (let i=0; i<size; i++) {
359359
const meshAgent = pods[i].getAgent(PeerGroupAgent.agentIdForPeerGroup(peerNetworkId)) as PeerGroupAgent;
360360
//let agent = new TerminalOpsSyncAgent(meshAgent, s.hash(), stores[i], MutableSet.opClasses);
361-
let agent = new HeaderBasedSyncAgent(meshAgent, s.hash(), await Resources.create({store: stores[i]}), MutableSet.opClasses);
361+
let agent = new HeaderBasedSyncAgent(meshAgent, s.clone(), await Resources.create({store: stores[i]}), MutableSet.opClasses);
362362
let gossip = pods[i].getAgent(StateGossipAgent.agentIdForGossip(peerNetworkId)) as StateGossipAgent;
363363
gossip.trackAgentState(agent.getAgentId());
364364
//agent;
@@ -525,7 +525,7 @@ async function deepSyncInSmallPeerGroup(done: () => void, network: 'wrtc'|'ws'|'
525525
for (let i=0; i<size; i++) {
526526
const meshAgent = pods[i].getAgent(PeerGroupAgent.agentIdForPeerGroup(peerNetworkId)) as PeerGroupAgent;
527527
//let agent = new TerminalOpsSyncAgent(meshAgent, s.hash(), stores[i], MutableSet.opClasses);
528-
let agent = new HeaderBasedSyncAgent(meshAgent, s.hash(), await Resources.create({store: stores[i]}), MutableSet.opClasses);
528+
let agent = new HeaderBasedSyncAgent(meshAgent, s.clone(), await Resources.create({store: stores[i]}), MutableSet.opClasses);
529529
if (i===0) {
530530

531531
//syncAgent = agent;
@@ -739,7 +739,7 @@ async function diamondSyncInSmallPeerGroup(done: () => void, network: 'wrtc'|'ws
739739
for (let i=0; i<size; i++) {
740740
const meshAgent = pods[i].getAgent(PeerGroupAgent.agentIdForPeerGroup(peerNetworkId)) as PeerGroupAgent;
741741
//let agent = new TerminalOpsSyncAgent(meshAgent, s.hash(), stores[i], MutableSet.opClasses);
742-
let agent = new HeaderBasedSyncAgent(meshAgent, s.hash(), await Resources.create({store: stores[i]}), MutableSet.opClasses);
742+
let agent = new HeaderBasedSyncAgent(meshAgent, s.clone(), await Resources.create({store: stores[i]}), MutableSet.opClasses);
743743

744744
agent.synchronizer.controlLog = new Logger('synchronizer', LogLevel.INFO);
745745
agent.synchronizer.stateLog = new Logger('synchronizer', LogLevel.INFO);

test/storage/undo.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ async function testBasicUndoCycleWithSync(stores: Store[]) {
237237
const peerGroupAgent = pods[i].getAgent(PeerGroupAgent.agentIdForPeerGroup(peerNetworkId)) as PeerGroupAgent;
238238

239239
//let agent = new TerminalOpsSyncAgent(peerGroupAgent, s.hash(), stores[i], MutableSet.opClasses);
240-
let agent = new HeaderBasedSyncAgent(peerGroupAgent, permissions.hash(), await Resources.create({store: stores[i]}), permissions.getAcceptedMutationOpClasses());
240+
let agent = new HeaderBasedSyncAgent(peerGroupAgent, permissions.clone(), await Resources.create({store: stores[i]}), permissions.getAcceptedMutationOpClasses());
241241
let gossip = pods[i].getAgent(StateGossipAgent.agentIdForGossip(peerNetworkId)) as StateGossipAgent;
242242
gossip.trackAgentState(agent.getAgentId());
243243
//agent;
@@ -455,7 +455,7 @@ async function testMultiObjectUndoCascadeWithSync(stores: Store[]) {
455455
const peerGroupAgent = pods[i].getAgent(PeerGroupAgent.agentIdForPeerGroup(peerNetworkId)) as PeerGroupAgent;
456456

457457
//let agent = new TerminalOpsSyncAgent(peerGroupAgent, s.hash(), stores[i], MutableSet.opClasses);
458-
let agent = new HeaderBasedSyncAgent(peerGroupAgent, features.hash(), await Resources.create({store: stores[i]}), features.getAcceptedMutationOpClasses());
458+
let agent = new HeaderBasedSyncAgent(peerGroupAgent, features.clone(), await Resources.create({store: stores[i]}), features.getAcceptedMutationOpClasses());
459459
let gossip = pods[i].getAgent(StateGossipAgent.agentIdForGossip(peerNetworkId)) as StateGossipAgent;
460460
gossip.trackAgentState(agent.getAgentId());
461461
//agent;

0 commit comments

Comments
 (0)