Skip to content

Commit

Permalink
Install downgrade scripts by default.
Browse files Browse the repository at this point in the history
This commit removes downgrades/ folders and merges their contents with
their parents.
  • Loading branch information
hanefi committed Jan 23, 2023
1 parent 93fcc5c commit 7fab05d
Show file tree
Hide file tree
Showing 35 changed files with 185 additions and 94 deletions.
6 changes: 0 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ that are missing in earlier minor versions.
./configure
make
make install
# Optionally, you might instead want to use `make install-all`
# since `multi_extension` regression test would fail due to missing downgrade scripts.
cd src/test/regress
pip install pipenv
Expand Down Expand Up @@ -81,8 +79,6 @@ that are missing in earlier minor versions.
./configure
make
sudo make install
# Optionally, you might instead want to use `sudo make install-all`
# since `multi_extension` regression test would fail due to missing downgrade scripts.
cd src/test/regress
pip install pipenv
Expand Down Expand Up @@ -131,8 +127,6 @@ that are missing in earlier minor versions.
PG_CONFIG=/usr/pgsql-14/bin/pg_config ./configure
make
sudo make install
# Optionally, you might instead want to use `sudo make install-all`
# since `multi_extension` regression test would fail due to missing downgrade scripts.
cd src/test/regress
pip install pipenv
Expand Down
11 changes: 3 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ clean-full:
$(MAKE) -C src/backend/distributed/ clean-full
.PHONY: extension install-extension clean-extension clean-full

install-downgrades:
$(MAKE) -C src/backend/distributed/ install-downgrades
install-all: install-headers install-pg_send_cancellation
$(MAKE) -C src/backend/columnar/ install-all
$(MAKE) -C src/backend/distributed/ install-all
install-all: install

# build citus_send_cancellation binary
pg_send_cancellation:
Expand All @@ -64,8 +60,7 @@ check-style:
cd ${citus_abs_top_srcdir} && citus_indent --quiet --check
.PHONY: reindent check-style

# depend on install-all so that downgrade scripts are installed as well
check: all install-all
check: all install
$(MAKE) -C src/test/regress check-full

