Skip to content

Commit 78b80db

Browse files
authored
Merge pull request #2003 from Permify/datawrite-on-conflict
fix: data write serialization error
2 parents d947b05 + b517294 commit 78b80db

File tree

6 files changed

+7
-16
lines changed

6 files changed

+7
-16
lines changed

docs/api-reference/apidocs.swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"info": {
44
"title": "Permify API",
55
"description": "Permify is an open source authorization service for creating fine-grained and scalable authorization systems.",
6-
"version": "v1.2.9",
6+
"version": "v1.3.0",
77
"contact": {
88
"name": "API Support",
99
"url": "https://github.com/Permify/permify/issues",

docs/api-reference/openapiv2/apidocs.swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"info": {
44
"title": "Permify API",
55
"description": "Permify is an open source authorization service for creating fine-grained and scalable authorization systems.",
6-
"version": "v1.2.9",
6+
"version": "v1.3.0",
77
"contact": {
88
"name": "API Support",
99
"url": "https://github.com/Permify/permify/issues",

internal/info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var Identifier = ""
2323
*/
2424
const (
2525
// Version is the last release of the Permify (e.g. v0.1.0)
26-
Version = "v1.2.9"
26+
Version = "v1.3.0"
2727
)
2828

2929
// Function to create a single line of the ASCII art with centered content and color

internal/storage/postgres/dataWriter.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type DataWriter struct {
3434
func NewDataWriter(database *db.Postgres) *DataWriter {
3535
return &DataWriter{
3636
database: database,
37-
txOptions: pgx.TxOptions{IsoLevel: pgx.ReadCommitted, AccessMode: pgx.ReadWrite},
37+
txOptions: pgx.TxOptions{IsoLevel: pgx.Serializable, AccessMode: pgx.ReadWrite},
3838
}
3939
}
4040

@@ -194,10 +194,6 @@ func (w *DataWriter) write(
194194
batch := &pgx.Batch{}
195195

196196
if len(tupleCollection.GetTuples()) > 0 {
197-
err = w.batchUpdateRelationships(batch, xid, tenantID, buildDeleteClausesForRelationships(tupleCollection))
198-
if err != nil {
199-
return nil, err
200-
}
201197
err = w.batchInsertRelationships(batch, xid, tenantID, tupleCollection)
202198
if err != nil {
203199
return nil, err
@@ -390,11 +386,6 @@ func (w *DataWriter) runOperation(
390386
) (err error) {
391387
slog.Debug("processing bundles queries")
392388
if len(tb.Write.GetTuples()) > 0 {
393-
deleteClauses := buildDeleteClausesForRelationships(&tb.Write)
394-
err = w.batchUpdateRelationships(batch, xid, tenantID, deleteClauses)
395-
if err != nil {
396-
return err
397-
}
398389
err = w.batchInsertRelationships(batch, xid, tenantID, &tb.Write)
399390
if err != nil {
400391
return err
@@ -443,7 +434,7 @@ func (w *DataWriter) batchInsertRelationships(batch *pgx.Batch, xid types.XID8,
443434
srelation = ""
444435
}
445436
batch.Queue(
446-
"INSERT INTO relation_tuples (entity_type, entity_id, relation, subject_type, subject_id, subject_relation, created_tx_id, tenant_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
437+
"INSERT INTO relation_tuples (entity_type, entity_id, relation, subject_type, subject_id, subject_relation, created_tx_id, tenant_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT ON CONSTRAINT uq_relation_tuple_not_expired DO NOTHING",
447438
t.GetEntity().GetType(), t.GetEntity().GetId(), t.GetRelation(), t.GetSubject().GetType(), t.GetSubject().GetId(), srelation, xid, tenantID,
448439
)
449440
}

pkg/pb/base/v1/openapi.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/base/v1/openapi.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
99
info: {
1010
title: "Permify API";
1111
description: "Permify is an open source authorization service for creating fine-grained and scalable authorization systems.";
12-
version: "v1.2.9";
12+
version: "v1.3.0";
1313
contact: {
1414
name: "API Support";
1515
url: "https://github.com/Permify/permify/issues";

0 commit comments

Comments
 (0)