roadrunner: [πŸ› BUG]: Fail to upload files

No duplicates πŸ₯².

  • I have searched for a similar issue in our bug tracker and didn’t find any solutions.

What happened?

When we tried to upload an image to our backend service the worker failed and the client received an HTTP 500 error message, the logs just stated that the file did not exist.

Our stack is running:

  • PHP 8.1
  • Laravel 9.28.0
  • Roadrunner 2.11.3
  • spiral/roadrunner-laravel 5.9.0

We noticed that the error happens before our code is even triggered, indicating that the issue happens while Laravel is building the request to send to out controller class. The error itself is triggered in the following file as part of the nyholm/psr7 library (I believe is a core dependency of Laravel or Synfony).

vendor/nyholm/psr7/src/Factory/Psr17Factory.php

It’s worth noting our applicating runs inside a Docker container.

Our roadrunner configuration:

version: "2.7"

server:
  command: "php /app/vendor/bin/rr-worker start"
  relay: pipes
  user: www-data
  group: www-data

rpc:
  listen: tcp://:6001

http:
  address: 0.0.0.0:8000
  pool:
    num_workers: 0
    max_jobs: 500
    supervisor:
      exec_ttl: 300s

logs:
  mode: production
  level: error
  encoding: json

status:
  address: localhost:2114

reload:
  interval: 1s
  patterns:
    - ".php"
  services:
    http:
      recursive: true
      ignore:
        - "bin"
        - "database"
        - "docs"
        - "logs"
        - "ops"
        - "storage"
        - "submodules"
        - "tests"
        - "tmp"
        - "vendor"
      patterns:
        - ".json"
        - ".md"
        - ".php"
        - ".py"
        - ".sh"
        - ".yml"
      dirs:
        - "."

I have checked the information provided in the caveats wiki section (which mentions a similar issue regarding the upload of files) and also the information in this issue.

I have also tried changing the isValid() function of the UploadedFile.php Synfony class and it also did not work

Thanks!

Version (rr --version)

2.11.3

Relevant log output

2022-10-06T15:35:18.412Z	DEBUG	server      	worker is allocated	{"pid": 13716, "internal_event_name": "EventWorkerConstruct"}

2022-10-06T15:35:18.416Z	INFO	server      	In Psr17Factory.php line 49:
   The file "/tmp/upload3578791433" cannot be opened:
 start [--laravel-path [LARAVEL-PATH]] [--relay-dsn RELAY-DSN] [--refresh-app] [--worker-mode WORKER-MODE]

2022-10-06T15:35:18.419Z	ERROR	http        	execute	{"start": "2022-10-06T15:35:18.158Z", "elapsed": "260.795709ms", "error": "sync_worker_exec_worker_with_timeout: Network:\n\tsync_worker_exec_payload: EOF"}

2022-10-06T15:35:18.419Z	INFO	http        	http log	{"status": 500, "method": "POST", "URI": "/2.0/user/update", "remote_address": "127.0.0.1:43024", "read_bytes": 360038, "write_bytes": 0, "start": "2022-10-06T15:35:18.158Z", "elapsed": "261.082333ms"}

nginx access_log 172.18.0.1 "POST /2.0/user/update HTTP/1.1" 500 "curl/7.79.1" 0 0.263

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (12 by maintainers)

Most upvoted comments

My pleasure πŸ‘πŸ» It’ll be fixed this week, and since we’re already started v2.12.0 preparation, I’ll release a v2.12.0-beta.1 with this fix, so you may safely use it.

Got it! For now I will keep running rr as root until this issue is fixed then.

Thanks @rustatian πŸ˜ƒ

@egonbraun Hey πŸ‘‹πŸ» I looked at this problem a bit deeper; RR sends a file link to the PHP worker. So, this is a RR bug.

Done! Thanks!

So, when the RR process creates a file in the tmp folder, it creates it with the root permissions. But child processes are created with a different user (www-data). Then, when a PHP process touches this file, it just has no permission to do that. In this case, I highly recommend using a regular user to start a RR with proper permissions.

Hey @egonbraun πŸ‘‹πŸ» Could you please try to remove:

server:
  command: "php /app/vendor/bin/rr-worker start"
  relay: pipes
  user: www-data <--- THIS
  group: www-data <--- THIS

I suspect, that there are not enough permissions to open the file.