Change behavior of ComputeControlPlane::new_node() (#235)

Previously, transaction commit could happen regardless of whether
pageserver has caught up or not. This patch aims to fix that.

There are two notable changes:

1. ComputeControlPlane::new_node() now sets the
`synchronous_standby_names = 'pageserver'` parameter to delay
transaction commit until pageserver acting as a standby has
fetched and ack'd a relevant portion of WAL.

2. pageserver now has to:
    - Specify the `application_name = pageserver` which matches the
    one in `synchronous_standby_names`.
    - Properly reply with the ack'd LSNs.

This means that some tests don't need sleeps anymore.

TODO: We should probably make this behavior configurable.

Fixes #187.
This commit is contained in:
Dmitry Ivanov
2021-06-09 11:24:55 +03:00
committed by GitHub
parent 0969574d48
commit bb1446e33a
3 changed files with 28 additions and 25 deletions

View File

@@ -1,5 +1,4 @@
import psycopg2
import time
pytest_plugins = ("fixtures.zenith_fixtures")
@@ -38,13 +37,6 @@ def test_restart_compute(zenith_cli, pageserver, postgres, pg_bin):
cur.execute('SELECT count(*) FROM foo')
assert cur.fetchone() == (2, )
# FIXME: Currently, there is no guarantee that by the time the INSERT commits, the WAL
# has been streamed safely to the WAL safekeeper or page server. It is merely stored
# on the Postgres instance's local disk. Sleep a little, to give it time to be
# streamed. This should be removed, when we have the ability to run the Postgres
# instance -> safekeeper streaming in synchronous mode.
time.sleep(5)
# Stop, and destroy the Postgres instance. Then recreate and restart it.
pg_conn.close()
pg.stop_and_destroy()