Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate key error during upload #23

Open
mzur opened this issue Nov 27, 2023 · 0 comments
Open

Fix duplicate key error during upload #23

mzur opened this issue Nov 27, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@mzur
Copy link
Member

mzur commented Nov 27, 2023

Now and then there is an error like this:

message" => """
    SQLSTATE[23505]: Unique violation: 7 ERROR:  duplicate key value violates unique constraint "storage_request_files_path_storage_request_id_unique"
    DETAIL:  Key (path, storage_request_id)=(myfilenamepath, 2128) already exists. (Connection: pgsql, SQL: insert into "storage_request_files" ("path", "size", "storage_request_id") values (myfilenamepath, 12071687, 2128) returning "id") ◀
    """
  "context" => array:2 [▼
    "userId" => 0000
    "exception" => array:6 [▼
      "class" => "Illuminate\Database\UniqueConstraintViolationException"
      "message" => """
        SQLSTATE[23505]: Unique violation: 7 ERROR:  duplicate key value violates unique constraint "storage_request_files_path_storage_request_id_unique"
        DETAIL:  Key (path, storage_request_id)=(myfilenamepath, 2128) already exists. (Connection: pgsql, SQL: insert into "storage_re ▶
        """
      "code" => 23505
      "file" => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:796"
      "trace" => array:71 [▼
        0 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:755"
        1 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:424"
        2 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:394"
        3 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/PostgresProcessor.php:24"
        4 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:3387"
        5 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1966"
        6 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1333"
        7 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1298"
        8 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1137"
        9 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php:342"
        10 => "/var/www/vendor/laravel/framework/src/Illuminate/Support/helpers.php:307"
        11 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php:343"
        12 => "/var/www/vendor/biigle/user-storage/src/Http/Controllers/Api/StorageRequestFileController.php:89"
        13 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:30"
        14 => "/var/www/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:469"
        15 => "/var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:353"
        16 => "/var/www/vendor/biigle/user-storage/src/Http/Controllers/Api/StorageRequestFileController.php:116"

Figure out why this happens and fix it. Maybe a request times out and the file is created in the backend but the frotend retries? A naive solution might be to check if the file already exists and send a special error message (or immediate success) that can be handled by the frontend. But maybe something else is amiss and should be fixed instead of patching just the symptom.

The request was sent by Safari. Maybe this is part of the problem.

@mzur mzur added the bug Something isn't working label Nov 27, 2023
@mzur mzur moved this to Medium Priority in BIIGLE Roadmap Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Medium Priority
Development

No branches or pull requests

1 participant