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

[BugFix] Fix the has_output check bug of scan operator #42994

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

trueeyu
Copy link
Contributor

@trueeyu trueeyu commented Mar 22, 2024

Why I'm doing:

What we expect is that ScanOperator::pull_chunk can be executed only after ScanPrepareOperator::pull_chunk is executed finished and return success.

If ScanPrepareOperator::pull_chunk returns EOF, ScanOperator::pull_chunk should not be executed.

But when in function OlapScanPrepareOperator::pull_chunk, if _ctx->set_prepare_finished is executed finished and before _ctx->set_finished() is executed,

bool OlapScanOperator::has_output() const {
    if (!_ctx->is_prepare_finished() || _ctx->is_finished()) {
        return false;
    }

    return ScanOperator::has_output();
} 

will return true, causing OlapScanOperator::pull_chunk will be executed, causing some unexpected crashes.

There are dependencies between operators. The current scheduling does not consider this dependency, which is not a good design.

But the current fix does not change the implementation of this pipeline engine.

#7  0x0000000004712288 in starrocks::BinaryDictPageDecoder<(starrocks::FieldType)17>::next_batch (this=this@entry=0x7f97c0803f60, range=..., dst=dst@entry=0x7f97c08ed610) at /build/starrocks/be/src/storage/rowset/binary_dict_page.cpp:257
#8  0x00000000047125c8 in starrocks::BinaryDictPageDecoder<(starrocks::FieldType)17>::next_batch (this=0x7f97c0803f60, n=0x7f943db22210, dst=0x7f97c08ed610) at /build/starrocks/be/src/storage/rowset/binary_dict_page.cpp:219
#9  0x000000000472fd2b in starrocks::ParsedPageV2::read (this=0x7f97b22954c0, column=0x7f97c08ed610, count=0x7f943db22210) at /build/starrocks/be/src/storage/rowset/parsed_page.cpp:217
#10 0x0000000004702862 in operator() (count=0x7f943db22210, column=0x7f97c08ed610, __closure=<synthetic pointer>) at /build/starrocks/be/src/storage/rowset/scalar_column_iterator.cpp:495
#11 starrocks::ScalarColumnIterator::_fetch_by_rowid<starrocks::ScalarColumnIterator::fetch_values_by_rowid(const rowid_t*, size_t, starrocks::vectorized::Column*)::<lambda(starrocks::vectorized::Column*, size_t*)>&> (page_parse=<synthetic pointer>..., 
    values=0x7f97c08ed610, size=<optimized out>, rowids=<optimized out>, this=0x7f923b4ba300) at /build/starrocks/be/src/storage/rowset/scalar_column_iterator.cpp:482
