Skip to content
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

How to find the space when a user PUTs a CAR #95

Open
olizilla opened this issue Dec 13, 2022 · 2 comments
Open

How to find the space when a user PUTs a CAR #95

olizilla opened this issue Dec 13, 2022 · 2 comments

Comments

@olizilla
Copy link
Contributor

olizilla commented Dec 13, 2022

We will want to be able to show when a store/add is pending vs we have actually got the CAR.

The store/add dynamo table is currently partitioned by space DID, and the car CID is the sort key, so we enforce a unique car per space. This makes it cheap to find all cars for a space and terrible for finding a space by car CID.

We need some way to connect the ObjectCreated event we get from S3 back to the store/add invocation that enabled it.

Of note, we will need to handle the case where multiple independent store/add invocations are made for the same shard cid. We only skip providing a presigned url once an upload is fully written to s3. multiple callers could start writing at the same time.

@olizilla
Copy link
Contributor Author

The proposal that @Gozala re-shared is to write the store/add invocation to a bucket prefixed with the car cid like /${carCid}/${invocationCid}... so when we get an S3 ObjectCreated event we can go and list all the keys that start with the carCID to find the 1 or more invocations that got it there.

Alternatives are

  • another dynamo table keyed by carCid (same idea but state in a db)
  • a redis (same idea but state in a fast store)
  • encode the space or invocation CID into metadata in the query string in the presigned PUT URL.
    • the later is possible, but would need to prove that we get the metadata in the S3 event to deal with the case where the same shard is PUT from two different store/add invocations.

@olizilla
Copy link
Contributor Author

or we could add global secondary index on the the store/add table to let us find spaces by car.

{ partitionKey: 'link', sortKey: 'space' }

olizilla added a commit that referenced this issue Jan 4, 2023
adds an index to the store table using link as the partition key as a possible fix for #95 to let us find all the records for a given CAR CID.

TODO
- [ ] add method to store so we can query by link
- [ ] add tests

License: MIT
Signed-off-by: Oli Evans <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant