Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
991aaee6
Commit
991aaee6
authored
Nov 23, 2021
by
Adam Hegyi
Committed by
Patrick Bair
Nov 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prepare loose FK table for sliding partitioning
parent
28383338
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
5 deletions
+55
-5
db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb
...ge_default_value_of_loose_fk_deleted_records_partition.rb
+9
-0
db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb
...ove_hardcoded_partition_from_loose_fk_trigger_function.rb
+40
-0
db/schema_migrations/20211118100959
db/schema_migrations/20211118100959
+1
-0
db/schema_migrations/20211118103439
db/schema_migrations/20211118103439
+1
-0
db/structure.sql
db/structure.sql
+4
-5
No files found.
db/migrate/20211118100959_change_default_value_of_loose_fk_deleted_records_partition.rb
0 → 100644
View file @
991aaee6
# frozen_string_literal: true
class
ChangeDefaultValueOfLooseFkDeletedRecordsPartition
<
Gitlab
::
Database
::
Migration
[
1.0
]
enable_lock_retries!
def
change
change_column_default
(
:loose_foreign_keys_deleted_records
,
:partition
,
from:
nil
,
to:
1
)
end
end
db/migrate/20211118103439_remove_hardcoded_partition_from_loose_fk_trigger_function.rb
0 → 100644
View file @
991aaee6
# frozen_string_literal: true
class
RemoveHardcodedPartitionFromLooseFkTriggerFunction
<
Gitlab
::
Database
::
Migration
[
1.0
]
include
Gitlab
::
Database
::
MigrationHelpers
::
LooseForeignKeyHelpers
enable_lock_retries!
def
up
execute
(
<<~
SQL
)
CREATE OR REPLACE FUNCTION
#{
DELETED_RECORDS_INSERT_FUNCTION_NAME
}
()
RETURNS TRIGGER AS
$$
BEGIN
INSERT INTO loose_foreign_keys_deleted_records
(fully_qualified_table_name, primary_key_value)
SELECT TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table;
RETURN NULL;
END
$$ LANGUAGE PLPGSQL
SQL
end
def
down
execute
(
<<~
SQL
)
CREATE OR REPLACE FUNCTION
#{
DELETED_RECORDS_INSERT_FUNCTION_NAME
}
()
RETURNS TRIGGER AS
$$
BEGIN
INSERT INTO loose_foreign_keys_deleted_records
(partition, fully_qualified_table_name, primary_key_value)
SELECT 1, TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table
ON CONFLICT DO NOTHING;
RETURN NULL;
END
$$ LANGUAGE PLPGSQL
SQL
end
end
db/schema_migrations/20211118100959
0 → 100644
View file @
991aaee6
8b1bb9758150151518f16307d3f145431000b7edf946fd44e54cf7301087b002
\ No newline at end of file
db/schema_migrations/20211118103439
0 → 100644
View file @
991aaee6
721f1ada9fe5a3d7e5da3750a43d5021a85a26e8adc4d649e7f0fff8cdf68344
\ No newline at end of file
db/structure.sql
View file @
991aaee6
...
...
@@ -27,9 +27,8 @@ CREATE FUNCTION insert_into_loose_foreign_keys_deleted_records() RETURNS trigger
AS $$
BEGIN
INSERT INTO loose_foreign_keys_deleted_records
(partition, fully_qualified_table_name, primary_key_value)
SELECT 1, TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table
ON CONFLICT DO NOTHING;
(fully_qualified_table_name, primary_key_value)
SELECT TG_TABLE_SCHEMA || '.' || TG_TABLE_NAME, old_table.id FROM old_table;
RETURN NULL;
END
...
...
@@ -1016,7 +1015,7 @@ ALTER TABLE ONLY analytics_cycle_analytics_merge_request_stage_events ATTACH PAR
CREATE TABLE loose_foreign_keys_deleted_records (
id bigint NOT NULL,
partition bigint NOT NULL,
partition bigint
DEFAULT 1
NOT NULL,
primary_key_value bigint NOT NULL,
status smallint DEFAULT 1 NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
...
...
@@ -1037,7 +1036,7 @@ ALTER SEQUENCE loose_foreign_keys_deleted_records_id_seq OWNED BY loose_foreign_
CREATE TABLE gitlab_partitions_static.loose_foreign_keys_deleted_records_1 (
id bigint DEFAULT nextval('loose_foreign_keys_deleted_records_id_seq'::regclass) NOT NULL,
partition bigint NOT NULL,
partition bigint
DEFAULT 1
NOT NULL,
primary_key_value bigint NOT NULL,
status smallint DEFAULT 1 NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment