We reported issue with condition sets and conditio...
# permit-saas
y
We reported issue with condition sets and condition rules time out and slowness last week and it was fixed on Monday. Today we are experiencing issue with slowness. it times out 2-3 times even in UI and then it response back in 5-60 seconds. we have 64 condition sets which might grow to hundreds.
a
Hi @Yilmaz Alizadeh, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
I understand you're experiencing performance issues with condition sets and rules again. The timeouts and slow response times (5-60 seconds) with 64 condition sets are concerning. To help our engineers investigate this issue: 1. ​*Which Workspace / Project / Env are you using?*​ 2. ​*What calls are you performing?*​ (Please share the SDK code or CURL commands you're using) 3. ​*Which PDP version are you running?*​ 4. ​*Please share relevant logs from your PDP*​ Additionally, since you mentioned the UI is also timing out, could you specify if the slowness occurs during: • Creating/updating condition sets • Listing condition sets • Assigning permissions to sets • Evaluating policies that use these condition sets This information will help identify if this is related to the previous fix or a new issue with scaling to larger numbers of condition sets.
Feel free to tag me with additional questions. I also appreciate feedback, it helps me improve. 👍 button 👎 button
o
Hi @Yilmaz Alizadeh thanks for reaching out. Please provide the workspace/project/env in question, the URL of the API you’re seeing the delays with, and if you can what has changed between the “fixed” state and now Our team will investigate
Also note, your workspace (alex-trustflight-sandbox), is on our Startup tier - meaning it can only have up to 10 condition-sets . So you’re already in excess of your current plan , and there might be some QoS affect here, though there might be an underlying issue regardless which we would investigate, CC: @Natalia Edelson
l
Hmm our PM was in contact with you recently to upgrade our plan as we were receiving warnings. I'll ask them to get in touch. In the meantime here are our details: workspace = alex-trustflight-sandbox project = default env = dev
y
@Or Weis Just to confirm that our account is now upgraded to PRO but we still have the same issue. alex-trustflight-sandbox ->OneTrustFlight->Development is the one I am testing on.
image.png
:path /v2/schema/b0f64ab4b7a24e33ad80dc4d27384d9f/8c141b88d24241ce97e64ed2769e3d9f/condition_sets?type=resourceset&include_total_count=true
o
ack
l
We can pretty much no longer load your policy UI. For me it times out every time.
o
Thanks for letting us know, This is already queued up for the team to investigate. If you could address my question from before - of what has changed between the "fixed" state to now, it might help
l
Sorry, I missed that. At a guess it would be quantity of data. I think we have maybe 64 condition sets in there now whereas before it was probably ~20. I noticed it timing out occasionally yesterday but now it doesn't load at all.
o
The team thinks they found the culprit, a fix would like be in prod Sunday or Monday
l
Brilliant thank you!
I don't know if it's related to this problem but we're seeing extreme delays in new resource sets and their rules being propagated to our PDP, sometimes it's a few minutes, sometimes it's 20+ minutes. Even if we then update the rules for those sets the changes don't propagate. We know that the policy is configured because if we restart the PDP the checks immediately start behaving as expected.
Also this only happens on environments that have "more" data. For our environments that means it happens on
sandbox
-
lewis_development
&
default
-
dev
.
For environments that have less data, they update as expected. The reason I think this might be related to the same issue is because those are the environments that we were also seeing the issue with the policy page not loading (condition sets endpoint timing out).
o
Hi Lewis, we’ll investigate this new report and circle back to you. Are the changes you’re expecting policy (e.g. condition sets), or facts/data (e.g. role assignments, attribute values) ? If Data - as a intermediate side note, if you want to control/track how dynamic updates propagate to your PDP - we recommend using the “consistent updates” feature (note which APIs are covered by the feature)
Hi @Lewis Youl , I believe. the issue you’ve reported here is a result of temporary pressure on the system (following a DDOS attack, we get new variants of those from time to time), and the delays should subside now, as we’ve updated WAF settings; please let us know if you continue to see delays.
l
It's policy data, specifically it's new resource sets we're creating that aren't propagating and neither are any of the condition set rules we apply to them. We're still seeing the delays.
We are using "Send Consistent Updates". For clarity, does that functionality only work for "facts", and not policies? Think I answered my own question by reading this https://docs.permit.io/how-to/manage-data/local-facts-uploader/#supported-apis
o
CC: @Dan
d
Hey @Lewis Youl, can you please share the code you are using with the Consistent Updates, specifically the Permit instance initiation and the request/s lines that has the delays?
l
This is our permit initialization
Copy code
import { Permit } from 'permitio';

