- Move some code into module part to avoid dependency from IStorage in SystemLog
- Remove extra headers from SystemLog.h
- Rewrite some code that was relying on headers that was included by SystemLog.h
v2: rebase
v3: squash move into module part with explicit template instantiation
(to make each commit self compilable after rebase)
`ALTER TABLE ... FETCH` and `ALTER TABLE ... ATTACH` queries were
disabled in the Replicated database engine, because it could cause
accidental duplication of data.
This enables these queries but without replicating them.
In the case of `FETCH`, the part will only be fetched on the server
where the query is issued.
Similarly, in the case of `ATTACH`, the attached part only needs to
be available on the server where the query is issued.
If the table itself is using one of the Replicated MergeTree engines,
the attached data is then replicated by the table engine itself,
without intervention of the database engine.
This change is meant to help with live backup/restore when using the
Replicated database engine, using FREEZE for backup and ATTACH for
restore.
Add an ability to reset custom setting to default and remove it from table's metadata.
This will allow to rollback the change without knowing the system/config's default.
Signed-off-by: Aleksei Semiglazov <asemiglazov@cloudflare.com>
TODO (suggested by Nikolai)
1. Build query plan fro current query (inside storage::read) up to WithMergableState
2. Check, that plan is simple enough: Aggregating - Expression - Filter - ReadFromStorage (or simplier)
3. Check, that filter is the same as filter in projection, and also expression calculates the same aggregation keys as in projection
4. Return WithMergableState if projection applies
3 will be easier to do with ActionsDAG, cause it sees all functions, and dependencies are direct (but it is possible with ExpressionActions also)
Also need to figure out how prewhere works for projections, and
row_filter_policies.
wip
This PR fixes a lock issue that happens while executing
`ALTER LIVE VIEW` query with the `REFRESH` command that
results in a exception. The problem is that lock is currently
being acquired in `InterpreterALterQuery.cpp`
in the `InterpreterAlterQuery::execute()` method and lock
is again being reacquired in `StorageLiveView.cpp` in the
` StorageLiveView::refresh` method. This removes that extra
lock.
Before fix:
```sql
--create table
CREATE TABLE test0 (
c0 UInt64
) ENGINE = MergeTree() PARTITION BY c0 ORDER BY c0;
-- enable experimental_live_view
:) SET allow_experimental_live_view=1
-- create live view;
:) CREATE LIVE VIEW live1 AS SELECT * FROM table0;
-- alter live view results in exception
:) ALTER LIVE VIEW live1 REFRESH;
...
...
Received exception from server (version 20.8.1):
Code: 49. DB::Exception: Received from localhost:9000. DB::Exception: RWLockImpl::getLock(): RWLock is already locked in exclusive mode.
```
After fix:
```sql
:) ALTER LIVE VIEW live1 REFRESH;
ALTER LIVE VIEW live1
REFRESH
Ok.
0 rows in set. Elapsed: 0.016 sec.
```
In this version of the databaseReplicated sequential persistent zk nodes
are used to order DDL queries. Db replicated ddl queries are executed
in the backgrould pool no matter whether it's proposed by the same
replica or not.
add an option to create replicated tables within replicated db without specifying zk path and replica id
add replicated sch pool
disable replication of alter queries for replicated tables in replicated dbs
snapshot prototype. amend of replicated db workflow
add prototype of integration tests for replicated db