zenstackhq / zenstack

Fullstack TypeScript toolkit enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
1.83k stars 78 forks source link

[Feature Request] Create throws RESULT_NOT_READABLE when MySQL transaction_isolation is not "READ-UNCOMMITTED" #1523

Open OiAnthony opened 1 week ago

OiAnthony commented 1 week ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] Create throws RESULT_NOT_READABLE when MySQL transaction_isolation is not "READ-UNCOMMITTED"

Describe the solution you'd like A clear and concise description of what you want to happen.

  1. Check MySQL transaction_isolation, when transaction_isolation is not equal to "Read-Uncommitted", LOG warning
  2. Create and readBack Shouldn't it appear in the same thing? Dirty reading may appear

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered. At present, I took the initiative to change MySQL transaction_isolation to "Read-Uncommitted"

Additional context Add any other context or screenshots about the feature request here. image

ymc9 commented 1 day ago

Hi @OiAnthony , thanks for reporting this. Yes, ZenStack relies on reading uncommitted changes to enforce access policies. For the specific case of checking readability after creating, we can do the read after committing the create, but there're other cases where reading uncommitted changes is needed. I'll see if we can detect the current transaction settings, and will at least add something to the documentation about it.