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

Clear topics orphan files with fix #8960

Merged
merged 4 commits into from
Mar 28, 2023

Conversation

ZeDRoman
Copy link
Contributor

@ZeDRoman ZeDRoman commented Feb 17, 2023

When node is restarted while it was executing partition delete operation, this operation may be not finished and we will have orphan files for that partition left on device.
On node restart we don't have that partition data in memory so we couldn't retry partition delete operation and won't clean up partition files on reconciliation.
This pr bring garbage collector mechanism that will force delete partition files after node bootstrap.
We gather all existing ntps and then go through all data directories and check if topic directory responsible for any exisitng ntp if it don't we delete it.

#8396 pr with fix

Fixes #8919

Backports Required

  • none - not a bug fix
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v22.3.x
  • v22.2.x
  • v22.1.x

UX Changes

  • Mechanism for cleaning partition orphan files

Release Notes

  • Mechanism for cleaning partition orphan files

@ZeDRoman
Copy link
Contributor Author

/ci-repeat 10
skip-units
dt-repeat=15
tests/rptest/tests/random_node_operations_test.py::RandomNodeOperationsTest.test_node_operations@{"enable_failures":1}

@ZeDRoman
Copy link
Contributor Author

/ci-repeat 10
skip-units
dt-repeat=15
tests/rptest/tests/random_node_operations_test.py::RandomNodeOperationsTest.test_node_operations

@ZeDRoman
Copy link
Contributor Author

/ci-repeat 10
skip-units
dt-repeat=30
tests/rptest/tests/random_node_operations_test.py::RandomNodeOperationsTest.test_node_operations

@ZeDRoman
Copy link
Contributor Author

@ZeDRoman
Copy link
Contributor Author

/ci-repeat 10
skip-units
dt-repeat=30
tests/rptest/tests/random_node_operations_test.py::RandomNodeOperationsTest.test_node_operations

@ZeDRoman
Copy link
Contributor Author

/ci-repeat 10
skip-units
dt-repeat=15
tests/rptest/tests/random_node_operations_test.py::RandomNodeOperationsTest.test_node_operations

@ZeDRoman
Copy link
Contributor Author

/ci-repeat 10

@ZeDRoman ZeDRoman force-pushed the delete-orphan-topic-files-fix branch from 0ecefac to a1a595a Compare March 1, 2023 17:32
@ZeDRoman
Copy link
Contributor Author

ZeDRoman commented Mar 1, 2023

/ci-repeat 10

@ZeDRoman ZeDRoman force-pushed the delete-orphan-topic-files-fix branch from a1a595a to 9e222a1 Compare March 3, 2023 08:39
@ZeDRoman
Copy link
Contributor Author

ZeDRoman commented Mar 3, 2023

/ci-repeat 20

@ZeDRoman ZeDRoman changed the title Test Clear topics orphan files with fix Mar 3, 2023
@ZeDRoman
Copy link
Contributor Author

ZeDRoman commented Mar 3, 2023

Ci failures:
#8388
#7397

unknown:
RedpandaInstallerTest.test_install_by_line
http.client.RemoteDisconnected: Remote end closed connection without response
https://ci-artifacts.dev.vectorized.cloud/redpanda/0186a73c-ca33-4596-a9eb-eb1c99f09f19/vbuild/ducktape/results/2023-03-03--001/report.html

FeaturesMultiNodeTest.test_license_upload_and_query
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
https://ci-artifacts.dev.vectorized.cloud/redpanda/0186a73c-ca39-43a2-8a3f-610559eeaa25/vbuild/ducktape/results/2023-03-03--001/report.html

PartitionMovementTest.test_static
http.client.RemoteDisconnected: Remote end closed connection without response
https://ci-artifacts.dev.vectorized.cloud/redpanda/0186a73c-ca3f-422e-bc93-dd7881554b06/vbuild/ducktape/results/2023-03-03--001/report.html

PartitionMovementTest.test_deletion_stops_move
ConnectionResetError: [Errno 104] Connection reset by peer
https://ci-artifacts.dev.vectorized.cloud/redpanda/0186a73c-ca41-467d-9f89-ab2f87ac1b92/vbuild/ducktape/results/2023-03-03--001/report.html

@ZeDRoman ZeDRoman marked this pull request as ready for review March 3, 2023 16:30
Copy link
Member

@dotnwat dotnwat left a comment

Choose a reason for hiding this comment

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

does it make sense to do this on controller bakcned start-up, or integrate it into the general GC and space reclaimation process that is driven by log manager?

@ZeDRoman
Copy link
Contributor Author

ZeDRoman commented Mar 6, 2023

