Conversation
lib/plug/application.ex
Outdated
|
|
||
| children = [ | ||
| Plug.Upload | ||
| Plug.Upload.Setup, |
There was a problem hiding this comment.
Instead of having a setup process, have a regular supervisor, do the init on the regular supervisor, and have PartitionSupervisor as the child of this new supervisor. :)
There was a problem hiding this comment.
Not used to doing any init work on supervisors because OTP live upgrades would scream if the supervisor init callback has side-effects. I know that generally Elixir doesn't encourage good-old-live-code-upgrades but still, the habit is very strong 👀
There was a problem hiding this comment.
Also, a supervisor doesn't give me a terminate callback to run where I can clean up the tables. I guess the workers could do it, and race between them like crazy, it's all idempotent 🤷🏽♂️
lib/plug/upload.ex
Outdated
| {tmp_roots, suffix} = :persistent_term.get(__MODULE__) | ||
| {mega, _, _} = :os.timestamp() | ||
| subdir = "/plug-" <> i(mega) <> "-" <> suffix | ||
| sec = System.system_time(:second) |
There was a problem hiding this comment.
let's avoid these changes as part of this PR for now, as they are unrelated?
cf5034d to
1f67add
Compare
|
@josevalim pushed a change according to your comments. Will cleanup those dummy timestamps in a separate follow-up PR 👍🏽 |
|
Just noticed CI
|
|
Check the OTP version and swap to auto if >= "26" (I think it was added on 25.1 or something) |
|
Also, can you please rebase? I found we were not covering a path, so I pushed new tests (and they should still pass on your branch). |
52903b0 to
4bba919
Compare
|
Rebased on top of the new master, and added the check for the OTP version. |
4bba919 to
de01d09
Compare
|
Oh, and added back trapping exits into the genserver, as we do want its |
|
@NelsonVides the terminate function means gen servers can race each other. Instead, add a Plug.Upload.Terminator before the PartitionSupervisor that simply traps exits and deletes everything on terminate. :) |
|
But that's what the |
|
Also, having a look at CI, |
|
The reason why I disliked setup is because it was creating ETS tables that was used by its siblings. I prefer to keep it within the hierarchy. Ideally, if supervisors had a terminate, we would terminate there, but since we don’t, we need the additional process only for termination! regarding the Elixir version, let’s require 1.14 and bump CI! |
de01d09 to
0ff0ef5
Compare
|
All right, pushed a new version, CI bump included 🤞🏽 |
|
💚 💙 💜 💛 ❤️ |
If we're serving a ton of multipart requests in parallel, or we're having any other use of this temporary random file, that genserver singleton shows up in profiles, becoming a bottleneck. Thought it could be parallelised quite a bit by using a pool of them in a
PartitionSupervisor, where the key is the owning process' pid.