#12 starrocks::ScalarColumnIterator::fetch_values_by_rowid (this=0x7f923b4ba300, rowids=<optimized out>, size=<optimized out>, values=0x7f97c08ed610) at /build/starrocks/be/src/storage/rowset/scalar_column_iterator.cpp:496
#13 0x00000000046b4492 in starrocks::ColumnIterator::fetch_values_by_rowid (this=0x7f923b4ba300, rowids=..., values=0x7f97c08ed610) at /build/starrocks/be/src/storage/rowset/column_iterator.cpp:45
#14 0x00000000042d5eff in starrocks::ColumnDecoder::decode_values_by_rowid (values=<optimized out>, rowids=..., this=<optimized out>) at /build/starrocks/be/src/storage/rowset/column_decoder.h:28
#15 starrocks::vectorized::SegmentIterator::_finish_late_materialization (this=0x7f92cfdfac10, ctx=0x7f92cfdfb060) at /build/starrocks/be/src/storage/rowset/segment_iterator.cpp:1435
#16 0x00000000042dedd0 in starrocks::vectorized::SegmentIterator::_do_get_next (this=0x7f92cfdfac10, result=0x7f8b213c8ef0, rowid=0x0) at /build/starrocks/be/src/storage/rowset/segment_iterator.cpp:932
#17 0x00000000042e18b0 in starrocks::vectorized::SegmentIterator::do_get_next (this=0x7f92cfdfac10, chunk=0x7f8b213c8ef0) at /build/starrocks/be/src/storage/rowset/segment_iterator.cpp:811
#18 0x00000000043661f2 in starrocks::vectorized::ChunkIterator::get_next (chunk=<optimized out>, this=<optimized out>) at /build/starrocks/be/src/storage/chunk_iterator.h:40
#19 starrocks::vectorized::ProjectionIterator::do_get_next (this=0x7f9354333810, chunk=0x7f8b213c9960) at /build/starrocks/be/src/storage/projection_iterator.cpp:69
#20 0x0000000004916db5 in starrocks::vectorized::ChunkIterator::get_next (chunk=<optimized out>, this=<optimized out>) at /build/starrocks/be/src/storage/chunk_iterator.h:40
#21 starrocks::SegmentIteratorWrapper::do_get_next (this=<optimized out>, chunk=<optimized out>) at /build/starrocks/be/src/storage/rowset/rowset.cpp:337
#22 0x00000000047461a3 in starrocks::vectorized::ChunkIterator::get_next (chunk=0x7f8b213c9960, this=0x7f9354333990) at /build/starrocks/be/src/storage/chunk_iterator.h:40
#23 starrocks::vectorized::TimedChunkIterator::do_get_next (this=0x7f9354345390, chunk=0x7f8b213c9960) at /build/starrocks/be/src/storage/chunk_iterator.cpp:37
#24 0x0000000004397656 in starrocks::vectorized::ChunkIterator::get_next (chunk=0x7f8b213c9960, this=<optimized out>) at /build/starrocks/be/src/storage/chunk_iterator.h:40
#25 starrocks::vectorized::TabletReader::do_get_next (this=0x7f7999190c10, chunk=0x7f8b213c9960) at /build/starrocks/be/src/storage/tablet_reader.cpp:219
#26 0x00000000030342fb in starrocks::vectorized::ChunkIterator::get_next (chunk=0x7f8b213c9960, this=<optimized out>) at /build/starrocks/be/src/storage/chunk_iterator.h:40
#27 starrocks::pipeline::OlapChunkSource::_read_chunk_from_storage (this=0x7f91121a3710, state=<optimized out>, chunk=0x7f8b213c9960) at /build/starrocks/be/src/exec/pipeline/scan/olap_chunk_source.cpp:332
#28 0x00000000030349db in starrocks::pipeline::OlapChunkSource::_read_chunk (this=0x7f91121a3710, state=<optimized out>, chunk=0x7f943db228c0) at /build/starrocks/be/src/exec/pipeline/scan/olap_chunk_source.cpp:293
#29 0x00000000030242af in starrocks::pipeline::ChunkSource::buffer_next_batch_chunks_blocking (this=0x7f91121a3710, state=0x7f91f81f0500, batch_size=batch_size@entry=64, running_wg=0x7f97df8b8d50) at /build/starrocks/be/src/exec/pipeline/scan/chunk_source.cpp:57
#30 0x0000000002d9e9a4 in operator() (__closure=0x7f92cfda96c0) at /build/starrocks/be/src/exec/pipeline/scan/scan_operator.cpp:374
#31 0x0000000002dafdce in std::function<void ()>::operator()() const (this=0x7f943db22cf0) at /opt/gcc/usr/include/c++/10.3.0/bits/std_function.h:622
#32 starrocks::workgroup::ScanExecutor::worker_thread (this=0x7f97df7c5220) at /build/starrocks/be/src/exec/workgroup/scan_executor.cpp:58
#33 0x0000000004b17352 in std::function<void ()>::operator()() const (this=0x7f94b2871e98) at /opt/gcc/usr/include/c++/10.3.0/bits/std_function.h:622
#34 starrocks::FunctionRunnable::run (this=0x7f94b2871e90) at /build/starrocks/be/src/util/threadpool.cpp:44
#35 starrocks::ThreadPool::dispatch_thread (this=0x7f97df8b90c0) at /build/starrocks/be/src/util/threadpool.cpp:539
#36 0x0000000004b11e4a in std::function<void ()>::operator()() const (this=0x7f94b287b418) at /opt/gcc/usr/include/c++/10.3.0/bits/std_function.h:622
#37 starrocks::Thread::supervise_thread (arg=0x7f94b287b400) at /build/starrocks/be/src/util/thread.cpp:351
#38 0x00007f97e346e17a in start_thread () from /home/disk6/lxh/core/lib64/[libpthread-2.28.so](http://libpthread-2.28.so/)
#39 0x00007f97e2a0fdf3 in clone () from /home/disk6/lxh/core/lib64/[libc-2.28.so](http://libc-2.28.so/)

What I'm doing:

If prepare return eof, we will first set_finished and then set_prepare_finished.

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@github-actions github-actions bot added the 2.5 label Mar 22, 2024
@trueeyu trueeyu marked this pull request as ready for review March 22, 2024 09:12
@trueeyu trueeyu requested review from a team as code owners March 22, 2024 09:12
Signed-off-by: trueeyu <lxhhust350@qq.com>
static_cast<void>(_ctx->set_finished());
TEST_SYNC_POINT("OlapScnPrepareOperator::pull_chunk::after_set_finished");
_ctx->set_prepare_finished();
Copy link
Contributor

