RuntimeError: Failed to create session: 8dc29a95411be00600ec264701020100
I've added detailed logging to help identify the exact issue. The logs will now show:
- Exception details - The actual underlying exception
- Exception type - What kind of error occurred
- Session details - app_name, user_id being used
- Step-by-step progress - Each step of the save process
Symptom: relation "sessions" does not exist
Solution: Tables should be created automatically by Base.metadata.create_all(self.engine) in PostgresDBHelper.__init__. Check:
# In postgres_db_helper.py line 202
Base.metadata.create_all(self.engine)Manual check:
-- Connect to your database
psql postgresql://username:password@hostname:5432/database
-- Check if tables exist
\dt
-- Should show:
-- sessions
-- events
-- event_content_partsSymptom: Connection timeout, authentication failed
Check:
- Database URL is correct in
config.ini - Password is URL-encoded correctly (
%24for$) - Database is accessible from your network
Symptom: permission denied for table sessions
Solution: Ensure user has CREATE, INSERT, UPDATE permissions
Symptom: invalid input syntax for type jsonb or similar
Check:
stateis a valid dictionary/JSONevent_datais properly serialized
Symptom: duplicate key value violates unique constraint
Possible: Session ID already exists (should be handled by upsert logic)
After the error, look for:
Error creating session- Shows the underlying exceptionException type- What kind of errorError in _save_session- Database-level error
Set logging level to DEBUG:
import logging
logging.getLogger('google_adk').setLevel(logging.DEBUG)Or in your environment:
export PYTHONLOGLEVEL=DEBUGfrom google.adk.utils.postgres_db_helper import PostgresDBHelper
db_helper = PostgresDBHelper.get_instance()
with db_helper.get_session() as db:
# Test query
result = db.execute("SELECT 1")
print("Connection works!")-- Connect to database
psql postgresql://username:password@hostname:5432/database
-- Check table structure
\d sessions
-- Should show columns matching PostgresSession model-
Restart the server with the new logging
-
Make the same request that failed
-
Check the logs for:
Error creating session- full exception detailsException type- what type of errorError in _save_session- database error details
-
Share the full error traceback - it will show the exact line and cause
The enhanced logging will help identify whether it's:
- Database connection issue
- Table missing issue
- Data validation issue
- Permission issue
- Or something else