pyeventsourcing / eventsourcing

A library for event sourcing in Python.
https://eventsourcing.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.41k stars 129 forks source link

Postgres does not accept idle_in_transaction_session_timeout as float string #234

Closed bernardotorres closed 2 years ago

bernardotorres commented 2 years ago

Even if the value itself is an integer.

https://www.postgresql.org/docs/9.6/runtime-config-client.html

postgres_1  | 2021-09-15 14:50:40.583 UTC [77] ERROR:  invalid value for parameter "idle_in_transaction_session_timeout": "0.0s"
postgres_1  | 2021-09-15 14:50:40.583 UTC [77] HINT:  Valid units for this parameter are "ms", "s", "min", "h", and "d".
postgres_1  | 2021-09-15 14:50:40.583 UTC [77] STATEMENT:  SET idle_in_transaction_session_timeout = '0.0s'
http_1      | Exception in thread Thread-2:
http_1      | Traceback (most recent call last):
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/postgres.py", line 159, in get_connection
http_1      |     conn = self._connections[thread_id]
http_1      | KeyError: 139650004793088
http_1      |
http_1      | During handling of the above exception, another exception occurred:
http_1      |
http_1      | Traceback (most recent call last):
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/postgres.py", line 184, in _create_connection
http_1      |     psycopg_c.cursor().execute(
http_1      | psycopg2.errors.InvalidParameterValue: invalid value for parameter "idle_in_transaction_session_timeout": "0.0s"
http_1      | HINT:  Valid units for this parameter are "ms", "s", "min", "h", and "d".
http_1      |
http_1      |
http_1      | During handling of the above exception, another exception occurred:
http_1      |
http_1      | Traceback (most recent call last):
http_1      |   File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner
http_1      |     self.run()
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/system.py", line 541, in run
http_1      |     self.app: Follower = self.app_class()
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/system.py", line 173, in __init__
http_1      |     super().__init__()
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/system.py", line 59, in __init__
http_1      |     super().__init__()
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/application.py", line 245, in __init__
http_1      |     self.recorder = self.construct_recorder()
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/system.py", line 74, in construct_recorder
http_1      |     return self.factory.process_recorder()
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/postgres.py", line 698, in process_recorder
http_1      |     recorder.create_table()
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/postgres.py", line 250, in create_table
http_1      |     with self.datastore.transaction(commit=True) as conn:
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/postgres.py", line 154, in transaction
http_1      |     return Transaction(self.get_connection(), commit=commit)
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/postgres.py", line 161, in get_connection
http_1      |     conn = self._create_connection(thread_id)
http_1      |   File "/usr/local/lib/python3.9/site-packages/eventsourcing/postgres.py", line 189, in _create_connection
http_1      |     raise InterfaceError(e)
http_1      | eventsourcing.persistence.InterfaceError: invalid value for parameter "idle_in_transaction_session_timeout": "0.0s"
http_1      | HINT:  Valid units for this parameter are "ms", "s", "min", "h", and "d".
johnbywater commented 2 years ago

How would you like this to be resolved?

bernardotorres commented 2 years ago

I've opened the Pull Request. I couldn't run the tests locally, so I'll use the CI to check that https://github.com/johnbywater/eventsourcing/pull/235