-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[TT-5545] fix bug "issue when retrieving a list of keys attached to an api" #7623
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
base: master
Are you sure you want to change the base?
[TT-5545] fix bug "issue when retrieving a list of keys attached to an api" #7623
Conversation
|
API Changes --- prev.txt 2025-12-17 06:10:10.027317190 +0000
+++ current.txt 2025-12-17 06:10:00.421316623 +0000
@@ -8873,6 +8873,14 @@
CONSTANTS
const (
+
+ // KeyListingWorkerCount defines how many parallel goroutines we use to fetch key details.
+ KeyListingWorkerCount = 20
+
+ // KeyListingBufferSize defines the channel buffer size.
+ KeyListingBufferSize = 100
+)
+const (
LDAPStorageEngine apidef.StorageEngineCode = "ldap"
RPCStorageEngine apidef.StorageEngineCode = "rpc"
) |
|
This PR addresses a bug where the To handle potentially large numbers of keys efficiently, the key retrieval logic has been refactored to use a concurrent worker pool. This approach processes key session lookups in parallel, preventing the request from blocking for an extended period and improving performance. Additionally, the endpoint now respects Files Changed Analysis
Architecture & Impact Assessment
flowchart TD
A[GET /tyk/keys?api_id=...] --> B{api_id provided?};
B -- No --> C[Return all keys];
B -- Yes --> D[Fetch all key names from storage];
D --> E[Create Worker Pool & Job Channel];
E --> F[Feed key names to workers];
subgraph Concurrent Processing
G[For each key, worker fetches session & checks AccessRights]
end
F --> G;
G -- Has Access --> H[Add key to result list];
G -- No Access --> I[Discard key];
H --> J[Wait for all workers to complete];
I --> J;
J --> K[Return filtered & sorted key list];
Scope Discovery & Context Expansion
Metadata
Powered by Visor from Probelabs Last updated: 2025-12-17T06:16:42.153Z | Triggered by: pr_updated | Commit: 916bb1d 💡 TIP: You can chat with Visor using |
Security Issues (1)
Architecture Issues (1)
Performance Issues (2)
Quality Issues (1)
Powered by Visor from Probelabs Last updated: 2025-12-17T06:16:46.129Z | Triggered by: pr_updated | Commit: 916bb1d 💡 TIP: You can chat with Visor using |
42ca167 to
5270341
Compare
| } | ||
|
|
||
| sessionsObj := apiAllKeys{fixedSessions} | ||
| jobs := make(chan string, KeyListingBufferSize) |
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.
So if it's hard to fetch a couple of sessions in one query, extract this fetching block into a separate method please. Currently, it's hard to read.
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.
done, please re-review
2480bec to
916bb1d
Compare
|



Description
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
Ticket Details
TT-5545
Generated at: 2025-12-17 06:09:39