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

Store less data in Cassandra prefix buckets #7199

Merged
merged 4 commits into from
Aug 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions physical/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,18 @@ func (c *CassandraBackend) Put(ctx context.Context, entry *physical.Entry) error

// Execute inserts to each key prefix simultaneously
stmt := fmt.Sprintf(`INSERT INTO "%s" (bucket, key, value) VALUES (?, ?, ?)`, c.table)
results := make(chan error)
buckets := c.buckets(entry.Key)
for _, _bucket := range buckets {
go func(bucket string) {
results <- c.sess.Query(stmt, bucket, entry.Key, entry.Value).Exec()
}(_bucket)
results := make(chan error, len(buckets))
for i, _bucket := range buckets {
go func(i int, bucket string) {
var value []byte
if i == len(buckets)-1 {
// Only store the full value if this is the leaf bucket where the entry will actually be read
// otherwise this write is just to allow for list operations
value = entry.Value
}
results <- c.sess.Query(stmt, bucket, entry.Key, value).Exec()
}(i, _bucket)
}
for i := 0; i < len(buckets); i++ {
if err := <-results; err != nil {
Expand Down Expand Up @@ -296,8 +302,8 @@ func (c *CassandraBackend) Delete(ctx context.Context, key string) error {
defer metrics.MeasureSince([]string{"cassandra", "delete"}, time.Now())

stmt := fmt.Sprintf(`DELETE FROM "%s" WHERE bucket = ? AND key = ?`, c.table)
results := make(chan error)
buckets := c.buckets(key)
results := make(chan error, len(buckets))

for _, bucket := range buckets {
go func(bucket string) {
Expand Down