Choose a reason for hiding this comment

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

defer set_prepare_finished will be OK

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

ZiheLiu
ZiheLiu previously approved these changes Mar 22, 2024
Signed-off-by: trueeyu <lxhhust350@qq.com>
@wyb wyb enabled auto-merge (squash) March 22, 2024 11:06
Copy link

[FE Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[BE Incremental Coverage Report]

pass : 9 / 10 (90.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/exec/pipeline/scan/olap_scan_prepare_operator.cpp 7 8 87.50% [90]
🔵 be/src/exec/pipeline/scan/olap_scan_context.cpp 1 1 100.00% []
🔵 be/src/exec/pipeline/scan/scan_operator.cpp 1 1 100.00% []

@wyb wyb merged commit d9d9c70 into StarRocks:main Mar 22, 2024
53 of 54 checks passed
Copy link

@Mergifyio backport branch-3.2

@github-actions github-actions bot removed the 3.2 label Mar 22, 2024
Copy link

@Mergifyio backport branch-3.1

Copy link

@Mergifyio backport branch-3.0

@github-actions github-actions bot removed the 3.1 label Mar 22, 2024
Copy link
Contributor

mergify bot commented Mar 22, 2024

backport branch-3.2

✅ Backports have been created

@github-actions github-actions bot removed the 3.0 label Mar 22, 2024
Copy link

@Mergifyio backport branch-2.5

@github-actions github-actions bot removed the 2.5 label Mar 22, 2024
Copy link
Contributor

mergify bot commented Mar 22, 2024

backport branch-3.1

✅ Backports have been created

Copy link
Contributor

mergify bot commented Mar 22, 2024

backport branch-3.0

✅ Backports have been created

Copy link
Contributor

mergify bot commented Mar 22, 2024

backport branch-2.5

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Mar 22, 2024
Signed-off-by: trueeyu <lxhhust350@qq.com>
(cherry picked from commit d9d9c70)

# Conflicts:
#	be/src/exec/pipeline/scan/olap_scan_prepare_operator.cpp
mergify bot pushed a commit that referenced this pull request Mar 22, 2024
Signed-off-by: trueeyu <lxhhust350@qq.com>
(cherry picked from commit d9d9c70)

# Conflicts:
#	be/src/exec/pipeline/scan/olap_scan_prepare_operator.cpp
mergify bot pushed a commit that referenced this pull request Mar 22, 2024
Signed-off-by: trueeyu <lxhhust350@qq.com>
(cherry picked from commit d9d9c70)

# Conflicts:
#	be/src/exec/pipeline/scan/olap_scan_prepare_operator.cpp
#	be/src/testutil/sync_point.h
mergify bot pushed a commit that referenced this pull request Mar 22, 2024
Signed-off-by: trueeyu <lxhhust350@qq.com>
(cherry picked from commit d9d9c70)

# Conflicts:
#	be/src/exec/pipeline/scan/olap_scan_prepare_operator.cpp
#	be/src/testutil/sync_point.h
#	be/test/CMakeLists.txt
wanpengfei-git pushed a commit that referenced this pull request Mar 25, 2024
…) (#43003)

Signed-off-by: trueeyu <lxhhust350@qq.com>
Co-authored-by: trueeyu <lxhhust350@qq.com>
wanpengfei-git pushed a commit that referenced this pull request Mar 25, 2024
…) (#43004)

Signed-off-by: trueeyu <lxhhust350@qq.com>
Co-authored-by: trueeyu <lxhhust350@qq.com>
wanpengfei-git pushed a commit that referenced this pull request Mar 25, 2024
…) (#43005)

Signed-off-by: trueeyu <lxhhust350@qq.com>
Co-authored-by: trueeyu <lxhhust350@qq.com>
wanpengfei-git pushed a commit that referenced this pull request Mar 25, 2024
…) (#43006)

Signed-off-by: trueeyu <lxhhust350@qq.com>
Co-authored-by: trueeyu <lxhhust350@qq.com>
trueeyu added a commit to trueeyu/starrocks that referenced this pull request Mar 26, 2024
…Rocks#42994) (StarRocks#43006)

Signed-off-by: trueeyu <lxhhust350@qq.com>
Co-authored-by: trueeyu <lxhhust350@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants