rust/s3heap-service/README.md
The s3heap-service integrates with the function manager to trigger functions at no faster than a particular cadence, with reasonable guarantees that writing data will cause a function to run.
This document refines the design of the heap-tender and heap service until it can be implemented safely.
At the most abstract level, we have a heap and the sysdb. An item is either in the heap or not in the heap. For the sysdb, an item is not in the sysdb, in the sysdb and should be scheduled, or in the sysdb and waiting for writes to trigger the next scheduled run.
That gives this chart
| Heap State | Sysdb State |
|---|---|
| Not in heap | Not in sysdb |
| Not in heap | In sysdb, should be scheduled |
| Not in heap | In sysdb, waiting for writes |
| In heap | Not in sysdb |
| In heap | In sysdb, should be scheduled |
| In heap | In sysdb, waiting for writes |
And then one must take into account whether there's a function template.
More abstractly, view it like this:
| | On Heap | Not On Heap |
-------------------------|---------------------|------------|-------------| Has no function template | Not in sysdb | A_1 | A_2 | | In sysdb, scheduled | B_1 | B_2 | | In sysdb, waiting | C_1 | C_2 | -------------------------|---------------------|------------|-------------| Has function template | Not in sysdb | D_1 | D_2 | | In sysdb, scheduled | E_1 | E_2 | | In sysdb, waiting | F_1 | F_2 |
When viewed like this, we can establish rules for state transitions in our system. Each operation operates on either the sysdb or the heap, never both because there is no transactionality between S3 and databases. Thus, we can reason that we can jump to any row within the same column, or to another column within the same row.
Note that there are six base cases. Reasoning through all 36 cases and getting them right will be difficult. Instead, we aim to exploit symmetry: If there is a function template and something is in sysdb, it is as if there is no function template. As before, we can mark as trivially impossible anything that changes along two axes simultaneously. Anything listed as INVX is invariant X and is prohibited by the invariant.
From
| A_1 | A_2 | B_1 | B_2 | C_1 | C_2 | D_1 | D_2 | E_1 | E_2 | F_1 | F_2 | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| A_1 | - | INV2 | DEL1 | X | DEL1 | X | TT2 | X | X | X | X | X | |
| A_2 | STOP | - | X | GC | X | DEL1 | X | TT2 | X | X | X | X | |
| To | B_1 | INV1 | X | - | R1 | R1 | X | X | X | T2 | X | X | X |
| B_2 | X | ADD1 | INV4 | - | X | WT1 | X | X | X | T2 | X | X | |
| C_1 | INV1 | X | DO1 | X | - | INV4 | X | X | X | X | T2 | X | |
| C_2 | X | INV3 | X | DO2 | INV4 | - | X | X | X | X | X | T2 | |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ | |
| D_1 | TT1 | X | X | X | X | X | - | INV2 | INV6 | X | INV6 | X | |
| D_2 | X | TT1 | X | X | X | X | INV5 | - | X | INV6 | X | INV6 | |
| E_1 | X | X | TT1 | X | X | X | X | X | - | R1 | WT1 | X | |
| E_2 | X | X | X | TT1 | X | X | X | TT3 | INV4 | - | X | WT1 | |
| F_1 | X | X | X | X | TT1 | X | TT3 | X | DO1 | X | - | X | |
| F_2 | X | X | X | X | X | TT1 | X | HOLE2 | X | DO2 | INV4 | - |
Holes to overcomb/Unsurities: