feat: add support to realtime.messages binary payloads#1869
Conversation
This comment has been minimized.
This comment has been minimized.
| use Ecto.Migration | ||
|
|
||
| def change do | ||
| execute("ALTER TABLE realtime.messages ADD COLUMN IF NOT EXISTS binary_payload bytea") |
There was a problem hiding this comment.
How do we handle big binaries? I can simulate a OOM crash with this payload:
payload = :binary.copy(<<0>>, 900 * 1024 * 1024)
Postgrex.query!(
db,
"SELECT realtime.send($1::bytea, 'oom', 'adios', true)",
[payload]
)Running in a container with ~1.2GB free mem
There was a problem hiding this comment.
The process would reach the max heap size and crash before OOMing (The container must have a bit more memory than the max heap size we set)
Line 14 in ce7bd50
There was a problem hiding this comment.
Yep I was just concerned about exposing a possible scenario where one could try to send a really large bin for whatever reason.
There was a problem hiding this comment.
Oh yeah makes sense! We do have this protection to not let any single process kill the system. The assumption is that we have enough free memory to not hit the limit quickly 👍
1c999c5 to
2d0995c
Compare
2d0995c to
7f6b856
Compare
What kind of change does this PR introduce?
binary_payloadcolumn to realtime.messages with a constraint that only apply to new rows that checks that we can't havebinary_payloadANDpayloadNOT NULL at the same time. They can both be NULL though because we already allowedpayloadto be NULL so I didn't want to break anythiung. We could be more strict and ensure that one of them exclusively must be NULL.realtime.sendacceptingbyteaoverloading the existing function.