<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/gitlab/gitlab-ce.git/db, branch background-migrations</title>
<subtitle>gitlab.com: gitlab-org/gitlab-ce.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/gitlab/gitlab-ce.git/'/>
<entry>
<title>Support for post deployment migrations</title>
<updated>2016-10-31T11:54:48+00:00</updated>
<author>
<name>Yorick Peterse</name>
<email>yorickpeterse@gmail.com</email>
</author>
<published>2016-10-27T12:36:53+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/gitlab/gitlab-ce.git/commit/?id=83c8241160ed48ab066e2c5bd58d0914a745197c'/>
<id>83c8241160ed48ab066e2c5bd58d0914a745197c</id>
<content type='text'>
These are regular Rails migrations that are executed by default. A user
can opt-out of these migrations by setting an environment variable
during the deployment process.

Fixes gitlab-org/gitlab-ce#22133
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These are regular Rails migrations that are executed by default. A user
can opt-out of these migrations by setting an environment variable
during the deployment process.

Fixes gitlab-org/gitlab-ce#22133
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'use-optimistic-locking' into 'master'</title>
<updated>2016-10-28T14:41:24+00:00</updated>
<author>
<name>Stan Hu</name>
<email>stanhu@gmail.com</email>
</author>
<published>2016-10-28T14:41:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/gitlab/gitlab-ce.git/commit/?id=d306b0d7c2c1f9384382c2a90a9d7c43bd20573c'/>
<id>d306b0d7c2c1f9384382c2a90a9d7c43bd20573c</id>
<content type='text'>

Use optimistic locking

## What does this MR do?
Removes the usage of pessimistic locking in favor of optimistic which is way cheaper and doesn't block database operation.

Since this is very simple change it should be safe. If we receive `StaleObjectError` message we will reload object a retry operations in lock.

However, I still believe that we need this one: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7005 as this will reduce a load on Database and FS.
This changes a behavior from:

### Pesimistic locking (previous behavior)

#### For updating
1. SELECT * FOR UPDATE (other updates wait on this)
2. we update ci_pipeline
3. latest_build_status
4. enqueue: (use: transition :created -&gt; :pending)
5. [state_machine] we are in  state created, we can go to pending
6. [state_machine] ci_pipeline.status = created
7. [state_machine] ci_pipeline.save
8. [state_machine] after_transition: (if for success): PipelineSuccessWorker on Sidekiq
9. release DB lock

#### If no update is required
1. SELECT * FOR UPDATE (other updates wait on this)
2. we update ci_pipeline
3. latest_build_status
4. we are in pending, we can't transition to pending, because it's forbidden
5. release DB lock

### Optimistic locking (implemented by this MR)

#### For updating
1. latest_build_status
2. enqueue: (use `transition :created -&gt; :pending`)
3. [state_machine] we are in state created, we can go to pending
4. [state_machine] ci_pipeline.status = created
5. [state_machine] ci_pipeline.save
6. [state_machine] [save] where(lock_version: ci_pipeline.lock_version).update_all(status: :created, updated_at: Time.now)
7. [state_machine] [save] unless we_updated_row then raise ObjectInconsistentError

#### If no update is required
1. we update ci_pipeline
2. latest_build_status
3. we are in pending, we can't transition to pending, because it's forbidden

## Why was this MR needed?
We have been seeing a number of problems when we migrated Pipeline/Build processing to Sidekiq. Especially we started seeing a lot of blocking queries.

We used a pessimistic locking which doesn't seem to be required. This effectively allows us to fix our issues with blocked queries by using more efficient method of operation.

## What are the relevant issue numbers?
Issues: https://gitlab.com/gitlab-com/infrastructure/issues/623 and https://gitlab.com/gitlab-com/infrastructure/issues/584, but also there's a bunch of Merge Requests that try to improve behavior of scheduled jobs.

cc @pcarranza @yorickpeterse @stanhu

See merge request !7040</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>

Use optimistic locking

## What does this MR do?
Removes the usage of pessimistic locking in favor of optimistic which is way cheaper and doesn't block database operation.

Since this is very simple change it should be safe. If we receive `StaleObjectError` message we will reload object a retry operations in lock.

However, I still believe that we need this one: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7005 as this will reduce a load on Database and FS.
This changes a behavior from:

### Pesimistic locking (previous behavior)

#### For updating
1. SELECT * FOR UPDATE (other updates wait on this)
2. we update ci_pipeline
3. latest_build_status
4. enqueue: (use: transition :created -&gt; :pending)
5. [state_machine] we are in  state created, we can go to pending
6. [state_machine] ci_pipeline.status = created
7. [state_machine] ci_pipeline.save
8. [state_machine] after_transition: (if for success): PipelineSuccessWorker on Sidekiq
9. release DB lock

