Commit 07a3f810 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'ag-improve-geo-verification-dev-docs' into 'master'

Add multiple improvements to Geo development docs

See merge request gitlab-org/gitlab!74865
parents 900de4d9 f744779e
...@@ -56,9 +56,7 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org ...@@ -56,9 +56,7 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org
```ruby ```ruby
# frozen_string_literal: true # frozen_string_literal: true
class CreateCoolWidgetRegistry < ActiveRecord::Migration[6.0] class CreateCoolWidgetRegistry < Gitlab::Database::Migration[1.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
def up def up
...@@ -126,9 +124,7 @@ The Geo primary site needs to checksum every replicable so secondaries can verif ...@@ -126,9 +124,7 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
```ruby ```ruby
# frozen_string_literal: true # frozen_string_literal: true
class CreateCoolWidgetStates < ActiveRecord::Migration[6.0] class CreateCoolWidgetStates < Gitlab::Database::Migration[1.0]
include Gitlab::Database::MigrationHelpers
VERIFICATION_STATE_INDEX_NAME = "index_cool_widget_states_on_verification_state" VERIFICATION_STATE_INDEX_NAME = "index_cool_widget_states_on_verification_state"
PENDING_VERIFICATION_INDEX_NAME = "index_cool_widget_states_pending_verification" PENDING_VERIFICATION_INDEX_NAME = "index_cool_widget_states_pending_verification"
FAILED_VERIFICATION_INDEX_NAME = "index_cool_widget_states_failed_verification" FAILED_VERIFICATION_INDEX_NAME = "index_cool_widget_states_failed_verification"
...@@ -137,7 +133,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif ...@@ -137,7 +133,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
disable_ddl_transaction! disable_ddl_transaction!
def up def up
unless table_exists?(:cool_widget_states)
with_lock_retries do with_lock_retries do
create_table :cool_widget_states, id: false do |t| create_table :cool_widget_states, id: false do |t|
t.references :cool_widget, primary_key: true, null: false, foreign_key: { on_delete: :cascade } t.references :cool_widget, primary_key: true, null: false, foreign_key: { on_delete: :cascade }
...@@ -155,7 +150,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif ...@@ -155,7 +150,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
end end
end end
end
add_text_limit :cool_widget_states, :verification_failure, 255 add_text_limit :cool_widget_states, :verification_failure, 255
end end
...@@ -209,6 +203,8 @@ That's all of the required database changes. ...@@ -209,6 +203,8 @@ That's all of the required database changes.
has_one :cool_widget_state, autosave: false, inverse_of: :cool_widget, class_name: 'Geo::CoolWidgetState' has_one :cool_widget_state, autosave: false, inverse_of: :cool_widget, class_name: 'Geo::CoolWidgetState'
after_save :save_verification_details
delegate :verification_retry_at, :verification_retry_at=, delegate :verification_retry_at, :verification_retry_at=,
:verified_at, :verified_at=, :verified_at, :verified_at=,
:verification_checksum, :verification_checksum=, :verification_checksum, :verification_checksum=,
...@@ -223,6 +219,8 @@ That's all of the required database changes. ...@@ -223,6 +219,8 @@ That's all of the required database changes.
scope :checksummed, -> { joins(:cool_widget_state).where.not(cool_widget_states: { verification_checksum: nil } ) } scope :checksummed, -> { joins(:cool_widget_state).where.not(cool_widget_states: { verification_checksum: nil } ) }
scope :not_checksummed, -> { joins(:cool_widget_state).where(cool_widget_states: { verification_checksum: nil } ) } scope :not_checksummed, -> { joins(:cool_widget_state).where(cool_widget_states: { verification_checksum: nil } ) }
scope :available_verifiables, -> { joins(:cool_widget_state) }
# Override the `all` default if not all records can be replicated. For an # Override the `all` default if not all records can be replicated. For an
# example of an existing Model that needs to do this, see # example of an existing Model that needs to do this, see
# `EE::MergeRequestDiff`. # `EE::MergeRequestDiff`.
......
...@@ -58,13 +58,10 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org ...@@ -58,13 +58,10 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org
```ruby ```ruby
# frozen_string_literal: true # frozen_string_literal: true
class CreateCoolWidgetRegistry < ActiveRecord::Migration[6.0] class CreateCoolWidgetRegistry < Gitlab::Database::Migration[1.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
def up def up
unless table_exists?(:cool_widget_registry)
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
create_table :cool_widget_registry, id: :bigserial, force: :cascade do |t| create_table :cool_widget_registry, id: :bigserial, force: :cascade do |t|
t.bigint :cool_widget_id, null: false t.bigint :cool_widget_id, null: false
...@@ -96,7 +93,6 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org ...@@ -96,7 +93,6 @@ Geo secondary sites have a [Geo tracking database](https://gitlab.com/gitlab-org
end end
end end
end end
end
def down def down
drop_table :cool_widget_registry drop_table :cool_widget_registry
...@@ -130,9 +126,7 @@ The Geo primary site needs to checksum every replicable so secondaries can verif ...@@ -130,9 +126,7 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
```ruby ```ruby
# frozen_string_literal: true # frozen_string_literal: true
class CreateCoolWidgetStates < ActiveRecord::Migration[6.0] class CreateCoolWidgetStates < Gitlab::Database::Migration[1.0]
include Gitlab::Database::MigrationHelpers
VERIFICATION_STATE_INDEX_NAME = "index_cool_widget_states_on_verification_state" VERIFICATION_STATE_INDEX_NAME = "index_cool_widget_states_on_verification_state"
PENDING_VERIFICATION_INDEX_NAME = "index_cool_widget_states_pending_verification" PENDING_VERIFICATION_INDEX_NAME = "index_cool_widget_states_pending_verification"
FAILED_VERIFICATION_INDEX_NAME = "index_cool_widget_states_failed_verification" FAILED_VERIFICATION_INDEX_NAME = "index_cool_widget_states_failed_verification"
...@@ -141,7 +135,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif ...@@ -141,7 +135,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
disable_ddl_transaction! disable_ddl_transaction!
def up def up
unless table_exists?(:cool_widget_states)
with_lock_retries do with_lock_retries do
create_table :cool_widget_states, id: false do |t| create_table :cool_widget_states, id: false do |t|
t.references :cool_widget, primary_key: true, null: false, foreign_key: { on_delete: :cascade } t.references :cool_widget, primary_key: true, null: false, foreign_key: { on_delete: :cascade }
...@@ -159,7 +152,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif ...@@ -159,7 +152,6 @@ The Geo primary site needs to checksum every replicable so secondaries can verif
t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME t.index :verification_state, where: "(verification_state = 0 OR verification_state = 3)", name: NEEDS_VERIFICATION_INDEX_NAME
end end
end end
end
add_text_limit :cool_widget_states, :verification_failure, 255 add_text_limit :cool_widget_states, :verification_failure, 255
end end
...@@ -213,6 +205,8 @@ That's all of the required database changes. ...@@ -213,6 +205,8 @@ That's all of the required database changes.
has_one :cool_widget_state, autosave: false, inverse_of: :cool_widget, class_name: 'Geo::CoolWidgetState' has_one :cool_widget_state, autosave: false, inverse_of: :cool_widget, class_name: 'Geo::CoolWidgetState'
after_save :save_verification_details
delegate :verification_retry_at, :verification_retry_at=, delegate :verification_retry_at, :verification_retry_at=,
:verified_at, :verified_at=, :verified_at, :verified_at=,
:verification_checksum, :verification_checksum=, :verification_checksum, :verification_checksum=,
...@@ -227,6 +221,8 @@ That's all of the required database changes. ...@@ -227,6 +221,8 @@ That's all of the required database changes.
scope :checksummed, -> { joins(:cool_widget_state).where.not(cool_widget_states: { verification_checksum: nil } ) } scope :checksummed, -> { joins(:cool_widget_state).where.not(cool_widget_states: { verification_checksum: nil } ) }
scope :not_checksummed, -> { joins(:cool_widget_state).where(cool_widget_states: { verification_checksum: nil } ) } scope :not_checksummed, -> { joins(:cool_widget_state).where(cool_widget_states: { verification_checksum: nil } ) }
scope :available_verifiables, -> { joins(:cool_widget_state) }
# Override the `all` default if not all records can be replicated. For an # Override the `all` default if not all records can be replicated. For an
# example of an existing Model that needs to do this, see # example of an existing Model that needs to do this, see
# `EE::MergeRequestDiff`. # `EE::MergeRequestDiff`.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment