Skip to content

Commit

Permalink
Fix frontend proxy worker binding to wrong port. (#823)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
  • Loading branch information
erikjohnston and clokep authored Mar 3, 2020
1 parent 128d7d3 commit f6db39c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
3 changes: 0 additions & 3 deletions docker/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,3 @@ ENV PGHOST=/var/run/postgresql
ENV PGDATA=$PGHOST/data
ENV PGUSER=postgres
RUN for ver in `ls /usr/lib/postgresql | head -n 1`; do su -c '/usr/lib/postgresql/'$ver'/bin/initdb -E "UTF-8" --lc-collate="C" --lc-ctype="C" --username=postgres' postgres; done

# Turn off all the fsync stuff for postgres
RUN for ver in /etc/postgresql/*/main; do mkdir -p $ver/conf.d/; echo -e "fsync=off\nfull_page_writes=off" >> $ver/conf.d/fsync.conf; done
8 changes: 7 additions & 1 deletion lib/SyTest/Homeserver/Synapse.pm
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ sub wrap_synapse_command
"worker_log_config" => $self->configure_logger("pusher"),
"worker_replication_host" => "$bind_host",
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
"worker_listeners" => [
{
type => "http",
Expand All @@ -728,6 +729,7 @@ sub wrap_synapse_command
"worker_log_config" => $self->configure_logger("appservice"),
"worker_replication_host" => "$bind_host",
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
"worker_listeners" => [
{
type => "manhole",
Expand All @@ -753,6 +755,7 @@ sub wrap_synapse_command
"worker_log_config" => $self->configure_logger("federation_sender"),
"worker_replication_host" => "$bind_host",
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
"worker_listeners" => [
{
type => "manhole",
Expand All @@ -778,6 +781,7 @@ sub wrap_synapse_command
"worker_log_config" => $self->configure_logger("synchrotron"),
"worker_replication_host" => "$bind_host",
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
"worker_listeners" => [
{
type => "http",
Expand Down Expand Up @@ -845,6 +849,7 @@ sub wrap_synapse_command
"worker_log_config" => $self->configure_logger("media_repository"),
"worker_replication_host" => "$bind_host",
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
"worker_listeners" => [
{
type => "http",
Expand Down Expand Up @@ -912,6 +917,7 @@ sub wrap_synapse_command
"worker_log_config" => $self->configure_logger("user_dir"),
"worker_replication_host" => "$bind_host",
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
"worker_listeners" => [
{
type => "http",
Expand Down Expand Up @@ -990,7 +996,7 @@ sub wrap_synapse_command
},
{
type => "manhole",
port => $self->{ports}{frontend_proxy},
port => $self->{ports}{frontend_proxy_manhole},
bind_address => $bind_host,
},
{
Expand Down
23 changes: 16 additions & 7 deletions scripts/synapse_sytest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,26 @@ cd "$(dirname $0)/.."
mkdir /work

# PostgreSQL setup
if [ -n "$MULTI_POSTGRES" ]; then
# In this mode we want to run synapse against multiple split out databases.

if [ -n "$MULTI_POSTGRES" ] || [ -n "$POSTGRES" ]; then
# We increase the max connections as we have more databases.
echo -e "max_connections=1000" >> /var/run/postgresql/data/postgresql.conf
sed -i -r "s/^max_connections.*$/max_connections = 500/" /var/run/postgresql/data/postgresql.conf

echo -e "fsync = off" >> /var/run/postgresql/data/postgresql.conf
echo -e "full_page_writes = off" >> /var/run/postgresql/data/postgresql.conf

# Start the database
su -c 'eatmydata /usr/lib/postgresql/*/bin/pg_ctl -w -D $PGDATA start' postgres

su -c psql postgres <<< "show config_file"
su -c psql postgres <<< "show max_connections"
su -c psql postgres <<< "show full_page_writes"
su -c psql postgres <<< "show fsync"
fi

# Now create the databases
if [ -n "$MULTI_POSTGRES" ]; then
# In this mode we want to run synapse against multiple split out databases.

# Make the test databases for the two Synapse servers that will be spun up
su -c psql postgres <<EOF
CREATE DATABASE pg1_main;
Expand Down Expand Up @@ -85,13 +96,11 @@ state_db:
EOF

elif [ -n "$POSTGRES" ]; then
# Env vars used by prep_sytest_for_postgres script.
export PGUSER=postgres
export POSTGRES_DB_1=pg1
export POSTGRES_DB_2=pg2

# Start the database
su -c 'eatmydata /usr/lib/postgresql/*/bin/pg_ctl -w -D $PGDATA start' postgres

# Write out the configuration for a PostgreSQL using Synapse
./scripts/prep_sytest_for_postgres.sh

Expand Down

0 comments on commit f6db39c

Please sign in to comment.