#### If no update is required
1. SELECT * FOR UPDATE (other updates wait on this)
2. we update ci_pipeline
3. latest_build_status
4. we are in pending, we can't transition to pending, because it's forbidden
5. release DB lock

### Optimistic locking (implemented by this MR)

#### For updating
1. latest_build_status
2. enqueue: (use `transition :created -&gt; :pending`)
3. [state_machine] we are in state created, we can go to pending
4. [state_machine] ci_pipeline.status = created
5. [state_machine] ci_pipeline.save
6. [state_machine] [save] where(lock_version: ci_pipeline.lock_version).update_all(status: :created, updated_at: Time.now)
7. [state_machine] [save] unless we_updated_row then raise ObjectInconsistentError

#### If no update is required
1. we update ci_pipeline
2. latest_build_status
3. we are in pending, we can't transition to pending, because it's forbidden

## Why was this MR needed?
We have been seeing a number of problems when we migrated Pipeline/Build processing to Sidekiq. Especially we started seeing a lot of blocking queries.

We used a pessimistic locking which doesn't seem to be required. This effectively allows us to fix our issues with blocked queries by using more efficient method of operation.

## What are the relevant issue numbers?
Issues: https://gitlab.com/gitlab-com/infrastructure/issues/623 and https://gitlab.com/gitlab-com/infrastructure/issues/584, but also there's a bunch of Merge Requests that try to improve behavior of scheduled jobs.

cc @pcarranza @yorickpeterse @stanhu

See merge request !7040</pre>
</div>
</content>
</entry>
<entry>
<title>Finish updates to use JIRA gem</title>
<updated>2016-10-26T17:02:16+00:00</updated>
<author>
<name>Felipe Artur</name>
<email>felipefac@gmail.com</email>
</author>
<published>2016-09-29T21:11:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/gitlab/gitlab-ce.git/commit/?id=c2d6822e942f86422348fe4ebea7142822e5882c'/>
<id>c2d6822e942f86422348fe4ebea7142822e5882c</id>
<content type='text'>
Code improvements, bug fixes, finish documentation and specs
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Code improvements, bug fixes, finish documentation and specs
</pre>
</div>
</content>
</entry>
<entry>
<title>Refactor JIRA service to use gem</title>
<updated>2016-10-26T17:02:16+00:00</updated>
<author>
<name>Drew Blessing</name>
<email>drew@gitlab.com</email>
</author>
<published>2016-01-14T14:20:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/gitlab/gitlab-ce.git/commit/?id=f4bc18d237413ac55e32ce16a23b3d2ab35a6976'/>
<id>f4bc18d237413ac55e32ce16a23b3d2ab35a6976</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Use optimistic locking</title>
<updated>2016-10-26T09:37:23+00:00</updated>
<author>
<name>Kamil Trzcinski</name>
<email>ayufan@ayufan.eu</email>
</author>
<published>2016-10-20T07:33:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/gitlab/gitlab-ce.git/commit/?id=5d7ee7a1b6c818dd0ccba6a393875072dabd7eba'/>
<id>5d7ee7a1b6c818dd0ccba6a393875072dabd7eba</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix reply-by-email not working due to queue name mismatch</title>
<updated>2016-10-24T04:35:52+00:00</updated>
<author>
<name>Stan Hu</name>
<email>stanhu@gmail.com</email>
</author>
<published>2016-10-24T04:17:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/gitlab/gitlab-ce.git/commit/?id=59ed1d3cbbf6c89fde202889af798fc189035313'/>
<id>59ed1d3cbbf6c89fde202889af798fc189035313</id>
<content type='text'>
mail_room was configured to deliver mail to the `incoming_email`
queue while `EmailReceiveWorker` was reading the `email_receiver`
queue. Adds a migration that repeats the work of a previous
migration to ensure all mails that wound up in the old
queue get processed.

Closes #23689
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
mail_room was configured to deliver mail to the `incoming_email`
queue while `EmailReceiveWorker` was reading the `email_receiver`
queue. Adds a migration that repeats the work of a previous
migration to ensure all mails that wound up in the old
queue get processed.

Closes #23689
</pre>
</div>
</content>
</entry>
<entry>
<title>Re-organize queues to use for Sidekiq</title>
<updated>2016-10-21T16:17:07+00:00</updated>
<author>
<name>Yorick Peterse</name>
<email>yorickpeterse@gmail.com</email>
</author>
<published>2016-10-21T16:13:41+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/gitlab/gitlab-ce.git/commit/?id=97731760d7252acf8ee94c707c0e107492b1ef24'/>
<id>97731760d7252acf8ee94c707c0e107492b1ef24</id>
<content type='text'>
Dumping too many jobs in the same queue (e.g. the "default" queue) is a
dangerous setup. Jobs that take a long time to process can effectively
block any other work from being performed given there are enough of
these jobs.

