I'm debugging an issue I got with synchronizing with a large dataset via Propel. The error that I got is the following:
SQLSTATE[42000]: Syntax error or access violation: 1461 Can't create more than max_prepared_stmt_count statements (current value: 16382)
I wrote a test script to see if I could isolate the problem, and the following script triggers the issue:
$conn = Propel::getConnection();
$conn->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, false);
$conn->useDebug(true);
//$conn = $conn->getWrappedConnection();
const MAX = 16382;
$i = MAX + 1;
while ($i--) {
$stmt = $conn->prepare('SELECT * FROM `User` LIMIT 1');
$stmt->execute();
$stmt->closeCursor();
}
If you either uncomment the getWrappedConnection line or set useDebug to false, the issue disappears. So it seems somehow useDebug has the effect that ConnectionWrapper doesn't properly close the prepared statements.
Note that prepared statement caching is explicitly turned off, so that is not the problem.
I'm debugging an issue I got with synchronizing with a large dataset via Propel. The error that I got is the following:
I wrote a test script to see if I could isolate the problem, and the following script triggers the issue:
If you either uncomment the
getWrappedConnection
line or setuseDebug
to false, the issue disappears. So it seems somehow useDebug has the effect that ConnectionWrapper doesn't properly close the prepared statements.Note that prepared statement caching is explicitly turned off, so that is not the problem.