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
d9270f7a
Commit
d9270f7a
authored
Oct 19, 2020
by
Dmitry Gruzd
Committed by
Dylan Griffith
Oct 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ElasticCommitIndexerWorker FK violation
parent
fa79e06f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
ee/changelogs/unreleased/240923-fix-foreign-key-violation.yml
...hangelogs/unreleased/240923-fix-foreign-key-violation.yml
+5
-0
ee/lib/gitlab/elastic/indexer.rb
ee/lib/gitlab/elastic/indexer.rb
+9
-0
ee/spec/lib/gitlab/elastic/indexer_spec.rb
ee/spec/lib/gitlab/elastic/indexer_spec.rb
+19
-0
No files found.
ee/changelogs/unreleased/240923-fix-foreign-key-violation.yml
0 → 100644
View file @
d9270f7a
---
title
:
Fix unnecessary Sidekiq errors/retries when project is deleted during indexing
merge_request
:
45249
author
:
type
:
fixed
ee/lib/gitlab/elastic/indexer.rb
View file @
d9270f7a
...
...
@@ -177,6 +177,15 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def
update_index_status
(
to_sha
)
unless
Project
.
exists?
(
id:
project
.
id
)
Gitlab
::
Elasticsearch
::
Logger
.
build
.
debug
(
message:
'Index status could not be updated as the project does not exist'
,
project_id:
project
.
id
,
wiki:
index_wiki?
)
return
false
end
raise
"Invalid sha
#{
to_sha
}
"
unless
to_sha
.
present?
# An index_status should always be created,
...
...
ee/spec/lib/gitlab/elastic/indexer_spec.rb
View file @
d9270f7a
...
...
@@ -388,6 +388,25 @@ RSpec.describe Gitlab::Elastic::Indexer do
end
end
context
'when project no longer exists in database'
do
let!
(
:logger_double
)
{
instance_double
(
Gitlab
::
Elasticsearch
::
Logger
)
}
before
do
allow
(
Gitlab
::
Elasticsearch
::
Logger
).
to
receive
(
:build
).
and_return
(
logger_double
)
allow
(
indexer
).
to
receive
(
:run_indexer!
)
{
Project
.
where
(
id:
project
.
id
).
delete_all
}
end
it
'does not raises an exception and prints log message'
do
expect
(
logger_double
).
to
receive
(
:debug
).
with
(
message:
'Index status could not be updated as the project does not exist'
,
project_id:
project
.
id
,
wiki:
false
)
expect
(
IndexStatus
).
not_to
receive
(
:safe_find_or_create_by!
).
with
(
project_id:
project
.
id
)
expect
{
indexer
.
run
}.
not_to
raise_error
end
end
def
expect_popen
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
end
...
...
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