feat: add space diff table new gsi for cause#609
Conversation
View stack outputs
|
hannahhoward
left a comment
There was a problem hiding this comment.
LGTM, but please fix the TODO comment -- it's confusing.
| const existingDiffs = await spaceDiffStore.listByCause(cause, { size: 1 }) | ||
| const causeAlreadyExists = (existingDiffs.ok?.results?.length ?? 0) > 0 | ||
|
|
||
| // TODO: Should we fail the entire transaction if the cause already exists? |
There was a problem hiding this comment.
pretty sure no -- we're writing to the blob registry in this function no? assuming there are cases where we are putting to the blob registry but for whatever reason the cause is already in the diff table -- I don't htink we should be failing the whole register function. -- probably worth putting a rationale rather than leaving as an open question in a TODO comment.
d69f514 to
2a3ebc1
Compare
According to this storacha/RFC#78 (related issue storacha/project-tracking#307)
This PR implements the short term solution, adding a GSI on
causeto the existingspace-difftable. It then uses that GSI to check if a diff with the samecausealready exists before writing a new one. If it does, we just skip the write.This approach:
Limitation: this is a best-effort guard. It adds a read-before-write step and doesn’t fully guarantee uniqueness (there’s still a small chance of a race condition).