Can't generate more then 5000 DOIs

We are digitalising a lot of old journals at once and publishing them via OJS, some of those journals have been running for almost 200 years so they have published a lot of articles over the time.
In some cases over 10000.

But when generating new DOIs only 5000 articles get an identifier.
The other articles are not listed in the Datacite Plugin nor do they have a DOI listed in the Database.
It is not an issue with DataCite itself since the DOIs are never generated in OJS so they are never send to DataCite.

This limit is per Journal. There is no issue with registering DOIs for multiple journals at once, even if they have over 5000 articles combined.

We ran into the 5000 articles limit in multiple journals so it is a per journal issue. Telling OJS to generate DOIs again does nothing.

I also checked if it could be a database issue but there is no indication for that. All limits of MariaDB are much higher and also all powers of 2 (so you would expect something like a 4096 or 8192 limit) but the number of DOI is exactly 5000.
It also can’t be a php timeout issue since I already had to increase those limits to be able to see published issues in the backend of OJS.
Also a timeout would not always happen exactly at 5000.

I did check the source code for the DOI and Datacite plugin but I couldn’t find any obvious limits in there.

OJS version 3.3.0.5
MariaDB 10.3.28