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

make writebuffers cancelable #64478

Merged
merged 27 commits into from
Jun 26, 2024
Merged

make writebuffers cancelable #64478

merged 27 commits into from
Jun 26, 2024

Conversation

CheSema
Copy link
Member

@CheSema CheSema commented May 27, 2024

fixes #64451

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Fix bug with cancelation buffer when canceling a query.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

CI Settings

NOTE: If your merge the PR with modified CI you MUST KNOW what you are doing
NOTE: Checked options will be applied if set before CI RunConfig/PrepareRunConfig step

  • Allow: Integration Tests
  • Allow: Stateless tests
  • Allow: Stateful tests
  • Allow: Unit tests
  • Allow: Performance tests
  • Allow: All with aarch64
  • Allow: All with ASAN
  • Allow: All with TSAN
  • Allow: All with Analyzer
  • Allow: All with Azure
  • Allow: Add your option here

  • Exclude: Fast test
  • Exclude: Integration Tests
  • Exclude: Stateless tests
  • Exclude: Stateful tests
  • Exclude: Performance tests
  • Exclude: All with ASAN
  • Exclude: All with TSAN
  • Exclude: All with MSAN
  • Exclude: All with UBSAN
  • Exclude: All with Coverage
  • Exclude: All with Aarch64

  • do not test (only style check)
  • disable merge-commit (no merge from master before tests)
  • disable CI cache (job reuse)
  • allow: batch 1 for multi-batch jobs
  • allow: batch 2
  • allow: batch 3
  • allow: batch 4, 5 and 6

@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-bugfix Pull request with bugfix, not backported by default label May 27, 2024
@robot-ch-test-poll2
Copy link
Contributor

robot-ch-test-poll2 commented May 27, 2024

This is an automated comment for commit bbd9c77 with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Check nameDescriptionStatus
Bugfix validationChecks that either a new test (functional or integration) or there some changed tests that fail with the binary built on master branch❌ error
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR❌ failure
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc❌ failure
Successful checks
Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
ClickHouse build checkBuilds ClickHouse in various configurations for use in further steps. You have to fix the builds that fail. Build logs often has enough information to fix the error, but you might have to reproduce the failure locally. The cmake options can be found in the build log, grepping for cmake. Use these options and follow the general build process✅ success
Cloud fork sync (only for ClickHouse Inc. employees)If it fails, ask a maintainer for help✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkBuilds and tests the documentation✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integration tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Mergeable CheckChecks if all other necessary checks are successful✅ success
PR CheckChecks correctness of the PR's body✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style checkRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success

@CheSema CheSema changed the title Fix bug with cancelation buffer when canceling a query. make writebuffers cancelable May 27, 2024
Copy link
Member

@antonio2368 antonio2368 left a comment

Choose a reason for hiding this comment

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

👍

src/IO/WriteBuffer.h Outdated Show resolved Hide resolved
@CheSema
Copy link
Member Author

CheSema commented May 28, 2024

It will take a time to pass all the tests here.

For example now fast tests are failed because
CompressedWriteBuffer calls finalize at the destructor. It is not good. The buffer bellow CompressedWriteBuffer could be already canceled.
Will try to catch such cases.

@CheSema
Copy link
Member Author

CheSema commented Jun 18, 2024

@CheSema
Copy link
Member Author

CheSema commented Jun 18, 2024

@antonio2368 could I ask you to check this once again?
I think I passed the CI. The last CI has a crash which turned out is not raleted to my changes.

@antonio2368 antonio2368 self-requested a review June 18, 2024 13:34
src/Client/Connection.cpp Outdated Show resolved Hide resolved
Co-authored-by: Antonio Andelic <antonio2368@users.noreply.github.com>
@CheSema
Copy link
Member Author

CheSema commented Jun 20, 2024

01926_order_by_desc_limit -- #65472
02922_deduplication_with_zero_copy -- #65486
test_when_s3_broken_pipe_at_upload_is_retried -- related to #65472
00988_parallel_parts_removal -- #65473

@CheSema CheSema enabled auto-merge June 20, 2024 15:40
@CheSema CheSema disabled auto-merge June 20, 2024 15:41
@CheSema
Copy link
Member Author

CheSema commented Jun 20, 2024

I have rerun CI because Bugfix Validation has failed with unclear reason.

@CheSema
Copy link
Member Author

CheSema commented Jun 21, 2024

https://s3.amazonaws.com/clickhouse-test-reports/64478/19bafb5063ece9d71f44f248b35087800c4f302c/stress_test__ubsan_.html

 [ 4096 ] {a7c87804-bf65-4264-863f-d34164941762} <Fatal> : Logical error: \'false && "WriteBuffer is not finalized in destructor."\'.

related to the issue.

It is a good catch!

2024.06.20 23:44:30.479523 [ 4096 ] {a7c87804-bf65-4264-863f-d34164941762} <Error> void DB::MergeTreeDeduplicationLog::shutdown(): Code: 439. DB::Exception: Cannot schedule a task: fault injected (threads=87, jobs=0). (CANNOT_SCHEDULE_TASK), Stack trace (when copying this message, always include the lines below):