.PHONY: all check clean install install-downgrades install-all
.PHONY: all check clean install install-all
2 changes: 1 addition & 1 deletion ci/build-citus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ build_ext() {
CFLAGS=-Werror "${basedir}/configure" PG_CONFIG="/usr/lib/postgresql/${pg_major}/bin/pg_config" --enable-coverage --with-security-flags

installdir="${builddir}/install"
make -j$(nproc) && mkdir -p "${installdir}" && { make DESTDIR="${installdir}" install-all || make DESTDIR="${installdir}" install ; }
make -j$(nproc) && mkdir -p "${installdir}" && make DESTDIR="${installdir}" install

cd "${installdir}" && find . -type f -print > "${builddir}/files.lst"
tar cvf "${basedir}/install-${pg_major}.tar" `cat ${builddir}/files.lst`
Expand Down
121 changes: 121 additions & 0 deletions gucs_in_citus.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
citus.all_modifications_commutative
citus.allow_modifications_from_workers_to_replicated_tables
citus.allow_nested_distributed_execution
citus.allow_unsafe_constraints
citus.allow_unsafe_locks_from_workers
citus.background_task_queue_interval
citus.check_available_space_before_move
citus.cluster_name
citus.coordinator_aggregation_strategy
citus.copy_switchover_threshold
citus.count_distinct_error_rate
citus.cpu_priority
citus.cpu_priority_for_logical_replication_senders
citus.create_object_propagation
citus.defer_drop_after_shard_move
citus.defer_drop_after_shard_split
citus.defer_shard_delete_interval
citus.desired_percent_disk_available_after_move
citus.distributed_deadlock_detection_factor
citus.enable_alter_database_owner
citus.enable_alter_role_propagation
citus.enable_alter_role_set_propagation
citus.enable_binary_protocol
citus.enable_cluster_clock
citus.enable_cost_based_connection_establishment
citus.enable_create_role_propagation
citus.enable_create_type_propagation
citus.enable_ddl_propagation
citus.enable_deadlock_prevention
citus.enable_fast_path_router_planner
citus.enable_local_execution
citus.enable_local_reference_table_foreign_keys
citus.enable_manual_changes_to_shards
citus.enable_manual_metadata_changes_for_user
citus.enable_metadata_sync
citus.enable_repartition_joins
citus.enable_repartitioned_insert_select
citus.enable_router_execution
citus.enable_single_hash_repartition_joins
citus.enable_statistics_collection
citus.enable_unique_job_ids
citus.enable_unsafe_triggers
citus.enable_unsupported_feature_messages
citus.enable_version_checks
citus.enforce_foreign_key_restrictions
citus.enforce_object_restrictions_for_local_objects
citus.executor_slow_start_interval
citus.explain_all_tasks
citus.explain_analyze_sort_method
citus.explain_distributed_queries
citus.force_max_query_parallelization
citus.function_opens_transaction_block
citus.grep_remote_commands
citus.hide_citus_dependent_objects
citus.hide_shards_from_app_name_prefixes
citus.isolation_test_session_process_id
citus.isolation_test_session_remote_process_id
citus.limit_clause_row_fetch_count
citus.local_copy_flush_threshold
citus.local_hostname
citus.local_shared_pool_size
citus.local_table_join_policy
citus.log_distributed_deadlock_detection
citus.log_intermediate_results
citus.log_local_commands
citus.log_multi_join_order
citus.log_remote_commands
citus.logical_replication_timeout
citus.max_adaptive_executor_pool_size
citus.max_background_task_executors
citus.max_cached_connection_lifetime
citus.max_cached_conns_per_worker
citus.max_client_connections
citus.max_high_priority_background_processes
citus.max_intermediate_result_size
citus.max_matview_size_to_auto_recreate
citus.max_rebalancer_logged_ignored_moves
citus.max_shared_pool_size
citus.max_worker_nodes_tracked
citus.metadata_sync_interval
citus.metadata_sync_retry_interval
citus.mitmfifo
citus.multi_shard_modify_mode
citus.multi_task_query_log_level
citus.next_cleanup_record_id
citus.next_operation_id
citus.next_placement_id
citus.next_shard_id
citus.node_connection_timeout
citus.node_conninfo
citus.override_table_visibility
citus.prevent_incomplete_connection_establishment
citus.propagate_session_settings_for_loopback_connection
citus.propagate_set_commands
citus.recover_2pc_interval
citus.remote_copy_flush_threshold
citus.remote_task_check_interval
citus.repartition_join_bucket_count_per_node
citus.replicate_reference_tables_on_activate
citus.replication_model
citus.running_under_isolation_test
citus.select_opens_transaction_block
citus.shard_count
citus.shard_replication_factor
citus.show_shards_for_app_name_prefixes
citus.skip_advisory_lock_permission_checks
citus.skip_constraint_validation
citus.skip_jsonb_validation_in_copy
citus.sort_returning
citus.stat_statements_max
citus.stat_statements_purge_interval
citus.stat_statements_track
citus.subquery_pushdown
citus.task_assignment_policy
citus.task_executor_type
citus.use_citus_managed_tables
citus.use_secondary_nodes
citus.values_materialization_threshold
citus.version
citus.worker_min_messages
citus.writable_standby_coordinator
4 changes: 1 addition & 3 deletions src/backend/columnar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ MODULE_big = citus_columnar
EXTENSION = citus_columnar

columnar_sql_files = $(patsubst $(citus_abs_srcdir)/%,%,$(wildcard $(citus_abs_srcdir)/sql/*.sql))
columnar_downgrade_sql_files = $(patsubst $(citus_abs_srcdir)/%,%,$(wildcard $(citus_abs_srcdir)/sql/downgrades/*.sql))
DATA = $(columnar_sql_files) \
$(columnar_downgrade_sql_files)
DATA = $(columnar_sql_files)

PG_CPPFLAGS += -I$(libpq_srcdir) -I$(safestringlib_srcdir)/include

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ ADD FOREIGN KEY (storage_id, stripe_num)
REFERENCES columnar.stripe(storage_id, stripe_num) ON DELETE CASCADE;

-- define columnar_ensure_objects_exist again
#include "../udfs/columnar_ensure_objects_exist/10.0-1.sql"
#include "udfs/columnar_ensure_objects_exist/10.0-1.sql"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../udfs/alter_columnar_table_set/10.0-1.sql"
#include "../udfs/alter_columnar_table_reset/10.0-1.sql"
#include "udfs/alter_columnar_table_set/10.0-1.sql"
#include "udfs/alter_columnar_table_reset/10.0-1.sql"

#include "../udfs/columnar_ensure_am_depends_catalog/10.2-4.sql"
#include "udfs/columnar_ensure_am_depends_catalog/10.2-4.sql"

DROP VIEW columnar.options;
DROP VIEW columnar.stripe;
Expand Down
19 changes: 1 addition & 18 deletions src/backend/distributed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ MODULE_big = citus
EXTENSION = citus

template_sql_files = $(patsubst $(citus_abs_srcdir)/%,%,$(wildcard $(citus_abs_srcdir)/sql/*.sql))
template_downgrade_sql_files = $(patsubst $(citus_abs_srcdir)/sql/downgrades/%,%,$(wildcard $(citus_abs_srcdir)/sql/downgrades/*.sql))
generated_sql_files = $(patsubst %,$(citus_abs_srcdir)/build/%,$(template_sql_files))
generated_downgrade_sql_files += $(patsubst %,$(citus_abs_srcdir)/build/sql/%,$(template_downgrade_sql_files))
# All citus--*.sql files that are used to upgrade between versions
DATA_built = $(generated_sql_files)

Expand Down Expand Up @@ -65,34 +63,19 @@ $(generated_sql_files): $(citus_abs_srcdir)/build/%: %
@# `man cpp` for further information
cd $(citus_abs_srcdir) && cpp -undef -w -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@

$(generated_downgrade_sql_files): $(citus_abs_srcdir)/build/sql/%: sql/downgrades/%
@mkdir -p $(citus_abs_srcdir)/$(SQL_DEPDIR) $(citus_abs_srcdir)/$(SQL_BUILDDIR)
@# -MF is used to store dependency files(.Po) in another directory for separation
@# -MT is used to change the target of the rule emitted by dependency generation.
@# -P is used to inhibit generation of linemarkers in the output from the preprocessor.
@# -undef is used to not predefine any system-specific or GCC-specific macros.
@# `man cpp` for further information
cd $(citus_abs_srcdir) && cpp -undef -w -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@

SQL_Po_files := $(wildcard $(SQL_DEPDIR)/*.Po)
ifneq (,$(SQL_Po_files))
include $(SQL_Po_files)
endif

.PHONY: clean-full install install-downgrades install-all
.PHONY: clean-full install install-all

cleanup-before-install:
rm -f $(DESTDIR)$(datadir)/$(datamoduledir)/citus.control
rm -f $(DESTDIR)$(datadir)/$(datamoduledir)/citus--*

install: cleanup-before-install

# install and install-downgrades should be run sequentially
install-all: install
$(MAKE) install-downgrades

install-downgrades: $(generated_downgrade_sql_files)
$(INSTALL_DATA) $(generated_downgrade_sql_files) '$(DESTDIR)$(datadir)/$(datamoduledir)/'

clean-full:
$(MAKE) clean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

DROP FUNCTION pg_catalog.citus_update_table_statistics(regclass);

#include "../udfs/citus_update_table_statistics/10.0-1.sql"
#include "udfs/citus_update_table_statistics/10.0-1.sql"

CREATE OR REPLACE FUNCTION master_update_table_statistics(relation regclass)
RETURNS VOID AS $$
Expand All @@ -43,7 +43,7 @@ COMMENT ON FUNCTION master_update_table_statistics(regclass)

DROP FUNCTION pg_catalog.citus_get_active_worker_nodes(OUT text, OUT bigint);
-- copy of citus--10.0-2--10.0-1.sql
#include "../../../columnar/sql/downgrades/columnar--10.0-2--10.0-1.sql"
#include "../../columnar/sql/columnar--10.0-2--10.0-1.sql"

-- copy of citus--10.0-1--9.5-1

Expand All @@ -56,14 +56,14 @@ DROP FUNCTION pg_catalog.citus_get_active_worker_nodes(OUT text, OUT bigint);
-- citus_drop_all_shards as we renamed it in Citus 10.0.
ALTER FUNCTION pg_catalog.citus_drop_all_shards(regclass, text, text)
RENAME TO master_drop_all_shards;
#include "../udfs/citus_drop_trigger/9.5-1.sql"
#include "udfs/citus_drop_trigger/9.5-1.sql"

-- Now we can safely drop notify_constraint_dropped as we downgraded citus_drop_trigger.
DROP FUNCTION pg_catalog.notify_constraint_dropped();

#include "../udfs/citus_finish_pg_upgrade/9.5-1.sql"
#include "udfs/citus_finish_pg_upgrade/9.5-1.sql"

#include "../../../columnar/sql/downgrades/columnar--10.0-1--9.5-1.sql"
#include "../../columnar/sql/columnar--10.0-1--9.5-1.sql"

DROP VIEW IF EXISTS pg_catalog.citus_tables;
DROP VIEW IF EXISTS public.citus_tables;
Expand Down Expand Up @@ -102,13 +102,13 @@ RENAME TO master_dist_placement_cache_invalidate;
ALTER FUNCTION pg_catalog.citus_dist_shard_cache_invalidate()
RENAME TO master_dist_shard_cache_invalidate;

#include "../udfs/citus_conninfo_cache_invalidate/9.5-1.sql"
#include "../udfs/citus_dist_local_group_cache_invalidate/9.5-1.sql"
#include "../udfs/citus_dist_node_cache_invalidate/9.5-1.sql"
#include "../udfs/citus_dist_object_cache_invalidate/9.5-1.sql"
#include "../udfs/citus_dist_partition_cache_invalidate/9.5-1.sql"
#include "../udfs/citus_dist_placement_cache_invalidate/9.5-1.sql"
#include "../udfs/citus_dist_shard_cache_invalidate/9.5-1.sql"
#include "udfs/citus_conninfo_cache_invalidate/9.5-1.sql"
#include "udfs/citus_dist_local_group_cache_invalidate/9.5-1.sql"
#include "udfs/citus_dist_node_cache_invalidate/9.5-1.sql"
#include "udfs/citus_dist_object_cache_invalidate/9.5-1.sql"
#include "udfs/citus_dist_partition_cache_invalidate/9.5-1.sql"
#include "udfs/citus_dist_placement_cache_invalidate/9.5-1.sql"
#include "udfs/citus_dist_shard_cache_invalidate/9.5-1.sql"

DROP VIEW pg_catalog.time_partitions;
DROP FUNCTION pg_catalog.time_partition_range(regclass);
Expand Down Expand Up @@ -150,10 +150,10 @@ CREATE FUNCTION pg_catalog.master_create_worker_shards(table_name text, shard_co

DROP FUNCTION pg_catalog.remove_local_tables_from_metadata();

#include "../udfs/citus_total_relation_size/7.0-1.sql"
#include "../udfs/upgrade_to_reference_table/8.0-1.sql"
#include "../udfs/undistribute_table/9.5-1.sql"
#include "../udfs/create_citus_local_table/9.5-1.sql"
#include "udfs/citus_total_relation_size/7.0-1.sql"
#include "udfs/upgrade_to_reference_table/8.0-1.sql"
#include "udfs/undistribute_table/9.5-1.sql"
#include "udfs/create_citus_local_table/9.5-1.sql"
DROP VIEW pg_catalog.citus_shards CASCADE;
DROP FUNCTION pg_catalog.citus_shard_sizes(OUT table_name text, OUT size bigint);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
DELETE FROM citus.pg_dist_object
WHERE classid = 'pg_catalog.pg_database'::regclass::oid;

#include "../../../columnar/sql/downgrades/columnar--10.1-1--10.0-3.sql"
#include "../../columnar/sql/columnar--10.1-1--10.0-3.sql"

DROP FUNCTION pg_catalog.create_distributed_table(regclass, text, citus.distribution_type, text, int);
CREATE FUNCTION create_distributed_table(table_name regclass,
Expand All @@ -30,21 +30,21 @@ DROP FUNCTION pg_catalog.worker_partitioned_relation_size(regclass);
DROP FUNCTION pg_catalog.worker_partitioned_table_size(regclass);
DROP FUNCTION pg_catalog.citus_local_disk_space_stats();

#include "../udfs/citus_prepare_pg_upgrade/9.5-1.sql"
#include "../udfs/citus_finish_pg_upgrade/10.0-1.sql"
#include "../udfs/get_rebalance_table_shards_plan/9.2-1.sql"
#include "udfs/citus_prepare_pg_upgrade/9.5-1.sql"
#include "udfs/citus_finish_pg_upgrade/10.0-1.sql"
#include "udfs/get_rebalance_table_shards_plan/9.2-1.sql"

-- the migration for citus_add_rebalance_strategy from 9.2-1 was the first one,
-- so it doesn't have a DROP. This is why we DROP manually here.
DROP FUNCTION pg_catalog.citus_add_rebalance_strategy;
#include "../udfs/citus_add_rebalance_strategy/9.2-1.sql"
#include "udfs/citus_add_rebalance_strategy/9.2-1.sql"

ALTER TABLE pg_catalog.pg_dist_rebalance_strategy DROP COLUMN improvement_threshold;

-- the migration for get_rebalance_progress from 9.0-1 was the first one,
-- so it doesn't have a DROP. This is why we DROP manually here.
DROP FUNCTION pg_catalog.get_rebalance_progress;
#include "../udfs/get_rebalance_progress/9.0-1.sql"
#include "udfs/get_rebalance_progress/9.0-1.sql"

CREATE OR REPLACE VIEW pg_catalog.citus_shards AS
WITH shard_sizes AS (SELECT * FROM pg_catalog.citus_shard_sizes())
Expand Down Expand Up @@ -79,7 +79,7 @@ ORDER BY
pg_dist_shard.logicalrelid::text, shardid
;

#include "../udfs/citus_finish_pg_upgrade/10.0-1.sql"
#include "udfs/citus_finish_pg_upgrade/10.0-1.sql"
CREATE FUNCTION citus_internal.pg_dist_rebalance_strategy_enterprise_check()
RETURNS TRIGGER
LANGUAGE C
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- citus--10.2-1--10.1-1

#include "../../../columnar/sql/downgrades/columnar--10.2-1--10.1-1.sql"
#include "../../columnar/sql/columnar--10.2-1--10.1-1.sql"

DROP FUNCTION pg_catalog.stop_metadata_sync_to_node(text, integer, bool);

Expand Down Expand Up @@ -35,4 +35,4 @@ CREATE FUNCTION pg_catalog.citus_drop_all_shards(logicalrelid regclass,
AS 'MODULE_PATHNAME', $$master_drop_all_shards$$;
COMMENT ON FUNCTION pg_catalog.citus_drop_all_shards(regclass, text, text)
IS 'drop all shards in a relation and update metadata';
#include "../udfs/citus_drop_trigger/10.0-1.sql"
#include "udfs/citus_drop_trigger/10.0-1.sql"
3 changes: 3 additions & 0 deletions src/backend/distributed/sql/citus--10.2-2--10.2-1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- citus--10.2-2--10.2-1

#include "../../columnar/sql/columnar--10.2-2--10.2-1.sql"
3 changes: 3 additions & 0 deletions src/backend/distributed/sql/citus--10.2-3--10.2-2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- citus--10.2-3--10.2-2

#include "../../columnar/sql/columnar--10.2-3--10.2-2.sql"
Loading

0 comments on commit 7fab05d

Please sign in to comment.