-
Notifications
You must be signed in to change notification settings - Fork 208
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
add incarnation
to transcriptStore spans and items
#7482
Comments
I think we can get away with not including the incarnation number in the transcript items table. I am not aware of any case where we query the items directly without first looking at bounds in the spans table. |
hm, true. I kinda like the idea of having them there, because it could make some future queries simpler to express. But it does add a tiny bit of complication to the |
I have a couple of nits to pick with this design. I think we should omit the index -- queries based on incarnation are going to be relatively rare and when they happen they will be in contexts that are not particularly performance sensitive. However, with an explicit index we'd be paying the cost of maintaining/updating that index on every database write to the transcript. If, in the highly unlikely event that we are experiencing some kind of perf bottleneck due to frequent incarnation-entangled queries, we can just add the index then, since doing so would be a transparent and backwards compatible change. Second, I don't think it's a win to remove management of the incarnation number from the
is a bit misleading since the kvStore is in the DB. Replacing the current |
Chatting with @FUDCo now:
Hm, not necessarily as part of this task, but we might consider removing |
What is the Problem Being Solved?
Our vat lifetimes are first broken up into "incarnations", separated by upgrades. When the vat is first created, we're in
incarnation = 0
. The firstE(adminFacet).upgrade()
that happens to the vat changes that toincarnation = 1
, etc.Note that this is a larger unit than a "span". Each time we write out a heap snapshot, we start a new span. There will be multiple spans within a single incarnation, if the vat worker uses heap snapshots, and it receives enough deliveries to justify a snapshot.
The new incarnation number is visible to userspace in the result of the
upgrade()
call ({ incarnatonNumber }
). The old value appears in thedisconnectObject
with which all the old incarnation's outstanding promises are rejected:{ name: 'vatUpgraded', upgradeMessage, incarnationNumber }
.A month-ish ago we realized that it would be nice if this value were also in the database. We'd like to be able to quickly extract all the transcript items from a single incarnation, and currently there is no convenient way to learn where the upgrade points were. In a pinch, you could scan the whole transcript for
startVat
deliveries, and then deduce that the upgrade must have happened about the same time, but we'd prefer something more deliberate/accurate, and which wouldn't require additional queries.Description of the Design
So we'd like to change the
transcriptItems
table from:to:
and the
transcriptSpans
table from:to:
plus we should add an index to support querying by vatid+incarnation:
The
incarnation
number should be initialized to0
duringinitTranscript
, adding it to the initial span record. Each time we add a new transcript entry (addItem()
), we should fetch theincarnation
from the current span and include it in the newtranscriptItems
row. It might be more efficient to do this with SQL query syntax than with multiple queries, or maybegetCurrentSpanBounds()
should return the currentincarnation
along with everything else, and then include it in the call tosqlAddItem
.We should add a boolean
rolloverIncarnation
argument torolloverSpan
, and increase theincarnation
number iff that argument is true. So the old span will be the last span of the old incarnation, and the new span record will use the next higher incarnation number. We'll callrolloverSpan(vatID, true)
fromvatKeeper.dropSnapshotAndResetTranscript()
, which is called from vat-warehouseresetWorker()
, which is called from kernel.jsprocessUpgradeVat()
. These functions should return the new incarnation number.vatKeeper.js > getIncarnationNumber
currently tracks this in the kvStore. This should change to track it in the DB, getting it fromtranscriptStore.getCurrentSpanBounds()
. VatKeeper'sincIncarnationNumber
should be removed. Thekernel.js
code that called it (fromprocessUpgradeVat
) should be removed, and replaced with the return value fromresetWorker
.Security Considerations
None, we're just adding an extra counter.
Scaling Considerations
None, the additional data is minimal. This will make it easier to delete old transcript items while retaining the ones needed for a sleeper-agent only-since-last-upgrade kind of upgrade, if/when we want to do that.
Release Priority Considerations
DB schema changes are always easier to make before deployment than after. This is a low-risk change that is highly likely to help us out in the future, and @FUDCo has some spare time, so we think we can get it landed before the release.
Test Plan
Unit tests in
swing-store
which callrolloverSpan
with both true and false, followed byaddItem
andgetCurrentSpanBounds()
calls to check that the incarnation number is as expected.Confirm that the incarnation numbers that appear in the vat-upgrade tests match the ones in the DB, probably by having
test/upgrade/test-upgrade.js
snoop thetranscriptStore.getCurrentSpanBounds()
before/after the upgrade.The text was updated successfully, but these errors were encountered: