realAaronWu opened a new issue, #587:
URL: https://github.com/apache/paimon-cpp/issues/587

   ### Search before asking
   
   - [x] I searched the existing issues. #435 tracks broader planning limits 
and cancellation. This report isolates a snapshot-buffer allocation and 
includes a measured reproduction.
   
   ### Paimon-cpp version
   
   Apache Paimon C++ `main` at `2826c2651d6384e3c767720307df552fd6f6a522`, on 
Linux ARM64 with libstdc++.
   
   ### Minimal reproduce step
   
   1. Use a copy of a local append-only table with a valid snapshot 1. Append 
trailing JSON whitespace to the snapshot file until it is 270,337 bytes. The 
parsed snapshot metadata stays the same.
   2. Configure `ScanContextBuilder` with `scan.mode=from-snapshot-full`, 
`scan.snapshot-id=1`, and `WithMemoryPool` using a pool capped at 262,144 
bytes. Create a table scan and call `CreatePlan()`.
   3. Record allocations through the supplied pool and trace the ordinary 
allocation in `FileSystem::ReadFile`. In our downstream test, a local 
allocation tracer recorded the successful allocation without changing Paimon 
C++ production code.
   
   ### What doesn't meet your expectations?
   
   The snapshot read made a **270,338-byte allocation** outside the supplied 
pool. The pool recorded **zero peak bytes** in this run. Planning failed later 
during Avro reader construction, after the snapshot buffer had already been 
allocated.
   
   The stack was `CreatePlan → StaticFromSnapshotStartingScanner::Scan → 
SnapshotManager::LoadSnapshot → Snapshot::FromPath → FileSystem::ReadFile`. The 
default implementation calls `std::string::resize` using the file length before 
reading the content. [Snapshot 
load](https://github.com/apache/paimon-cpp/blob/2826c2651d6384e3c767720307df552fd6f6a522/src/paimon/core/snapshot.cpp#L326-L331)
 · [Buffer 
allocation](https://github.com/apache/paimon-cpp/blob/2826c2651d6384e3c767720307df552fd6f6a522/src/paimon/common/fs/file_system.cpp#L44-L57)
   
   For a caller using bounded planning, the snapshot buffer should be checked 
against the query budget before allocation, with an over-budget snapshot 
returning a failure before a plan is produced. Can this allocation be covered 
by the bounded-planning contract in #435?
   
   ### Anything else?
   
   This report is limited to the snapshot input buffer. It does not measure 
parser memory, later planning allocations, or process RSS. Downstream context 
is [Sirius #2211](https://github.com/sirius-db/sirius/issues/2211).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to