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: data write serialization error #2003

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion docs/api-reference/apidocs.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "Permify API",
"description": "Permify is an open source authorization service for creating fine-grained and scalable authorization systems.",
"version": "v1.2.9",
"version": "v1.3.0",
"contact": {
"name": "API Support",
"url": "https://github.com/Permify/permify/issues",
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/openapiv2/apidocs.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "Permify API",
"description": "Permify is an open source authorization service for creating fine-grained and scalable authorization systems.",
"version": "v1.2.9",
"version": "v1.3.0",
"contact": {
"name": "API Support",
"url": "https://github.com/Permify/permify/issues",
Expand Down
2 changes: 1 addition & 1 deletion internal/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var Identifier = ""
*/
const (
// Version is the last release of the Permify (e.g. v0.1.0)
Version = "v1.2.9"
Version = "v1.3.0"
)

// Function to create a single line of the ASCII art with centered content and color
Expand Down
13 changes: 2 additions & 11 deletions internal/storage/postgres/dataWriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type DataWriter struct {
func NewDataWriter(database *db.Postgres) *DataWriter {
return &DataWriter{
database: database,
txOptions: pgx.TxOptions{IsoLevel: pgx.ReadCommitted, AccessMode: pgx.ReadWrite},
txOptions: pgx.TxOptions{IsoLevel: pgx.Serializable, AccessMode: pgx.ReadWrite},
}
}

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

if len(tupleCollection.GetTuples()) > 0 {
err = w.batchUpdateRelationships(batch, xid, tenantID, buildDeleteClausesForRelationships(tupleCollection))
if err != nil {
return nil, err
}
err = w.batchInsertRelationships(batch, xid, tenantID, tupleCollection)
if err != nil {
return nil, err
Expand Down Expand Up @@ -390,11 +386,6 @@ func (w *DataWriter) runOperation(
) (err error) {
slog.Debug("processing bundles queries")
if len(tb.Write.GetTuples()) > 0 {
deleteClauses := buildDeleteClausesForRelationships(&tb.Write)
err = w.batchUpdateRelationships(batch, xid, tenantID, deleteClauses)
if err != nil {
return err
}
err = w.batchInsertRelationships(batch, xid, tenantID, &tb.Write)
if err != nil {
return err
Expand Down Expand Up @@ -443,7 +434,7 @@ func (w *DataWriter) batchInsertRelationships(batch *pgx.Batch, xid types.XID8,
srelation = ""
}
batch.Queue(
"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)",
"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",
t.GetEntity().GetType(), t.GetEntity().GetId(), t.GetRelation(), t.GetSubject().GetType(), t.GetSubject().GetId(), srelation, xid, tenantID,
)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/pb/base/v1/openapi.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto/base/v1/openapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "Permify API";
description: "Permify is an open source authorization service for creating fine-grained and scalable authorization systems.";
version: "v1.2.9";
version: "v1.3.0";
contact: {
name: "API Support";
url: "https://github.com/Permify/permify/issues";
Expand Down