I was having an issue adding session data to the database after deleting the current session (using $session->restart()). My session was removed but $this->_update_id was not set to NULL to allow inserting of a new session. The result is function _write issues an update query for a non existent session row.
I solved my issue by adding a line of code in database/classes/Kohana/Session/Database.php after
// Delete the cookie
Cookie::delete($this->_name);
//New line
$this->_update_id = NULL;
in _destroy.