Unless a new code-block-specific limit has been introduced recently (and not talked about), the limit is for the whole post, not specifically for a code block. If you pasted code in and didn't hit the limit, and then you formatted it as code and did hit the limit, that's because of the additional four spaces added to each line (which is how a line in a code block is signified in markdown). I've had that happen a couple times before, when improving the formatting on existing long posts.
If you decide you really do want to have that much text in a code block (or several code blocks), then a possible workaround is to use HTML rather than markdown to format it. You can put
<pre><code> at the beginning of the first line of text that you want to format as code, and
</code></pre> at the end of the last line.
If you do this, then you should make sure there isn't anything that's interpreted as HTML in the block itself, because unlike when you prefix every line with four spaces, characters like
< do get interpreted specially inside
<pre><code> tags you put in yourself. (This is actually the main use case for using those tags -- if you need to apply special formatting to code, for a purpose other than what automatic syntax highlighting will achieve.)
On the one hand, you might not want to have that much code in a post! But sometimes it may be reasonable to put lots of text from the terminal, or
dmesg, or something in a post. Ubuntu Pastebin and other paste sites are handy and should definitely be preferred for truly enormous amounts of text (like, beyond the 30,000 character limit), but they do run the risk of creating what might be called a "link-only question"--there is no guarantee pastes will survive forever, even if they are never manually deleted. I believe it usually depends on how long it's been since they've been viewed.
A single code block on Ask Ubuntu is styled so it doesn't take up too much vertical space -- instead of getting tall, it gets a scroll bar. Eventually, posts will start to make the page lag on slower devices, but that's more a feature of what is in the post -- just a few animated images, for example, will probably cause more users' devices to lag on the page than 30,000 characters of text. There should be some limit to the length of a post, but it should not be short, because if it were then quite a few good-quality posts couldn't exist. For example, I would not want this answer to have been prevented from existing.
It's certainly possible for a whole answer to come up against the character limit, even a good answer that isn't needlessly long. This happens on the Stack Exchange network from time to time, especially for answers that need to provide lots of information, quoted from different sources, need to give their own explanatory context, and the URLs for the sources are themselves really long. I'm thinking particularly of this answer on English Language & Usage. But I'm not familiar with situations where the markdown of a post really needed to be quite that long here on Ask Ubuntu.
Unless there's evidence that anyone is having significant problems using the system to create good-quality posts, a simple limit of 30,000 characters seems reasonable to me. At least as of now, I don't think there's any reason to make it smaller (as you seem to be suggesting), or bigger, or to make things way more complicated by having a separate total or individual limit for code blocks. This isn't something that needs fixing.