Non-Transaction Write is not allowing the configuration of max parallelization
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
Direzione di ricerca
Inizia da src/main/java/dev/openfga/sdk/api/configuration/ClientWriteOptions.java e dal percorso di scrittura non transazionale intorno alle righe 415-417 di OpenFgaClient.java. Confronta la configurazione e i valori predefiniti Java con le implementazioni di riferimento in Go, JS e .NET; il lavoro è completato quando maxParallelRequests è configurabile e la dimensione del blocco della transazione usa il valore predefinito previsto senza modificare il comportamento di scrittura esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Please do not report security vulnerabilities here. See the Responsible Disclosure Program.
Thank you in advance for helping us to improve this library! Please read through the template below and answer all relevant questions. Your additional work here is greatly appreciated and will help us respond as quickly as possible.
By submitting an issue to this repository, you agree to the terms within the OpenFGA Code of Conduct.
Description
Provide a clear and concise description of the issue, including what you expected to happen.
The Java SDK ClientWriteOptions https://github.com/openfga/java-sdk/blob/main/src/main/java/dev/openfga/sdk/api/configuration/ClientWriteOptions.java#L17 do not expose a method to set the parallization for non-transactional writes.
Equivalent JS interface: https://github.com/openfga/js-sdk/blob/main/client.ts#L190-L196
Equivalent .NET interface: https://github.com/openfga/dotnet-sdk/blob/main/src/OpenFga.Sdk/Client/Model/ClientWriteOptions.cs#L53
Equivalent Go interface: https://github.com/openfga/go-sdk/blob/main/client/client.go#L1416-L1429
The maxParallelRequests is supposed to define how many requests are sent in paralllel.
When your application sends multiple non-transactional write requests (let's say you send N of them), the SDK doesn't send them all individually. Instead, it groups them into smaller batches and sends these batches with a controlled amount of parallelization.
Here's how it should work:
-
Batching Requests:
- The SDK first divides your N requests into M "chunks" or batches.
- The size of each chunk is determined by the transaction chunk size, which defaults to 1 request per chunk.
- So, if you have 100 requests and the default chunk size is 1, you'll end up with 100 individual chunks (M = 100 / 1 = 100).
- The formula for calculating M is: $M = \text{integer}(\text{N / transaction chunk size} + 1)$. The "+1" ensures that any remainder requests also get their own chunk.
-
Limited Parallel Processing (Worker Queue):
- Once the requests are batched, the SDK sends them out with limited parallelization. This means it doesn't try to send all M chunks at once.
- It only allows a maximum number of requests to be active (in progress) at any given time. This limit is called maxParallelRequests, and it defaults to 10.
- Think of it like a worker queue:
- The SDK starts by sending out up to 10 requests simultaneously (if M is 10 or more).
- As soon as any of those active requests finishes, the SDK immediately sends out the next request from the queue. It doesn't wait for all 10 active requests to complete before sending more. This keeps the processing flow continuous and efficient.
- Note: that this queue is per-Write request, so we're not queuing all the requests in the SDK.
In essence, the SDK intelligently batches your non-transactional writes and processes them in a controlled, concurrent manner to optimize performance without overwhelming the system.
Alt SDK implementations of the feature:
- Go: https://github.com/openfga/go-sdk/blob/main/client/client.go#L1661-L1720
- JS: https://github.com/openfga/js-sdk/blob/main/client.ts#L520-L560
- .NET: https://github.com/openfga/dotnet-sdk/blob/main/src/OpenFga.Sdk/Client/Client.cs#L226-L282
Additionally, the Java SDK seems to be using the DEFAULT_MAX_METHOD_PARALLEL_REQS for the transaction chunksize, confusing the two: https://github.com/openfga/java-sdk/blob/main/src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java#L415-L417. Max chunk size should default to 1 if not set: https://github.com/openfga/dotnet-sdk/blob/main/src/OpenFga.Sdk/Client/Client.cs#L195-L197
Version of SDK
v0.8.3
Version of OpenFGA (if known)
N/A
OpenFGA Flags/Custom Configuration Applicable
N/A
Reproduction
Detail the steps taken to reproduce this error, what was expected, and whether this issue can be reproduced consistently or if it is intermittent.
- Initialize OpenFgaClient with openfga_sdk.ClientConfiguration parameter api_host=127.0.0.1, credentials method client_credentials
- Invoke method read_authorization_models
- See exception thrown
Sample Code the Produces Issues
Backtrace (if applicable)
Expected behavior
When Write is called in non-transaction mode, the SDK should
Additional context
- Lingua principale
- Java
- Stelle
- 55
- Fork
- 26
- Merge medio
- 1g 22h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di openfga/java-sdk
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Make client-credentials token refresh buffer and jitter configurableForse già presa @dpkass l’ha presa 27 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
openfga/java-sdk#370 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
openfga/java-sdk#361 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di openfga/java-sdk
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
java-native-access/jna#1740 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
portfolio-performance/portfolio#6119 ·
I maintainer di solito rispondono entro 8 giorni
-
Bump up AWS SDK to 2.54.3Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
jenkinsci/ec2-plugin#2041 ·
-
L: github:actions L: php:composer
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
dependabot/dependabot-core#16493 ·
I maintainer di solito rispondono entro 1 giorno