Commit Graph

81701 Commits

Author SHA1 Message Date
Azat Khuzhin
c9e93b21c2 Fix tiny race between count() and INSERT/merges/... in MergeTree
Before it was possible to return stale counter from
StorageMergeTree::totalRows() (that is used for
optimize_trivial_count_query) since the accounting is done in two steps:
- subtract old number of rows
  <-- here the number can be zero, even though there are rows -->
- add new number of rows

This was found by CI [1] in 01615_random_one_shard_insertion test:

Here you can see that INSERT went to both tables:

<details>

    2022.01.16 09:07:34.288252 [ 154369 ] {a1905be0-93da-460c-8c6f-9b5adace72a0} <Debug> DistributedBlockOutputStream: It took 0.035197041 sec. to insert 100
    blocks, 2841.1479249065287 rows per second. Insertion status:
    Wrote 54 blocks and 54 rows on shard 0 replica 0, localhost:9000 (average 0 ms per block, the slowest block 1 ms)
    Wrote 46 blocks and 46 rows on shard 1 replica 0, localhost:9000 (average 0 ms per block, the slowest block 1 ms)

</details>

But the test fails, since select from shard1.tbl returns 0, and the
problem was concurrent merge:

<details>

    2022.01.16 09:07:34.289470 [ 146495 ] {cd9d4cf2-7131-4179-b0b2-3aeec4045755} <Debug> executeQuery: (from [::1]:42082) (comment: 01615_random_one_shard_insertion.sql) select count() != 0 from shard_0.tbl;
    2022.01.16 09:07:34.289564 [ 375 ] {c7a885fa-4ef4-4dcf-a4de-1650d44fa0ab::all_1_54_9} <Debug> MergeTask::MergeProjectionsStage: Merge sorted 54 rows, containing 1 columns (1 merged, 0 gathered) in 0.00171193 sec., 31543.345814373253 rows/sec., 246.43 KiB>
    2022.01.16 09:07:34.289810 [ 375 ] {c7a885fa-4ef4-4dcf-a4de-1650d44fa0ab::all_1_54_9} <Trace> shard_0.tbl (c7a885fa-4ef4-4dcf-a4de-1650d44fa0ab): Renaming temporary part tmp_merge_all_1_54_9 to all_1_54_9.
    2022.01.16 09:07:34.289858 [ 146495 ] {cd9d4cf2-7131-4179-b0b2-3aeec4045755} <Trace> ContextAccess (default): Access granted: SELECT(number) ON shard_0.tbl
    2022.01.16 09:07:34.289897 [ 375 ] {c7a885fa-4ef4-4dcf-a4de-1650d44fa0ab::all_1_54_9} <Trace> shard_0.tbl (c7a885fa-4ef4-4dcf-a4de-1650d44fa0ab) (MergerMutator): Merged 6 parts: from all_1_49_8 to all_54_54_0
    2022.01.16 09:07:34.289920 [ 146495 ] {cd9d4cf2-7131-4179-b0b2-3aeec4045755} <Trace> InterpreterSelectQuery: WithMergeableState -> Complete
    2022.01.16 09:07:34.289987 [ 375 ] {} <Debug> MemoryTracker: Peak memory usage Mutate/Merge: 3.12 MiB.
    2022.01.16 09:07:34.290305 [ 154344 ] {cd9d4cf2-7131-4179-b0b2-3aeec4045755} <Trace> MergingAggregatedTransform: Reading blocks of partially aggregated data.
    2022.01.16 09:07:34.290332 [ 154344 ] {cd9d4cf2-7131-4179-b0b2-3aeec4045755} <Debug> MergingAggregatedTransform: Read 1 blocks of partially aggregated data, total 1 rows.
    2022.01.16 09:07:34.290343 [ 154344 ] {cd9d4cf2-7131-4179-b0b2-3aeec4045755} <Trace> Aggregator: Merging partially aggregated single-level data.
    2022.01.16 09:07:34.290358 [ 154344 ] {cd9d4cf2-7131-4179-b0b2-3aeec4045755} <Trace> Aggregator: Merged partially aggregated single-level data.
    2022.01.16 09:07:34.290366 [ 154344 ] {cd9d4cf2-7131-4179-b0b2-3aeec4045755} <Trace> Aggregator: Converting aggregated data to blocks
    2022.01.16 09:07:34.290391 [ 154344 ] {cd9d4cf2-7131-4179-b0b2-3aeec4045755} <Debug> Aggregator: Converted aggregated data to blocks. 1 rows, 8.00 B in 1.0939e-05 sec. (91416.034 rows/sec., 714.19 KiB/sec.)
    2022.01.16 09:07:34.290709 [ 146495 ] {cd9d4cf2-7131-4179-b0b2-3aeec4045755} <Information> executeQuery: Read 1 rows, 4.01 KiB in 0.001187722 sec., 841 rows/sec., 3.30 MiB/sec.
    2022.01.16 09:07:34.290774 [ 146495 ] {cd9d4cf2-7131-4179-b0b2-3aeec4045755} <Debug> MemoryTracker: Peak memory usage (for query): 0.00 B.

