@@ -287,6 +287,11 @@ Status OlapScanner::get_batch(RuntimeState* state, RowBatch* batch, bool* eof) {
287287 int64_t raw_bytes_threshold = config::doris_scanner_row_bytes;
288288 {
289289 SCOPED_TIMER (_parent->_scan_timer );
290+ // store the object which may can't pass the conjuncts temporarily.
291+ // otherwise, pushed all objects into agg_object_pool directly may lead to OOM.
292+ ObjectPool tmp_object_pool;
293+ // release the memory of the object which can't pass the conjuncts.
294+ ObjectPool unused_object_pool;
290295 while (true ) {
291296 // Batch is full or reach raw_rows_threshold or raw_bytes_threshold, break
292297 if (batch->is_full () ||
@@ -295,9 +300,18 @@ Status OlapScanner::get_batch(RuntimeState* state, RowBatch* batch, bool* eof) {
295300 _update_realtime_counter ();
296301 break ;
297302 }
303+
304+ if (tmp_object_pool.size () > 0 ) {
305+ unused_object_pool.acquire_data (&tmp_object_pool);
306+ }
307+
308+ if (unused_object_pool.size () >= config::object_pool_buffer_size) {
309+ unused_object_pool.clear ();
310+ }
311+
298312 // Read one row from reader
299313 auto res = _tablet_reader->next_row_with_aggregation (&_read_row_cursor, mem_pool.get (),
300- batch-> agg_object_pool () , eof);
314+ &tmp_object_pool , eof);
301315 if (!res.ok ()) {
302316 std::stringstream ss;
303317 ss << " Internal Error: read storage fail. res=" << res
@@ -396,6 +410,7 @@ Status OlapScanner::get_batch(RuntimeState* state, RowBatch* batch, bool* eof) {
396410
397411 // check direct && pushdown conjuncts success then commit tuple
398412 batch->commit_last_row ();
413+ batch->agg_object_pool ()->acquire_data (&tmp_object_pool);
399414 char * new_tuple = reinterpret_cast <char *>(tuple);
400415 new_tuple += _tuple_desc->byte_size ();
401416 tuple = reinterpret_cast <Tuple*>(new_tuple);
0 commit comments