fix invalid segment id bug after mutation

skip hardlinking inverted index files in mutation
This commit is contained in:
cangyin 2023-03-17 10:00:50 +08:00
parent 49feba9272
commit 51ea0888e5
3 changed files with 36 additions and 0 deletions

View File

@ -19,6 +19,7 @@
#include <Storages/MergeTree/MergeTreeDataWriter.h>
#include <Storages/MutationCommands.h>
#include <Storages/MergeTree/MergeTreeDataMergerMutator.h>
#include <Storages/MergeTree/MergeTreeIndexInverted.h>
#include <DataTypes/DataTypeNullable.h>
#include <boost/algorithm/string/replace.hpp>
#include <Common/ProfileEventsScope.h>
@ -551,6 +552,15 @@ static NameSet collectFilesToSkip(
/// Since MinMax index has .idx2 extension, we need to add correct extension.
files_to_skip.insert(index->getFileName() + index->getSerializedFileExtension());
files_to_skip.insert(index->getFileName() + mrk_extension);
// skip all inverted index files, for they will be re-built
if (dynamic_cast<const MergeTreeIndexInverted *>(&*index) != nullptr)
{
files_to_skip.insert(index->getFileName() + ".gin_dict");
files_to_skip.insert(index->getFileName() + ".gin_post");
files_to_skip.insert(index->getFileName() + ".gin_sed");
files_to_skip.insert(index->getFileName() + ".gin_sid");
}
}
for (const auto & projection : projections_to_recalc)

View File

@ -0,0 +1,3 @@
1
2
I am not inverted

View File

@ -0,0 +1,23 @@
SET allow_experimental_inverted_index=1;
DROP TABLE IF EXISTS t;
CREATE TABLE t
(
`timestamp` UInt64,
`s` String,
INDEX idx s TYPE inverted(3) GRANULARITY 1
)
ENGINE = MergeTree
ORDER BY tuple()
SETTINGS min_rows_for_wide_part = 1, min_bytes_for_wide_part = 1;
INSERT INTO t (s) VALUES ('I am inverted');
SELECT data_version FROM system.parts WHERE database=currentDatabase() AND table='t' AND active=1;
-- do update column synchronously
ALTER TABLE t UPDATE s='I am not inverted' WHERE 1 SETTINGS mutations_sync=1;
SELECT data_version FROM system.parts WHERE database=currentDatabase() AND table='t' AND active=1;
SELECT s FROM t WHERE s LIKE '%inverted%' SETTINGS force_data_skipping_indices='idx';