diff --git a/internal/datastore/memdb/memdb.go b/internal/datastore/memdb/memdb.go index 1e48ab3aa2..e23a7f3560 100644 --- a/internal/datastore/memdb/memdb.go +++ b/internal/datastore/memdb/memdb.go @@ -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. @@ -154,7 +154,7 @@ func (mdb *memdbDatastore) ReadWriteTx( defer mdb.Unlock() if mdb.activeWriteTxn != nil { - err = errSerialization + err = ErrSerialization return } @@ -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 diff --git a/internal/datastore/memdb/revisions_test.go b/internal/datastore/memdb/revisions_test.go index 1fc9784c0e..fc91edbba0 100644 --- a/internal/datastore/memdb/revisions_test.go +++ b/internal/datastore/memdb/revisions_test.go @@ -27,5 +27,5 @@ func TestHeadRevision(t *testing.T) { } func (mdb *memdbDatastore) ExampleRetryableError() error { - return errSerialization + return ErrSerialization } diff --git a/internal/datastore/proxy/observable.go b/internal/datastore/proxy/observable.go index 5d1ebcb039..7837487a8e 100644 --- a/internal/datastore/proxy/observable.go +++ b/internal/datastore/proxy/observable.go @@ -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) { diff --git a/internal/datastore/proxy/observable_test.go b/internal/datastore/proxy/observable_test.go new file mode 100644 index 0000000000..9644c82cdd --- /dev/null +++ b/internal/datastore/proxy/observable_test.go @@ -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) { + 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 +}