I don’t remember the exact case, but I think this error happend to me when I tried to access the session (readSession()) within a custom writeSession(). Means Yii::app()->user->id will internally call readSession() of course.
To debug further, can you try removing the access to the user component? Like:
// $session->userId = Yii::app()->user->id;
$session->userId = 123;