</details>

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/33675/7848ea7d609e4c720e8e4494eb6207c0751f5aea/stateless_tests__ubsan__actions_.html

This also fixes a race between DROP TABLE check and INSERT/merges.

v0: use Active parts instead.
v2: fix total counters accounting instead.
2022-01-18 23:58:02 +03:00
Yatsishin Ilya
e64351de37 Disable dh_update_autotools_config 2022-01-18 20:10:38 +00:00
Nikolay Degterinsky
f7e315bb0a
Merge pull request #33750 from yohannj/fix_doc_tuplePlus
fix/doc: close code highlight before tuplePlus
2022-01-18 22:45:58 +03:00
Yohann Jardin
b1a35c934f fix/doc: close code highlight before tuplePlus 2022-01-18 20:38:30 +01:00
alesapin
127365658d Followup 2022-01-18 22:00:52 +03:00
alesapin
e7ee116358
Update src/Storages/MergeTree/MergeTreeData.cpp
Co-authored-by: tavplubix <avtokmakov@yandex-team.ru>
2022-01-18 22:00:23 +03:00
alesapin
24f4a5040d Better exception message 2022-01-18 21:59:54 +03:00
alesapin
e89d067cbf
Merge pull request #33744 from ClickHouse/Felixoid-patch-1
Fix release_branches workflow for some cases
2022-01-18 21:58:43 +03:00
Yatsishin Ilya
9d044db183 Merge remote-tracking branch 'origin' into cleanup-build 2022-01-18 17:53:33 +00:00
Yatsishin Ilya
3e1d0fdd79 Merge branch 'fix-debian-descriptions' into cleanup-build 2022-01-18 17:53:18 +00:00
Yatsishin Ilya
78d6d77a93 Improve descriptions 2022-01-18 16:34:56 +00:00
Mikhail f. Shiryaev
105b50eccf
Fix release_branches workflow for some cases 2022-01-18 17:34:05 +01:00
Maksim Kita
123802b43b
Merge pull request #33739 from vdimir/issue_31009
Add test issue_31009
2022-01-18 17:31:31 +01:00
alesapin
358e3a165c Better exception text on suspicious broken parts 2022-01-18 19:28:58 +03:00
Yatsishin Ilya
25adc59e9f cmake update 2022-01-18 15:41:53 +00:00
Yatsishin Ilya
0540c2672f libpqxx without confgure_file cmake 2022-01-18 15:40:32 +00:00
alesapin
e5ec1aa446
Merge pull request #33642 from ClickHouse/add_integration_test_for_zero_duplication
Fix bug with background moves in zero copy replication
2022-01-18 18:32:16 +03:00
Yatsishin Ilya
f59c7f5254 Add more build paths to .gitignore 2022-01-18 15:25:48 +00:00
Maksim Kita
821c5dd989 Fix build 2022-01-18 14:46:19 +00:00
Kseniia Sumarokova
5561850f82
Merge pull request #33720 from cnmade/PF0118
Translate zh/sql/statements  index and use document
2022-01-18 17:44:38 +03:00
liuneng1994
5e1e512bf2 fix check style
Signed-off-by: neng.liu <neng.liu@kyligence.io>
2022-01-18 14:42:28 +00:00
Kruglov Pavel
2295a07066
Merge pull request #33534 from azat/fwd-decl
RFC: Split headers, move SystemLog into module, more forward declarations
2022-01-18 17:22:49 +03:00
Maksim Kita
0e8498849b
Merge pull request #33718 from den-crane/patch-58
Changelog. uniq*States are incompatible (UUID)
2022-01-18 15:09:59 +01:00
Denny Crane
9d87ca003f uniqState / uniqHLL12State / uniqCombinedState / uniqCombined64State Backward Incompatible from 21.6 2022-01-18 09:59:46 -04:00
vdimir
98d036e2c0
Add test, close issue #31009 2022-01-18 16:27:34 +03:00
Maksim Kita
562098779f Fixed style check 2022-01-18 13:26:23 +00:00
Maksim Kita
6536c3aaee Added performance tests 2022-01-18 13:20:54 +00:00
Maksim Kita
60bcf88228 Added IntervalTree documentation 2022-01-18 13:20:43 +00:00
liuneng1994
15ea37c4ae ignore file not found exception
Signed-off-by: neng.liu <neng.liu@kyligence.io>
2022-01-18 12:49:40 +00:00
Maksim Kita
30dab61f97
Merge pull request #33526 from kitaisreal/dictionary-rename-fix
Dictionary rename fix
2022-01-18 13:11:34 +01:00
Dmitry Novik
43838c1b4c
Merge pull request #33355 from ucasfl/decimal-binary-op
Enable binary arithmetic between Decimal and Float
2022-01-18 14:04:26 +03:00
Vxider
fb62960836 remove unused variable 2022-01-18 09:34:26 +00:00
Anton Ivashkin
7c26a832f8 Fix restore S3 disk without detached directories 2022-01-18 12:31:31 +03:00
Vxider
ba0a702807 enable stream to table join in windowview 2022-01-18 09:20:15 +00:00
Vxider
f526ff2a51 remove unused variable 2022-01-18 09:03:16 +00:00
alesapin
eff85d3352 Review fixes 2022-01-18 11:27:01 +03:00
mergify[bot]
df869c5b9c
Merge branch 'master' into fix_ignore_hdfs_error 2022-01-18 07:05:24 +00:00
Ilya Yatsishin
601b6adaff
Merge pull request #33634 from qoega/fix-mongo2-compose 2022-01-18 09:47:25 +03:00
liuneng1994
c6e205b2ad add error check 2022-01-18 06:21:40 +00:00
cnmade
4043529300 Translate zh/sql/statements:rev translate 2022-01-18 11:40:29 +08:00
cnmade
fc38cffd33 Translate zh/sql/statements index and use document 2022-01-18 11:06:41 +08:00
alexey-milovidov
c0bb166b55
Merge pull request #33691 from ClickHouse/changelog-22.1
Add changelog for 22.1
2022-01-18 03:35:23 +03:00
alexey-milovidov
19fadd8d41
Merge pull request #33707 from kitaisreal/h3-remove-functions-rads-to-degs
H3 remove functions degsToRads, radsToDegs
2022-01-18 03:32:38 +03:00
Alexey Milovidov
a0cd7ad6e7 Mostly finish editing changelog 2022-01-18 03:24:10 +03:00
Alexey Milovidov
ba40b28732 Editing changelog, 75% done 2022-01-18 02:49:30 +03:00
Anton Popov
a25f2518e3
Merge pull request #33141 from 1over/feature_default_keyword
Add support of DEFAULT keyword for INSERT
2022-01-18 02:04:37 +03:00
alexeypavlenko
06b08b0e3a fix insert 2022-01-17 23:06:56 +02:00
alexeypavlenko
4cc1e25d45 simplify test 2022-01-17 22:36:03 +02:00
Maksim Kita
3ca17afa00 Fixed build 2022-01-17 20:35:52 +00:00
alexeypavlenko
8778eda2e0 fix unit test (sorry, took a while to build it on my laptop) 2022-01-17 22:35:12 +02:00