Skip to content

PDOException: Thrown PDOException: SQLSTATE[HY000]: General error: 1 table SimpleSAMLphp_tableVersion already exists #2460

@rjain21

Description

@rjain21

What is Happening

Our VA.GOV Logs are filled with the following exception.

PDOException: Thrown PDOException: SQLSTATE[HY000]: General error: 1 table SimpleSAMLphp_tableVersion already exists in /var/www/cms/docroot/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/Store/SQLStore.php:188

Partial Stack Trace


#0 /var/www/cms/docroot/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/Store/SQLStore.php(188): PDO->exec()
#1 /var/www/cms/docroot/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/Store/SQLStore.php(88): SimpleSAML\Store\SQLStore->initTableVersionTable()
#2 /var/www/cms/docroot/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/Store/StoreFactory.php(53): SimpleSAML\Store\SQLStore->__construct()
#3 /var/www/cms/docroot/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/SessionHandler.php(143): SimpleSAML\Store\StoreFactory::getInstance()
#4 /var/www/cms/docroot/vendor/simplesamlphp/simplesamlphp/src/SimpleSAML/SessionHandler.php(45): SimpleSAML\SessionHandler::createSessionHandler()
...

Source of Error

The error seems to be originating from this line which, upon a Select for existence create a Table no matter the exception. However there could be many reasons that the Select Statement can fail (I am not an expert but I would assume so).

Suggested fix

Option 1: Use CREATE TABLE IF NOT EXISTS instead.
Option2: Some fine grained error checking

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions