mirror of
https://github.com/plausible/analytics.git
synced 2024-11-26 00:24:44 +03:00
Disable deduplication for improted_* tables in CH (#3429)
* Disable deduplication for improted_* tables in CH * Make migration cluster-aware * Bump cache to avoid problems * Fix cache dump * Remove cache bump
This commit is contained in:
parent
fd8a9529f9
commit
4cdf843ade
@ -0,0 +1,34 @@
|
||||
defmodule Plausible.IngestRepo.Migrations.DisableDeduplicationWindowForImports do
|
||||
use Ecto.Migration
|
||||
|
||||
@import_tables ~w(
|
||||
imported_visitors
|
||||
imported_sources
|
||||
imported_pages
|
||||
imported_entry_pages
|
||||
imported_exit_pages
|
||||
imported_locations
|
||||
imported_devices
|
||||
imported_browsers
|
||||
imported_operating_systems
|
||||
)
|
||||
|
||||
def change do
|
||||
cluster_query = "SELECT 1 FROM system.replicas WHERE table = 'imported_visitors'"
|
||||
|
||||
cluster? =
|
||||
case Ecto.Adapters.SQL.query(Plausible.IngestRepo, cluster_query) |> IO.inspect() do
|
||||
{:ok, %{rows: []}} -> false
|
||||
{:ok, _} -> true
|
||||
end
|
||||
|
||||
for table <- @import_tables do
|
||||
execute """
|
||||
ALTER TABLE #{table} #{if cluster?, do: "ON CLUSTER '{cluster}'"} MODIFY SETTING replicated_deduplication_window = 0
|
||||
""",
|
||||
"""
|
||||
ALTER TABLE #{table} #{if cluster?, do: "ON CLUSTER '{cluster}'"} MODIFY SETTING replicated_deduplication_window = 100
|
||||
"""
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user