laravel / pennant

A simple, lightweight library for managing feature flags.
https://laravel.com/docs/pennant
MIT License
478 stars 49 forks source link

Database driver could support high frequency requests #101

Closed potsky closed 5 months ago

potsky commented 5 months ago

Database driver does not work at scale, we have thousand of SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "features_name_scope_unique" because of the driver architecture when you have thousand requests per seconds.

As advised by @timacdonald in https://github.com/laravel/pennant/pull/77, we could use an upsert instead of an insert.

Perhaps aninsert in a try catch (UniqueConstraintViolationException) should do the job because it is not really important to update the record several times in a single request...

timacdonald commented 5 months ago

Thanks for opening this one, @potsky. As we discussed, we will likely look at doing this via upserts to help with this issue.

timacdonald commented 5 months ago

I've opened a PR to address this issue. Thanks for reporting it. I'll close this now and we can track the PR.

timacdonald commented 5 months ago

This has been tagged and merged. Let me know if you hit this again, but we should be in the clear now.