casbin / xorm-adapter

Xorm adapter for Casbin
https://github.com/casbin/casbin
Apache License 2.0
384 stars 58 forks source link

[Question] Can I configure casbin xorm to "skip" table creation ? #56

Closed atreyamj closed 1 year ago

atreyamj commented 1 year ago

What's your scenario? What do you want to achieve? I am creating a cached enforcer in casbin and using XORM to store my policies to store my policies on a cloud managed Postgres DB. It looks like casbin internally calls : https://github.com/xormplus/xorm/blob/master/session_schema.go#L236 whenever it wants to connect to the DB and to determine whether the table needs to be created or not. This query is long running seems to cause time outs on our end.

Question - Is there any way I can specify casbin to NOT create the tables and assume that the table is created and skip this call altogether ? Or is there any other way we can work around the time outs?

Thank You!

casbin-bot commented 1 year ago

@tangyang9464 @JalinWang

hsluoyz commented 1 year ago

@atreyamj what adapter do you use?

atreyamj commented 1 year ago

@hsluoyz , we use XORM adapter with Cloud Managed YugabyteDB ( Postrges) On more deep dive - this is more of a yugabyte issue than XORM. The reason why it fails is because, XORM queries the metadata tables to determine whether it needs to create a table or not. However, the metadata table query operations are too slow in Yugabyte. Hence, was wondering if there is a way to just to skip metadata table query for checking whether XORM should create the table or not?

Essentially Is there a way, I can ask XORM to assume the table already exists instead of trying determine if it needs to create the table by querying the metadata tables?

casbin-bot commented 1 year ago

@tangyang9464 @JalinWang @imp2002

hsluoyz commented 1 year ago

@PokIsemaine

atreyamj commented 1 year ago

@hsluoyz and @thekartikeyamishra , thank you so much for your responses. Apologies in the delay in my response as I was away.

I will try your suggestions of custom adapter and if that doesnt work will circle back on the PR. :)

Really appreciate the responses ! Also, to re-iterate this is NOT a casbin issue but rather a DB issue. Hence the request to see if we can have connection without having to create table via casbin.

I think the custom adapter should fix it.

hsluoyz commented 1 year ago

Closed for now