const permit = new Permit({
  token: process.env.PDP_API_KEY,
  pdp: process.env.PDP_URL,
  proxyFactsViaPdp: true,
  throwOnError: true
});

export default permit;
This is the SDK call that we make to create a condition set.
Copy code
await this.permit.api.conditionSets.create(conditionSet);
This is an example of the conditionSet we would send:
Copy code
{
  key: "document-58d83812-2a73-45b5-b431-ac890096a7b5-c8217bd9-ed07-4898-b455-f9c9eb615977-resource-set",
  name: "document with documentTypeId 58d83812-2a73-45b5-b431-ac890096a7b5 on c8217bd9-ed07-4898-b455-f9c9eb615977",
  description: "document with documentTypeId 58d83812-2a73-45b5-b431-ac890096a7b5 on c8217bd9-ed07-4898-b455-f9c9eb615977",
  type: "resourceset",
  resource_id: "document",
  conditions: {
    allOf: [
      {
        allOf: [
          {
            "resource.documentTypeId": {
              equals: "58d83812-2a73-45b5-b431-ac890096a7b5",
            },
          }, {
            "resource.tenant": {
              equals: "redacted",
            },
          }
        ],
      }
    ],
  },
}
To be clear, the requests execute fine and it seems that the data is correct in permit cloud (although we can't 100% tell because the UI and endpoints to return condition sets timeout until your deployment goes through today). The PDP just doesn't seem to get the update and as such, even if we configure rules between a user set and the newly created resource set those rules aren't applied for a very long time (or until we restart the PDP).
I've replicated this in our hosted env, which uses two PDPs but also locally in a simple single 1PDP setup.
d
Thank you for the details 🌟 Notice that this API call is not supported by the Consistent Updates APIs https://docs.permit.io/how-to/manage-data/local-facts-uploader/#supported-apis Creating or changing a condition set is a schema update, therefor requires a new policy generation. Are you using Custom GitOps with your project? Can you please share the full PDP logs that had the long delay described?
l
Notice that this API call is not supported by the Consistent Updates APIs
Yes I figured that out earlier in the thread.
Are you using Custom GitOps with your project?
No we aren't.
✅ 1
Here are the logs that the PDP receives when the new resource set is created. Appreciate the delay isn't huge here but I don't want to wait for ages until/if it gets populated.
As soon as I rebooted the pdp the permission checks work as expected which implies to me that whatever schema needed to be created does exist, it's just that the PDP never found out about it.
Appreciate that there are now sort of two bugs in this thread, I still can't access the policy page, any idea when that's going to be available today? https://permit-io.slack.com/archives/C02RTML2WNN/p1757074249150079
d
Thank you for the details. It may very likely be the case, I'll try to find if the policy update may not have been propagated correctly. It may be an error or some race between them. I'll deep dive into the PDP logs to investigate what's going on there. About the Condition Sets page, the fix is ready and is now on testing and review. It will be available on production soon, I'll keep you posted about it 🙏
👍 1
Hey@Lewis Youl, thank you for the PDP logs. Those are logs between 1127 1129 and during those 2 minutes there was no changes to the Condition Sets in your environment 😬 Can you please share more logs for the entire day or the entire lifetime of the PDP? 🙏
l
Sure, hopefully this helps.
d
Thank you. Those logs contain both logs from other containers in your system, like pgAdmin and NGINX. Would it be possible to filter only the PDP logs from your side? 🙌
I've managed to filter it out. Putting here for reference
l
Ah sorry about that, thank you for doing that.
d
Hey @Lewis Youl, the Condition Set page fix is available now on production. Can you please confirm it is working well for you now? 🌟
l
I'm afraid not, still getting a 502.
👀 1
d
Hey @Lewis Youl, sorry for the inconveniences. I too been able to reproduce it still on the
lewis_development
env. It seem to be an issue with the number of condition sets and the amount of resources, actions and roles they have. This issue is the Cartesian fanout that cause the query to return hundreds of thousands of rows and leading to a timeout or even a crash. Even after the previous optimizations, this environment still leads to a very large response and timeout. I'm continuing to work on it to find the right way to overcome it. Thank you for your patience and I'll keep you posted about the solution 🙏
l
OK thanks. I appreciate that I don't know/understand the underlying implementation (that's why we picked permit right?!) but what I do notice is that there's no pagination on this page, it tries to show everything to you.
In terms of a priority though, the problem with our PDP not updating with new condition sets is at the top of the list.
d
Roger that, I'll try to tackle them both ASAP
🙏 1
l
I'm getting the impression from your comment above that what this behaves like with larger datasets is unknown (I wouldn't consider the amount of data we've put into the system to be large yet). We've been facing these issues in our development (local) environments as well as our QA environment for a new tool. These environments currently have very little data in them compared to what we're likely to have once the product is used in anger so if it's struggling to handle this subset then I am rather concerned at how it's going to behave once we customers adding many of their own roles and resource instances.
d
That is a valid concern to raise. Your current environment has unusually large schema, consisting of hundreds of resources, roles and condition sets, while having very few data entires (users, resource instances, role assignments). Schema changes, compared to data, are translated by our platform into Rego files, uploaded to Github for SDLC management and synchronized in real-time to all PDPs connected to your environment. Schema changes does not tend to grow or correlate with the number of users. It can be considered as the "code logic" of your application - similar to deploying your code to new servers. The current schema you are managing is unusually high, taking the platform to new limits. That raise the question, if your current design is based on schema changes during production code, we should consider how we can make it more generic and use facts data as the stateful variability. Would you like please to describe your current design, what it is planned to include and how are you implementing it? We would help you plan how to design it to suit your needs best 🙂
y
@Dan Our design requirement is as follows: each Document X belongs to a Document Type Y. We want to grant a User U the ability to perform Action A either on a specific Document X or on all documents of a Document Type T. Permissions can therefore be granted at both the document level and the document type level. When fully implemented with all of our subsystems we might have 100s of actions and Document Types and Thousands of document instances. Users can receive permissions in two ways: Direct Permission assignment to the user. Indirect Permission assignment through membership in a user group. Additionally, each user should always have visibility over their own documents by default. To implement this, the pattern we’ve been following is: for each Document Type, we create a ResourceSet, The resource set Will have DocumentTypeId equals xxx . then we grant permissions between the UserSet with attribute groupId=xxxx-ggg-xxxx and the ResourceSet DocumentTypeId equals xxx by creating condition rule, consistent with the approach described in the Permit.io documentation. The direct permissions are being handled by using REBAC which works as expected. There will be additional attributes to have resource sets but this is the basic requirements we have for now. @Lewis Youl can you also check and add anything that I missed.
👀 1
l
That pretty much covers it. Probably worth adding that the user groups/sets are user defined (fundamentally they relate to tenant specific scoped roles), with each tenant in our application being able to create their own roles and then scope those roles to different entities within our system (it is this scoping that reflects the users sets/groups in permit), hence us testing with potentially large numbers of them. Users are also able to define their own document types (this will also be the case for many other types of resources as the application grows), so in the case of my development environment I have ~30 document types, which as Yilmaz has described above will result in 2 resource sets per document type (so 60 resource sets).
o
I think it’s best that we schedule some time together to better understand your policy, how to model it better. It sounds like there might be other approach that might be more suitable for you but I don’t know for sure so I prefer to better understand your policy before I recommend anything. Do you have any time available tomorrow or on Thursday?
l
Tomorrow works, how is 10:30/11 GMT?
o
10:30 sounds good, who should I invite ( you can send the emails on PM if you prefer )
l
I have DM'd you