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

fix: delete options not being passed #1784

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions internal/datastore/memdb/memdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
numAttempts = 10
)

var errSerialization = errors.New("serialization error")
var ErrSerialization = errors.New("serialization error")

// DisableGC is a convenient constant for setting the garbage collection
// interval high enough that it will never run.
Expand Down Expand Up @@ -154,7 +154,7 @@ func (mdb *memdbDatastore) ReadWriteTx(
defer mdb.Unlock()

if mdb.activeWriteTxn != nil {
err = errSerialization
err = ErrSerialization
return
}

Expand All @@ -181,7 +181,7 @@ func (mdb *memdbDatastore) ReadWriteTx(
}

// If the error was a serialization error, retry the transaction
if errors.Is(err, errSerialization) {
if errors.Is(err, ErrSerialization) {
mdb.Unlock()

// If we don't sleep here, we run out of retries instantaneously
Expand Down
2 changes: 1 addition & 1 deletion internal/datastore/proxy/observable.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (rwt *observableRWT) DeleteRelationships(ctx context.Context, filter *v1.Re
))
defer closer()

return rwt.delegate.DeleteRelationships(ctx, filter)
return rwt.delegate.DeleteRelationships(ctx, filter, options...)
}

func (rwt *observableRWT) BulkLoad(ctx context.Context, iter datastore.BulkWriteRelationshipSource) (uint64, error) {
Expand Down
28 changes: 28 additions & 0 deletions internal/datastore/proxy/observable_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package proxy

import (
"testing"
"time"

"github.com/authzed/spicedb/internal/datastore/memdb"
"github.com/authzed/spicedb/pkg/datastore"
"github.com/authzed/spicedb/pkg/datastore/test"
)

type observableTest struct{}

func (obs observableTest) New(revisionQuantization, _, gcWindow time.Duration, watchBufferLength uint16) (datastore.Datastore, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this makes it so we test all of the Datastore tests with the Observable proxy, and more specifically the DeleteWithLimitTest which verifies the fix in this PR

db, err := memdb.NewMemdbDatastore(watchBufferLength, revisionQuantization, gcWindow)
if err != nil {
return nil, err
}
return NewObservableDatastoreProxy(db), nil
}

func TestObservableProxy(t *testing.T) {
test.All(t, observableTest{})
}

func (p *observableProxy) ExampleRetryableError() error {
return memdb.ErrSerialization
}
Loading