-
Notifications
You must be signed in to change notification settings - Fork 279
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
Add subject filters in schema relation delete to force use of the index #2131
Add subject filters in schema relation delete to force use of the index #2131
Conversation
@@ -11,64 +11,305 @@ import ( | |||
"github.com/authzed/spicedb/pkg/datastore" | |||
"github.com/authzed/spicedb/pkg/schemadsl/compiler" | |||
"github.com/authzed/spicedb/pkg/schemadsl/input" | |||
"github.com/authzed/spicedb/pkg/tuple" | |||
) | |||
|
|||
func TestApplySchemaChanges(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are missing a test with wildcards
internal/services/shared/schema.go
Outdated
|
||
subjectSelectors := make([]datastore.SubjectsSelector, 0, len(previousRelation.TypeInformation.AllowedDirectRelations)) | ||
for _, allowedType := range previousRelation.TypeInformation.AllowedDirectRelations { | ||
if allowedType.GetRelation() != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this worked by happenstance, but the ellipsis was not being handled correctly, as it's not modeled as empty string at this level of the stack, but ...
.
There is also no explicit handling of wildcards, but my understanding is that's modeled as an userset_object_id = *
, but userset_relation = ""
, so it ended up falling in ellipsis branch, which would generate the wrong SubjectRelationFilter
.
I've force-pushed the changes, let me know what you think
This should allow for much faster queries under the transaction. We observed some customers reporting timeouts when writting a new schema and dropping a relation because it ended up in full table scans.
1d18f98
to
e8ad9bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I force pushed the changes, if you think they look fine, we can approve this.
We have some examples on how to test for Datastore API calls selecting specific indexes, I'd suggest adding a test to make sure this does not regress, but also confirm that what we wanted to achieve actually is happening.
This should allow for much faster queries under the transaction