-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pgBouncer to funnel connections #243
Conversation
Closing this effort. See #236 (comment) |
0dd0fb1
to
e4dab2b
Compare
Rebased |
Current version appears to be working when running manually. Fails # process DC file, pretending it's a region instead of subregion
docker exec -it \
-e POSTGRES_PASSWORD=mysecretpassword \
-e POSTGRES_USER=postgres \
-u 1000:1000 \
pgosm python3 docker/pgosm_flex.py \
--layerset=minimal \
--ram=2 \
--region=region-dc \
--skip-qgis-style --skip-nested # Make this test run faster
2023-10-18 20:57:05,951:INFO:pgosm-flex:pgosm_flex:PgOSM Flex starting...
Setting up pgBouncer configuration files
Running pgbouncer as postgres user
Traceback (most recent call last):
File "/app/docker/pgosm_flex.py", line 625, in <module>
run_pgosm_flex()
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/app/docker/pgosm_flex.py", line 103, in run_pgosm_flex
pgbouncer.run()
File "/app/docker/pgbouncer.py", line 58, in run
subprocess.run(
File "/usr/lib/python3.9/subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 1] Operation not permitted
make: *** [Makefile:174: docker-exec-region] Error 1 |
|
||
LOGGER.warning('Saving password in plain text within the container for pgBouncer.') | ||
with open(PGBOUNCER_USER_LIST_PATH, "w") as user_file: | ||
user_file.write(user_list) |
Check failure
Code scanning / CodeQL
Clear-text storage of sensitive information
) | ||
|
||
with open(PGBOUNCER_INI_PATH, "w") as ini_file: | ||
ini_file.write(pgbouncer_ini) |
Check failure
Code scanning / CodeQL
Clear-text storage of sensitive information
It appears to be working nicely. Haven't tested with external connections yet, or with append mode. It does appear to be working as expected on internal Postgres so hopefully it just works from here...
New output to logs at beginning. Running 2023-10-22 12:08:40,321:INFO:pgosm-flex:pgosm_flex:PgOSM Flex starting...
2023-10-22 12:08:40,322:WARNING:pgosm-flex:pgbouncer:Saving password in plain text within the container for pgBouncer.
2023-10-22 12:08:40,322:INFO:pgosm-flex:pgbouncer:Setting up pgBouncer configuration files with pool size 10
2023-10-22 12:08:40,325:INFO:pgosm-flex:pgbouncer:pgBouncer started
2023-10-22 12:08:40,325:INFO:pgosm-flex:db:Checking for Postgres service to be available |
Crud, this actually wasn't working as I had expected. After making the osm2pgsql connections go through pgBouncer I'm getting failures.
Looking deeper and reading closer I found on this page:
Searching in osm2pgsql I found this in properties.cpp db_connection.exec(
"PREPARE set_property(text, text) AS"
" INSERT INTO {} (property, value) VALUES ($1, $2)"
" ON CONFLICT (property) DO UPDATE SET value = EXCLUDED.value",
table_name());
db_connection.exec_prepared("set_property", inserted.first,
inserted.second); I'm unsure how to proceed on this ATM. I'm going to have to do some deeper digging and testing to figure out how this should/could work. |
Maybe refactoring prepared queries to use |
Started a discussion on osm2pgsql to see if the approach with |
Update osm2pgqsql-tuner
…ndling, ability to restart pgBouncer and shell of documentation
49b365e
to
c3b9c6d
Compare
Rebased, setup osm2pgsql repo URL to be dynamic for planned testing. |
Recent work in osm2pgsql to reduce idle connections has removed my reasoning to work further on this. See #376 for details. The initial import w/ default layerset dropped from 43 connections down to 10. Replication updates dropped from 207 connections down to 17. |
Addresses #236.