Repository navigation
fix(read): release exported Arrow roots when batch publication fails #586
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
Merged
lxy-9602
merged 5 commits into
apache:main
from
realAaronWu:codex/paimon-release-exported-parquet-roots
Nov 22, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f6c1df8
Release exported Arrow roots when Parquet read publication fails
26f415e
Check Parquet root cleanup after an export-time metrics failure
6c6265a
Exercise SDK lifetime allocation failure through the Arrow C roots
ab51447
Check the Arrow schema allocation pool on Parquet unwind
4d50bc4
test: use fixed-width release counters and assert the injected read f…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/paimon/common/utils/arrow/arrow_lifetime_failure_test.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| #include <cstddef> | ||
| #include <cstdint> | ||
| #include <memory> | ||
| #include <new> | ||
| #include <utility> | ||
|
|
||
| #include "gtest/gtest.h" | ||
| #include "paimon/arrow/abi.h" | ||
| #include "paimon/common/utils/arrow/mem_utils.h" | ||
|
|
||
| namespace { | ||
| thread_local bool fail_next_allocation = false; | ||
| } // namespace | ||
|
|
||
| extern "C" void* __real__Znwm(std::size_t size); | ||
| extern "C" void* __wrap__Znwm(std::size_t size) { | ||
| if (std::exchange(fail_next_allocation, false)) { | ||
| throw std::bad_alloc(); | ||
| } | ||
| return __real__Znwm(size); | ||
| } | ||
|
|
||
| namespace paimon::test { | ||
|
|
||
| TEST(ArrowLifetimeFailureTest, ReleasesBothRootsWhenHoldingLifetimeRunsOutOfMemory) { | ||
| ArrowArray array{}; | ||
| ArrowSchema schema{}; | ||
| int32_t array_releases = 0; | ||
| int32_t schema_releases = 0; | ||
| array.private_data = &array_releases; | ||
| array.release = [](ArrowArray* root) { | ||
| ++*static_cast<int32_t*>(root->private_data); | ||
| root->release = nullptr; | ||
| }; | ||
| schema.private_data = &schema_releases; | ||
| schema.release = [](ArrowSchema* root) { | ||
| ++*static_cast<int32_t*>(root->private_data); | ||
| root->release = nullptr; | ||
| }; | ||
| std::shared_ptr<void> owner = std::make_shared<int32_t>(1); | ||
|
|
||
| Status status; | ||
| bool threw = false; | ||
| fail_next_allocation = true; | ||
| try { | ||
| status = AddArrowArrayLifetime(&array, &schema, owner); | ||
| } catch (const std::bad_alloc&) { | ||
| threw = true; | ||
| } | ||
| const bool fired = !std::exchange(fail_next_allocation, false); | ||
|
|
||
| EXPECT_TRUE(fired); | ||
| EXPECT_FALSE(threw); | ||
| EXPECT_TRUE(status.IsOutOfMemory()); | ||
| EXPECT_EQ(array_releases, 1); | ||
| EXPECT_EQ(schema_releases, 1); | ||
| EXPECT_EQ(array.release, nullptr); | ||
| EXPECT_EQ(schema.release, nullptr); | ||
| } | ||
|
|
||
| } // namespace paimon::test | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.