Furthermore it becomes harder to monitor the jobs as a single queue
could contain jobs for different workers. In such a setup the only
reliable way of getting counts per job is to iterate over all jobs in a
queue, which is a rather time consuming process.

By using separate queues for various workers we have better control over
throughput, we can add weight to queues, and we can monitor queues
better. Some workers still use the same queue whenever their work is
related. For example, the various CI pipeline workers use the same
"pipeline" queue.

This commit includes a Rails migration that moves Sidekiq jobs from the
old queues to the new ones. This migration also takes care of doing the
inverse if ever needed. This does require downtime as otherwise new jobs
could be scheduled in the old queues after this migration completes.

This commit also includes an RSpec test that blacklists the use of the
"default" queue and ensures cron workers use the "cronjob" queue.

Fixes gitlab-org/gitlab-ce#23370
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Dumping too many jobs in the same queue (e.g. the "default" queue) is a
dangerous setup. Jobs that take a long time to process can effectively
block any other work from being performed given there are enough of
these jobs.

Furthermore it becomes harder to monitor the jobs as a single queue
could contain jobs for different workers. In such a setup the only
reliable way of getting counts per job is to iterate over all jobs in a
queue, which is a rather time consuming process.

By using separate queues for various workers we have better control over
throughput, we can add weight to queues, and we can monitor queues
better. Some workers still use the same queue whenever their work is
related. For example, the various CI pipeline workers use the same
"pipeline" queue.

This commit includes a Rails migration that moves Sidekiq jobs from the
old queues to the new ones. This migration also takes care of doing the
inverse if ever needed. This does require downtime as otherwise new jobs
could be scheduled in the old queues after this migration completes.

This commit also includes an RSpec test that blacklists the use of the
"default" queue and ensures cron workers use the "cronjob" queue.

Fixes gitlab-org/gitlab-ce#23370
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'fix_project_member_access_levels' into 'master'</title>
<updated>2016-10-21T12:51:44+00:00</updated>
<author>
<name>Sean McGivern</name>
<email>sean@mcgivern.me.uk</email>
</author>
<published>2016-10-21T12:51:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/gitlab/gitlab-ce.git/commit/?id=6c09fbd889a2259f8e2db1927c4e0a3d4cdb01b4'/>
<id>6c09fbd889a2259f8e2db1927c4e0a3d4cdb01b4</id>
<content type='text'>

Fix project member access levels

Migrate invalid project members (owner -&gt; master)

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/18616

See merge request !6957</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>

Fix project member access levels

Migrate invalid project members (owner -&gt; master)

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/18616

See merge request !6957</pre>
</div>
</content>
</entry>
<entry>
<title>Fix broken label uniqueness label migration</title>
<updated>2016-10-21T10:45:10+00:00</updated>
<author>
<name>Stan Hu</name>
<email>stanhu@gmail.com</email>
</author>
<published>2016-10-21T04:43:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/gitlab/gitlab-ce.git/commit/?id=b332931af375a29fa0ff41d45315400beca44c7a'/>
<id>b332931af375a29fa0ff41d45315400beca44c7a</id>
<content type='text'>
The previous implementation of the migration failed on staging because
the migration was attempted to remove labels from projects that did not
actually have duplicates. This occurred because the SQL query did not
account for the project ID when selecting the labels.

To replicate the problem:

1. Disable the uniqueness validation in app/models/label.rb.
2. Create a duplicate label "bug" in project A.
3. Create the same label in project B with label "bug".

The migration will attempt to remove the label in B even if there are no duplicates.

Closes #23609
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The previous implementation of the migration failed on staging because
the migration was attempted to remove labels from projects that did not
actually have duplicates. This occurred because the SQL query did not
account for the project ID when selecting the labels.

To replicate the problem:

1. Disable the uniqueness validation in app/models/label.rb.
2. Create a duplicate label "bug" in project A.
3. Create the same label in project B with label "bug".

The migration will attempt to remove the label in B even if there are no duplicates.

Closes #23609
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix project member access levels</title>
<updated>2016-10-21T09:57:53+00:00</updated>
<author>
<name>Valery Sizov</name>
<email>valery@gitlab.com</email>
</author>
<published>2016-10-18T13:49:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/gitlab/gitlab-ce.git/commit/?id=168197cd5a179c961301225626ac1a175f892782'/>
<id>168197cd5a179c961301225626ac1a175f892782</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