does it make sense to do this on controller bakcned start-up, or integrate it into the general GC and space reclaimation process that is driven by log manager?

Now we assume that orphan files can appear only on redpanda restart.
In runtime we are retying deletion until we get success.
So there is no need in running this gc in runtime, only on startup

@dotnwat
Copy link
Member

dotnwat commented Mar 6, 2023

We gather all existing ntps and then go through all data directories and check if topic directory responsible for any exisitng ntp if it don't we delete it.

Can you please describe the decisions that are being made to determine what is and is not an orphaned file?

@ZeDRoman
Copy link
Contributor Author

ZeDRoman commented Mar 7, 2023

We gather all existing ntps and then go through all data directories and check if topic directory responsible for any exisitng ntp if it don't we delete it.

Can you please describe the decisions that are being made to determine what is and is not an orphaned file?

Orphaned files are those files that for some reason remained on the disk, although they should have been deleted.
e.x. files for already removed partition, or files for moved out partition

@ZeDRoman
Copy link
Contributor Author

https://buildkite.com/redpanda/redpanda/builds/24704#_ CI failures

#7397
#9287 multiple
#9284
#9052 multiple
#9243
#9315 multiple
#9340

@dotnwat dotnwat requested review from bharathv and jcsp March 13, 2023 18:38
Copy link
Contributor

@bharathv bharathv left a comment

Choose a reason for hiding this comment

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

code lgtm, would be great to document as it is not trivial for a future reader.

@@ -289,9 +290,69 @@ void controller_backend::setup_metrics() {
});
}

static absl::flat_hash_map<model::ntp, model::revision_id>
create_topic_table_snapshot(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it will be helpful to have a comment why we make a snpashot and what exactly is in the snapshot.

ssx::spawn_with_gate(
_gate,
[this, bootstrap_revision, snapshot = std::move(snapshot)] {
return clear_orphan_topic_files(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add some comments around what exactly orphan files and are why we do it at startup? (for readers who don't look at this as a commit).

}
if (
topic_table_snapshot.contains(ntp)
&& ntp_directory_data.revision_id
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: would be nice to document what qualifies as an orphan in the method doc.

});
}

ss::future<> log_manager::remove_orphan_files(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: would be nice to mention that this walks thru the entire directory structure in an async fiber to remove...

@ZeDRoman ZeDRoman requested a review from VladLazar March 14, 2023 11:28
Copy link
Contributor

@VladLazar VladLazar left a comment

Choose a reason for hiding this comment

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

Generally looks good. You might want to catch all exceptions/failed futures in one place though. At the moment only std::filesystem::filesystem_error is handled. If anything else bubbles up, I think the whole clean-up stops. It would make sense to attempt the clean-up for the rest of the ntps, even if one failed.

@@ -570,6 +631,65 @@ ss::future<> controller_backend::fetch_deltas() {
});
}

bool topic_files_are_orphan(
Copy link
Contributor

Choose a reason for hiding this comment

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

The logging in this function is a bit confusing to me. Cleaning up orphan topic files. ntp {} skip dir makes it sound like we'll clear up.

@@ -437,6 +441,85 @@ ss::future<> log_manager::remove(model::ntp ntp) {
co_await dispatch_topic_dir_deletion(topic_dir);
}

ss::future<> remove_orphan_partition_files(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd move this free function into the anon namespace (namespace {}) or mark it static.

@ZeDRoman ZeDRoman force-pushed the delete-orphan-topic-files-fix branch from 9e222a1 to e6facfa Compare March 22, 2023 15:10
@ZeDRoman ZeDRoman force-pushed the delete-orphan-topic-files-fix branch from e6facfa to 5aad020 Compare March 22, 2023 15:14
@ZeDRoman ZeDRoman requested review from bharathv and VladLazar March 22, 2023 15:14
When redpanda is restarted while delete operation is not finish
Partition files might be left on disk.
We need to cleanup orphan partition files after bootstrap.
@ZeDRoman ZeDRoman force-pushed the delete-orphan-topic-files-fix branch from 5aad020 to 2eb0976 Compare March 22, 2023 15:34
@ZeDRoman ZeDRoman merged commit 81610d8 into redpanda-data:dev Mar 28, 2023
@ZeDRoman
Copy link
Contributor Author

/backport v22.3.x

@vbotbuildovich
Copy link
Collaborator

Failed to run cherry-pick command. I executed the below command:

git cherry-pick -x cefbef2fc2c40142537332e8695ec7030acfd92a 2862c324ca2513040a138e846e40763a5fb43c28 ab214edadeffd650ff4bac34dc49fe179208b68d 2eb0976dc05864267756292b03503b5d2ed65fd6

Workflow run logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants