Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
0b5dbadd
Unverified
Commit
0b5dbadd
authored
5 years ago
by
Erik Johnston
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Explode on duplicate delta file names. (#6565)
parent
3d46124a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/6565.misc
+1
-0
1 addition, 0 deletions
changelog.d/6565.misc
synapse/storage/prepare_database.py
+18
-0
18 additions, 0 deletions
synapse/storage/prepare_database.py
with
19 additions
and
0 deletions
changelog.d/6565.misc
0 → 100644
+
1
−
0
View file @
0b5dbadd
Add assertion that schema delta file names are unique.
This diff is collapsed.
Click to expand it.
synapse/storage/prepare_database.py
+
18
−
0
View file @
0b5dbadd
...
@@ -18,6 +18,7 @@ import imp
...
@@ -18,6 +18,7 @@ import imp
import
logging
import
logging
import
os
import
os
import
re
import
re
from
collections
import
Counter
import
attr
import
attr
...
@@ -315,6 +316,9 @@ def _upgrade_existing_database(
...
@@ -315,6 +316,9 @@ def _upgrade_existing_database(
)
)
)
)
# Used to check if we have any duplicate file names
file_name_counter
=
Counter
()
# Now find which directories have anything of interest.
# Now find which directories have anything of interest.
directory_entries
=
[]
directory_entries
=
[]
for
directory
in
directories
:
for
directory
in
directories
:
...
@@ -325,6 +329,9 @@ def _upgrade_existing_database(
...
@@ -325,6 +329,9 @@ def _upgrade_existing_database(
_DirectoryListing
(
file_name
,
os
.
path
.
join
(
directory
,
file_name
))
_DirectoryListing
(
file_name
,
os
.
path
.
join
(
directory
,
file_name
))
for
file_name
in
file_names
for
file_name
in
file_names
)
)
for
file_name
in
file_names
:
file_name_counter
[
file_name
]
+=
1
except
FileNotFoundError
:
except
FileNotFoundError
:
# Data stores can have empty entries for a given version delta.
# Data stores can have empty entries for a given version delta.
pass
pass
...
@@ -333,6 +340,17 @@ def _upgrade_existing_database(
...
@@ -333,6 +340,17 @@ def _upgrade_existing_database(
"
Could not open delta dir for version %d: %s
"
%
(
v
,
directory
)
"
Could not open delta dir for version %d: %s
"
%
(
v
,
directory
)
)
)
duplicates
=
set
(
file_name
for
file_name
,
count
in
file_name_counter
.
items
()
if
count
>
1
)
if
duplicates
:
# We don't support using the same file name in the same delta version.
raise
PrepareDatabaseException
(
"
Found multiple delta files with the same name in v%d: %s
"
,
v
,
duplicates
,
)
# We sort to ensure that we apply the delta files in a consistent
# We sort to ensure that we apply the delta files in a consistent
# order (to avoid bugs caused by inconsistent directory listing order)
# order (to avoid bugs caused by inconsistent directory listing order)
directory_entries
.
sort
()
directory_entries
.
sort
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment