Skip to content

Commit d15cbb9

Browse files
committed
fix(SwingSet): Tolerate absence of a kpid from maybeFreeKrefs
...on suspicion that it absence stems database rollback after a failed delivery koid absence was already tolerated.
1 parent 6f1145f commit d15cbb9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

packages/SwingSet/src/kernel/kernel.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,8 +1458,16 @@ export default function buildKernel(
14581458
queueToKref(vatAdminRootKref, method, args, 'logFailure');
14591459
}
14601460

1461-
kernelKeeper.processRefcounts();
14621461
const crankNum = kernelKeeper.getCrankNumber();
1462+
const { lostObjects } = kernelKeeper.processRefcounts();
1463+
if (lostObjects.length) {
1464+
console.log(
1465+
`⚠️ Ignoring lost objects from crankNum ${crankNum}`,
1466+
lostObjects,
1467+
message,
1468+
crankResults,
1469+
);
1470+
}
14631471
kernelKeeper.incrementCrankNumber();
14641472
const { crankhash, activityhash } = kernelKeeper.emitCrankHashes();
14651473
finish({

packages/SwingSet/src/kernel/state/kernelKeeper.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,12 +1614,17 @@ export default function makeKernelKeeper(
16141614
// leaving work for the next delivery.
16151615

16161616
function processRefcounts() {
1617+
const lostObjects = [];
16171618
if (enableKernelGC) {
16181619
const actions = new Set();
16191620
for (const kref of maybeFreeKrefs.values()) {
16201621
const { type } = parseKernelSlot(kref);
16211622
if (type === 'promise') {
16221623
const kpid = kref;
1624+
if (!hasKernelPromise(kpid)) {
1625+
lostObjects.push(kref);
1626+
continue;
1627+
}
16231628
const kp = getKernelPromise(kpid);
16241629
if (kp.refCount === 0) {
16251630
let idx = 0;
@@ -1645,6 +1650,9 @@ export default function makeKernelKeeper(
16451650
// deleted). Message delivery should use that, but not us.
16461651
const ownerKey = `${kref}.owner`;
16471652
let ownerVatID = kvStore.get(ownerKey);
1653+
if (!ownerVatID) {
1654+
lostObjects.push(kref);
1655+
}
16481656
const terminated = terminatedVats.includes(ownerVatID);
16491657

16501658
// Some objects that are still owned, but the owning vat
@@ -1706,6 +1714,7 @@ export default function makeKernelKeeper(
17061714
addGCActions([...actions]);
17071715
}
17081716
maybeFreeKrefs.clear();
1717+
return { lostObjects };
17091718
}
17101719

17111720
function createVatState(vatID, source, options) {

0 commit comments

Comments
 (0)