One can easy avoid issues like that by not upgrading to new MariaDB, PHP and even new Nextcloud major releases on day one. I have long since moved to a more conservative strategy when it comes to upgrading Nextcloud and it’s main dependencies. This way I was able to avoid many of the problems that came up here in the forums. I am still on NC 21.0.3, MariaDB 10.3 and PHP7.4 on my production instance and I run a seperate instance, where I test new versions of Nextcloud and it’s dependencies before I upgrade my main instance.
Why is that nod ideal? As for MariaDB, each major release is supported for 5 years. And Nextcloud itself always supports at least the two or three latest versions of MariaDB. So there is no reason to upgrade immediately just because there is a new number on it.