claudehohl / Stikked

An advanced and beautiful pastebin written in PHP
992 stars 220 forks source link

DISCUSSION (maybe not be a bug): "MySQL server has gone away" with very large paste upload #567

Open elyograg opened 2 years ago

elyograg commented 2 years ago

I am starting here because it is this package where I ran into the problem. I don't think this is really a bug in Stikked, and may not be a bug in php or mysql either, just a very unusual use case.

For testing purposes with haproxy doing QUIC/HTTP3, I tried uploading a very large amount of data in a paste. It was 105842 lines, over 28MiB in size. I got a "MySQL server has gone away" exception in the apache error log.

What turned out to be the problem was that MySQL's max_allowed_packet was configured at 16M, which I believe is a very common recommended setting. I bumped that to 64M, restarted mysql, and then the paste upload worked.

Questions which this group may not be able to answer: Does the php mysqli module provide a way to do a large INSERT query like this with multiple packets so that it doesn't go over the limit? Does mysql itself have support for that?

I wonder if it might be a good idea for the Stikked UI to indicate that very large pastes may fail, and if it has any way to detect what the limit is, to display a max allowed size.