importinto: ensure engine cleanup on import error#65663
importinto: ensure engine cleanup on import error#65663ti-chi-bot[bot] merged 3 commits intopingcap:masterfrom
Conversation
|
Hi @D3Hunter. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
| // finishWrite flushes all data and waits for the background routine to finish. | ||
| // after calling this method, the engine cannot be written anymore. the underlying | ||
| // pebble DB is still kept open for reading. | ||
| func (e *Engine) finishWrite(ctx context.Context) error { |
There was a problem hiding this comment.
split from closeEngine
There was a problem hiding this comment.
Pull request overview
This PR fixes a resource leak where local engines (data and index engines) were not being properly cleaned up when import operations failed. The fix ensures that both engines are cleaned up even if the data engine import fails.
Changes:
- Added error-path cleanup in
RunSubtaskvia a defer to close all local engines when local sort fails - Refactored engine closing logic by extracting
finishWritemethod for reuse - Added
CleanupAllLocalEnginesmethods to close all engines during error recovery - Added integration test to verify engines are properly cleaned up and can be reopened on retry
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/realtikvtest/importintotest3/cleanup_on_error_test.go | New integration test that verifies engine cleanup on data engine import error with retry |
| tests/realtikvtest/importintotest3/BUILD.bazel | Added test file and driver error dependency to build configuration |
| pkg/dxf/importinto/task_executor.go | Added defer cleanup logic to handle engine cleanup on error path |
| pkg/executor/importer/table_import.go | Added failpoint for simulating data engine import errors in tests |
| pkg/lightning/backend/local/local.go | Added public CleanupAllLocalEngines method to backend interface |
| pkg/lightning/backend/local/engine_mgr.go | Refactored closeEngine to use new finishWrite method and added cleanupAllLocalEngines implementation |
| pkg/lightning/backend/local/engine.go | Extracted finishWrite method for reusable engine write finalization logic |
|
/retest |
|
@D3Hunter: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: GMHDBJD, joechenrh The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #65663 +/- ##
================================================
+ Coverage 77.8491% 78.3242% +0.4750%
================================================
Files 1983 1913 -70
Lines 542774 531252 -11522
================================================
- Hits 422545 416099 -6446
+ Misses 118569 114709 -3860
+ Partials 1660 444 -1216
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
/retest |
1 similar comment
|
/retest |
What problem does this PR solve?
Issue Number: close #65645
Problem Summary:
What changed and how does it work?
as title
Why it happens:
onFinished, both engines can stay open. See pkg/dxf/importinto/task_executor.go.
timeouts), the function returns immediately and skips closing/cleaning the index engine. See pkg/dxf/
importinto/task_executor.go.
index engine reopening and hitting a lock that’s still held.
Check List
Tests
without this pr, the case failes, after, it success
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.