Felix Medina
08/20/2024, 1:14 PMerror={"message":"rpc error: code = InvalidArgument desc = update count of 510 is greater than maximum allowed of 500"}
We are having to process a query that attempts to update more than 500 items. The question is how to deal with this limit, I mean by hand by making sure that I do not process more that 500 items at a time or, is there another API for doing this in batches automatically?vroldanbet
08/20/2024, 1:30 PMvroldanbet
08/20/2024, 1:31 PMvroldanbet
08/20/2024, 1:32 PMFelix Medina
08/20/2024, 1:33 PMFelix Medina
08/20/2024, 1:37 PMWriteRelationships and BulkImportRelationshipsRequest can deal with rigth? Is just 500 for the first one and 10K for the second one, right?vroldanbet
08/20/2024, 1:59 PMFelix Medina
08/20/2024, 2:08 PMWriteRelationships in batches, right?
Something like:
`// ... (assuming you have a slice of relationship updates called updates)
const maxUpdatesPerBatch = 500
for i := 0; i < len(updates); i += maxUpdatesPerBatch {
batchEnd := i + maxUpdatesPerBatch
if batchEnd > len(updates) {
batchEnd = len(updates)
}
batch := updates[i:batchEnd]
// Make the SpiceDB write call with the 'batch' slice
err := authzedClient.WriteRelationships(ctx, batch...)
if err != nil {
// Handle the error appropriately
}
}`
We reckon we won't be dealing with a lot of large transactions but ocasitionaly we will have to process a fewyetitwo
08/20/2024, 2:55 PM