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

Error on garbage after tar archive #2972

Closed
hlinnaka opened this issue Nov 30, 2022 · 2 comments
Closed

Error on garbage after tar archive #2972

hlinnaka opened this issue Nov 30, 2022 · 2 comments
Labels
c/storage/pageserver Component: storage: pageserver t/bug Issue Type: Bug

Comments

@hlinnaka
Copy link
Contributor

hlinnaka commented Nov 30, 2022

When importing a basebackup tar archive, bail if there is garbage after the valid tar file.

Discussed at #1978 (comment)

@hlinnaka hlinnaka added the c/storage/pageserver Component: storage: pageserver label Nov 30, 2022
@hlinnaka
Copy link
Contributor Author

I wrote a test case for this, to see if this is still an issue. It is. Here's the test case:

diff --git a/test_runner/regress/test_import.py b/test_runner/regress/test_import.py
index 91cca557..77ba6c7f 100644
--- a/test_runner/regress/test_import.py
+++ b/test_runner/regress/test_import.py
@@ -61,6 +61,12 @@ def test_import_from_vanilla(test_output_dir, pg_bin, vanilla_pg, neon_env_build
         cwd=unpacked_base,
     )
 
+    # Make copy of base.tar and append some garbage to it.
+    base_plus_garbage_tar = os.path.join(basebackup_dir, "base-plus-garbage.tar")
+    shutil.copyfile(base_tar, base_plus_garbage_tar)
+    with open(base_plus_garbage_tar, "a") as f:
+        f.write("trailing garbage")
+
     # Get start_lsn and end_lsn
     with open(os.path.join(basebackup_dir, "backup_manifest")) as f:
         manifest = json.load(f)
@@ -130,6 +136,10 @@ def test_import_from_vanilla(test_output_dir, pg_bin, vanilla_pg, neon_env_build
     with pytest.raises(Exception):
         import_tar(corrupt_base_tar, wal_tar)
 
+    # Importing tar with trailing garbage fails
+    with pytest.raises(Exception):
+        import_tar(base_plus_garbage_tar, wal_tar)
+
     # Importing correct backup works
     import_tar(base_tar, wal_tar)
 

@shanyp shanyp added the t/bug Issue Type: Bug label Aug 21, 2023
@problame
Copy link
Contributor

problame commented Jul 9, 2024

The test code above was committed, mostly in 0fd3cd2

I think we can close this.

Came to this because I'm moving the import functionality into mgmt HTTP API in

@hlinnaka please reopen if I'm wrong.

@problame problame closed this as completed Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/storage/pageserver Component: storage: pageserver t/bug Issue Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants