You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I received the following error when generating 10 000 users via a seeder:
Database\Seeders\UsersTableSeeder .......................................................................... RUNNING
Illuminate\Database\UniqueConstraintViolationException
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'guest_yhxOYL' for key 'internet_accesses.internet_accesses_wifi_username_unique' (Connection: mysql, SQL: update `internet_accesses` set `wifi_password` = tFnMQeEO, `wifi_username` = guest_yhxOYL, `internet_accesses`.`updated_at` = 2024-06-04 16:19:30 where `user_id` = 8813)
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:808
804▕ // message to include the bindings with SQL, which will make this exception a
805▕ // lot more helpful to the developer instead of just the database's errors.
806▕ catch (Exception $e) {
807▕ if ($this->isUniqueConstraintError($e)) {
➜ 808▕ throw new UniqueConstraintViolationException(
809▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
810▕ );
811▕ }
812▕
+11 vendor frames
12 app/Models/Internet/InternetAccess.php:109
Illuminate\Database\Eloquent\Model::update()
13 app/Models/User.php:140
App\Models\Internet\InternetAccess::setWifiCredentials()
Process finished with exit code 1
Math problem: If you generate N guest wifi usernames with the scheme defined at User.php:140, what is the probability of generating two identical ones in the process? @kdmnk
My math is most probably off, but I think there are 62^6=56800235584 possible ids from Str::random(6).
According to this, it should have a 0.0008798 chance that the issue happens described by @Trigary. So we I will look into this a bit more.
This python script calculates the possibility of the problem described by @Trigary:
I received the following error when generating 10 000 users via a seeder:
The culprit is the following line: https://github.com/EotvosCollegium/mars/blob/development/app/Models/Internet/InternetAccess.php#L107C1-L107C100
The text was updated successfully, but these errors were encountered: