Skip to content
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

refactor: attach: use create_tenant_files + schedule_local_tenant_processing #4235

Merged
merged 3 commits into from
May 16, 2023

Conversation

problame
Copy link
Contributor

@problame problame commented May 15, 2023

With this patch, the attach handler now follows the same pattern as tenant create with regards to instantiation of the new tenant:

  1. Prepare on-disk state using create_tenant_files.
  2. Use the same code path as pageserver startup to load it into memory and start background loops (schedule_local_tenant_processing).

It's a bit sad we can't use the
PageServerConfig::tenant_attaching_mark_file_path method inside create_tenant_files because it operates in a temporary directory. However, it's a small price to pay for the gained simplicity.

During implementation, I noticed that we don't handle failures post create_tenant_files well. I left TODO comments in the code linking to the issue that I created for this 1.

Also, I'll dedupe the spawn_load and spawn_attach code in a future commit.

refs #1555
part of #886 (Tenant Relocation)

Footnotes

  1. https://github.com/neondatabase/neon/issues/4233

…cessing

With this patch, the attach handler now follows the same pattern as
tenant create with regards to instantiation of the new tenant:

1. Prepare on-disk state using `create_tenant_files`.
2. Use the same code path as pageserver startup to load it
   into memory and start background loops
   (`schedule_local_tenant_processing`).

It's a bit sad we can't use the
`PageServerConfig::tenant_attaching_mark_file_path`
method inside `create_tenant_files` because it operates
in a temporary directory. However, it's a small price to pay for the
gained simplicity.

During implementation, I noticed that we don't handle
failures post `create_tenant_files` well. I left TODO
comments in the code linking to the issue that I created
for this [^1].

Also, I'll dedupe the spawn_load and spawn_attach code
in a future commit.

[^1]: #4233
@github-actions
Copy link

github-actions bot commented May 15, 2023

And make error message wording fit both create & attach use case.
@problame problame marked this pull request as ready for review May 16, 2023 12:53
@problame problame requested review from a team as code owners May 16, 2023 12:53
@problame problame requested review from save-buffer and skyzh and removed request for a team and save-buffer May 16, 2023 12:53
@problame problame changed the title refactor: attach: use create_tenant_files + schedule_local_tenant_pro… refactor: attach: use create_tenant_files + schedule_local_tenant_processing May 16, 2023
Copy link
Member

@skyzh skyzh left a comment

Choose a reason for hiding this comment

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

Rest LGTM

pageserver/src/tenant/mgr.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/mgr.rs Outdated Show resolved Hide resolved
pageserver/src/tenant.rs Show resolved Hide resolved
pageserver/src/tenant/mgr.rs Show resolved Hide resolved
@problame problame merged commit 4431779 into main May 16, 2023
27 checks passed
@problame problame deleted the problame/attach-time-tenant-config branch May 16, 2023 16:53
problame added a commit that referenced this pull request May 24, 2023
This PR adds support for supplying the tenant config upon /attach.

Before this change, when relocating a tenant using `/detach` and
`/attach`, the tenant config after `/attach` would be the default config
from `pageserver.toml`.
That is undesirable for settings such as the PITR-interval: if the
tenant's config on the source was `30 days` and the default config on
the attach-side is `7 days`, then the first GC run would eradicate 23
days worth of PITR capability.

The API change is backwards-compatible: if the body is empty, we
continue to use the default config.
We'll remove that capability as soon as the cloud.git code is updated to
use attach-time tenant config
(#4282 keeps track of this).

unblocks neondatabase/cloud#5092 
fixes #1555
part of #886 (Tenant
Relocation)

Implementation
==============

The preliminary PRs for this work were (most-recent to least-recent)

* #4279
* #4267
* #4252
* #4235
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants