Welcome Guest, Not a member yet? Register   Sign In
Duplicate session id error in database table
#1

Hello!

We're using 3.1.5 with database sessions and we noticed that we would sometimes get the following error in the application logs:

Quote:ERROR - 2017-07-22 15:32:19 --> Query error: Duplicate entry '[session_id]' for key 'PRIMARY' - Invalid query: INSERT INTO `db_session` (`id`, `ip_address`, `timestamp`, `data`) VALUES ('[session_id]', ...)
ERROR - 2017-07-22 15:32:19 --> Severity: Warning --> Unknown: Failed to write session data (user). Please verify that the current setting of session.save_path is correct (db_session) Unknown 0

The system is deployed on a Linode server with CloudFlare enabled. There also doesn't seem to be any recognizable pattern--it just happens randomly.

This is from our config.php:

PHP Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'db_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'db_session';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE

And our MySQL database table:

Code:
CREATE TABLE IF NOT EXISTS `db_session` (
 `id` VARCHAR(40) NOT NULL,
`ip_address` VARCHAR(45) NOT NULL,
`timestamp` INT UNSIGNED NOT NULL DEFAULT 0,
`data` BLOB NOT NULL,
PRIMARY KEY (`id`),
INDEX `idx_db_session_timestamp` (`timestamp` ASC))
ENGINE = InnoDB;
 
We found posts suggesting the ip_address should also be a primary key, but this doesn't apply to us since we have sess_match_ip set to FALSE.

Any help would be appreciated.

Thanks!
Reply


Messages In This Thread
Duplicate session id error in database table - by parasabayan - 07-22-2017, 02:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB