﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31400	base.py returns TypeError when CONN_MAX_AGE is set in a Postgresql connection	danb4r	Hasan Ramezani	"Just did a clean Django 3.0.4
Python 3.6.9, install with
Postgresql Version: 10+190ubuntu0.1 via psycopg2 (2.8.4)
inside Windows Subsystem for Linux.

When I run:
{{{
python manage.py migrate
}}}

I get:
{{{
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/db/backends/base/base.py"", line 192, in connect
    self.close_at = None if max_age is None else time.monotonic() + max_age
TypeError: unsupported operand type(s) for +: 'float' and 'str'
}}}

The error does not happen with CONN_MAX_AGE not set:
{{{
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'django_p1_master',
        'USER': 'django',
        'PASSWORD': 'secret',
        'HOST': '127.0.0.1',
        'PORT': '5432',
#        'CONN_MAX_AGE': '600',
    }
}
}}}

Full error stack:

{{{
(venv-django_p1) vmuser@REDBEAST:/mnt/c/usr/workspace/django_p1/dsite$ python manage.py migrate
Traceback (most recent call last):
  File ""manage.py"", line 21, in <module>
    main()
  File ""manage.py"", line 17, in main
    execute_from_command_line(sys.argv)
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/core/management/__init__.py"", line 401, in execute_from_command_line
    utility.execute()
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/core/management/__init__.py"", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/core/management/base.py"", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/core/management/base.py"", line 369, in execute
    output = self.handle(*args, **options)
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/core/management/base.py"", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/core/management/commands/migrate.py"", line 86, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/db/migrations/executor.py"", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/db/migrations/loader.py"", line 49, in __init__
    self.build_graph()
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/db/migrations/loader.py"", line 212, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/db/migrations/recorder.py"", line 76, in applied_migrations
    if self.has_table():
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/db/migrations/recorder.py"", line 56, in has_table
    return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/utils/asyncio.py"", line 26, in inner
    return func(*args, **kwargs)
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/db/backends/base/base.py"", line 260, in cursor
    return self._cursor()
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/db/backends/base/base.py"", line 236, in _cursor
    self.ensure_connection()
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/utils/asyncio.py"", line 26, in inner
    return func(*args, **kwargs)
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/db/backends/base/base.py"", line 220, in ensure_connection
    self.connect()
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/utils/asyncio.py"", line 26, in inner
    return func(*args, **kwargs)
  File ""/mnt/c/usr/workspace/django_p1/venv-django_p1/lib/python3.6/site-packages/django/db/backends/base/base.py"", line 192, in connect
    self.close_at = None if max_age is None else time.monotonic() + max_age
TypeError: unsupported operand type(s) for +: 'float' and 'str'
}}}"	Bug	closed	Documentation	3.0	Normal	fixed	CONN_MAX_AGE, base.py, Postgresql		Accepted	1	0	0	0	1	0