0. std::exception::capture() @ 0x00000000183d97eb
1. ./build_docker/./base/poco/Foundation/src/Exception.cpp:28: Poco::Exception::Exception(String const&, int) @ 0x0000000036ceb445
2. ./build_docker/./src/Common/Exception.cpp:101: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x0000000024361e8b
3. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x0000000018259796
4. ./src/Common/LoggingFormatStringHelpers.h:45: void ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool)::'lambda'(String const&)::operator()(String const&) const @ 0x000000002447e53a
5. ./build_docker/./src/Common/ThreadPool.cpp:0: void ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool) @ 0x00000000244782ad
6. ./contrib/llvm-project/libcxx/include/__functional/function.h:818: ? @ 0x0000000024478185
7. ./contrib/llvm-project/libcxx/include/__functional/function.h:818: ? @ 0x000000002f109f34
8. ./contrib/llvm-project/libcxx/include/__functional/function.h:717: ? @ 0x000000002f109d17
9. ./contrib/llvm-project/libcxx/include/list:385: DB::TaskTracker::add(std::function<void ()>&&) @ 0x000000002f190e86
10. ./contrib/llvm-project/libcxx/include/__functional/function.h:818: ? @ 0x000000002f167fc3
11. ./build_docker/./src/IO/WriteBufferFromS3.cpp:180: DB::WriteBufferFromS3::preFinalize() @ 0x000000002f16737f
12. ./build_docker/./src/IO/WriteBufferFromFileDecorator.cpp:0: DB::WriteBufferFromFileDecorator::preFinalize() @ 0x000000002ffe0fd6
13. ./build_docker/./src/IO/WriteBufferFromFileDecorator.cpp:26: DB::WriteBufferFromFileDecorator::finalizeImpl() @ 0x000000002ffe0c1d
14. ./build_docker/./src/Disks/IO/WriteBufferWithFinalizeCallback.cpp:19: DB::WriteBufferWithFinalizeCallback::finalizeImpl() @ 0x000000002ffe0630
15. DB::WriteBuffer::finalize() @ 0x000000001827385a
16. ./contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:302: DB::MergeTreeDeduplicationLog::shutdown() @ 0x00000000335864f0
17. ./contrib/llvm-project/libcxx/include/__memory/shared_ptr.h:436: DB::InterpreterDropQuery::executeToTableImpl(std::shared_ptr<DB::Context const> const&, DB::ASTDropQuery&, std::shared_ptr<DB::IDatabase>&, StrongTypedef<wide::integer<128ul, unsigned int>, DB::UUIDTag>&) @ 0x0000000030d902d4
18. ./build_docker/./src/Interpreters/InterpreterDropQuery.cpp:442: DB::InterpreterDropQuery::executeToDatabaseImpl(DB::ASTDropQuery const&, std::shared_ptr<DB::IDatabase>&, std::vector<StrongTypedef<wide::integer<128ul, unsigned int>, DB::UUIDTag>, std::allocator<StrongTypedef<wide::integer<128ul, unsigned int>, DB::UUIDTag>>>&) @ 0x0000000030d94
9fa
19. ./build_docker/./src/Interpreters/InterpreterDropQuery.cpp:0: DB::InterpreterDropQuery::executeToDatabase(DB::ASTDropQuery const&) @ 0x0000000030d8d42b
20. ./build_docker/./src/Interpreters/InterpreterDropQuery.cpp:96: DB::InterpreterDropQuery::executeSingleDropQuery(std::shared_ptr<DB::IAST> const&) @ 0x0000000030d8c059
21. ./build_docker/./src/Interpreters/InterpreterDropQuery.cpp:0: DB::InterpreterDropQuery::execute() @ 0x0000000030d8b40e
22. ./build_docker/./src/Interpreters/executeQuery.cpp:0: DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x0000000031babea6
23. ./build_docker/./src/Interpreters/executeQuery.cpp:0: DB::executeQuery(DB::ReadBuffer&, DB::WriteBuffer&, bool, std::shared_ptr<DB::Context>, std::function<void (DB::QueryResultDetails const&)>, DB::QueryFlags, std::optional<DB::FormatSettings> const&, std::function<void (DB::IOutputFormat&, String const&, std::shared_ptr<DB::Context const> co
nst&, std::optional<DB::FormatSettings> const&)>) @ 0x0000000031bb20ae
24. ./contrib/llvm-project/libcxx/include/__functional/function.h:818: ? @ 0x000000003389824e
25. ./build_docker/./src/Server/HTTPHandler.cpp:1161: DB::HTTPHandler::handleRequest(DB::HTTPServerRequest&, DB::HTTPServerResponse&, StrongTypedef<unsigned long, ProfileEvents::EventTag> const&) @ 0x000000003389ef09
26. ./build_docker/./src/Server/HTTP/HTTPServerConnection.cpp:71: DB::HTTPServerConnection::run() @ 0x0000000033990ac3
27. ./build_docker/./base/poco/Net/src/TCPServerConnection.cpp:57: Poco::Net::TCPServerConnection::start() @ 0x0000000036e3cb78
28. ./contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:302: Poco::Net::TCPServerDispatcher::run() @ 0x0000000036e3dcb2
29. ./build_docker/./base/poco/Foundation/src/ThreadPool.cpp:219: Poco::PooledThread::run() @ 0x0000000036d8eec1
30. ./base/poco/Foundation/include/Poco/AutoPtr.h:205: Poco::ThreadImpl::runnableEntry(void*) @ 0x0000000036d89ecf
31. ? @ 0x00007f872c6d7ac3
 (version 24.7.1.47)

It is an example when finalize throws an exception. Here it is CANNOT_SCHEDULE_TASK.

After that, WriteBufferFromFileDecorator is considered as finalized and WriteBufferFromFileDecorator::impl is not.
We unable to release that bundle of two buffers properly.

I need to untangle this as well.

@CheSema
Copy link
Member Author

CheSema commented Jun 26, 2024

02956_rocksdb_bulk_sink flaks in master.

@CheSema CheSema added this pull request to the merge queue Jun 26, 2024
Merged via the queue into master with commit 4d40983 Jun 26, 2024
228 of 240 checks passed
@CheSema CheSema deleted the chesema-fix-buffer-cancelation branch June 26, 2024 22:59
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_query_is_canceled_with_inf_retries flaks due to miss implementation for cancelation logic
4 participants