Skip to content

Conversation

marceloneppel
Copy link
Member

@marceloneppel marceloneppel commented Mar 23, 2024

Issue

The PostgreSQL charm takes 9-10 minutes to start (be in an Active state).

Solution

  • Avoid the legacy upgrade code execution during the start process (because it's not needed while Patroni is still offline).
  • Tweak timeouts to avoid differing the events too early (if Patroni is still offline).
  • Set the primary status message earlier.
  • Add some debug logs of the time spent since the charm started until it reaches the Active state.
  • Enabled and fixed a hidden unit test (test_set_primary_status_message). It was not being executed because of indentation in the test function.

Debug logs when using this PR charm (58 seconds from the beginning of the install hook until the workload is ready):

unit-postgresql-0: 19:27:23 DEBUG unit.postgresql/0.juju-log Install start time: 2024-06-24 19:27:23.462350
...
unit-postgresql-0: 19:28:21 DEBUG unit.postgresql/0.juju-log database-peers:1: Active workload time: 2024-06-24 19:28:21.274504

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Copy link

codecov bot commented Mar 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.78%. Comparing base (dbd46b5) to head (0148f1e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #413      +/-   ##
==========================================
+ Coverage   69.21%   69.78%   +0.56%     
==========================================
  Files          11       11              
  Lines        2865     2866       +1     
  Branches      507      507              
==========================================
+ Hits         1983     2000      +17     
+ Misses        781      761      -20     
- Partials      101      105       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…strap

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
…strap

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
…strap

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
…strap

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
…strap

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
…rlier

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
@marceloneppel marceloneppel marked this pull request as ready for review June 24, 2024 20:42
Copy link

@lucasgameiroborges lucasgameiroborges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! BTW sorry about the hidden unit test, that was probably me during the migration to pytest.

Copy link
Contributor

@taurus-forever taurus-forever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here really have positive effect on the start time.
Minimal changes which are promising! Thank you!

1 unit deployment:
23:48:28 - juju deploy
23:50:36 - the first event (lxc ready)
23:50:37 - Installing snap charmed-postgresql, revision 115, tracking 14/stable
23:51:08 - The snap installation completed successfully
23:51:58 - Completed.

3 units is a bit longer... but still good enough.

Let's move forward from here.

P.S. I am surprised to see no 503 Patroni API responces.

P.P.S. the datetime.now() is only necessary on CI/CD, as it duplicated juju debug-log timing:

unit-postgresql-4: 00:20:07 DEBUG unit.postgresql/4.juju-log Install start time: 2024-06-24 22:20:07.010192
unit-postgresql-4: 00:20:59 DEBUG unit.postgresql/4.juju-log Active workload time: 2024-06-24 22:20:59.474757

Anyway LGTM as it is WAY better the the current edge. Thank you!

@taurus-forever
Copy link
Contributor

I am merging this to test beta and promote candidate for Mohamed.

@taurus-forever taurus-forever merged commit 165d04c into main Jun 25, 2024
@taurus-forever taurus-forever deleted the dpe-3882-speedup-bootstrap branch June 25, 2024 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants