Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
e2dfd06b
Unverified
Commit
e2dfd06b
authored
7 months ago
by
Chris Truter
Committed by
GitHub
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Gracefully handle ignored errors during sync (#45968)
parent
5e6ca946
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
src/metabase/sync.clj
+23
-4
23 additions, 4 deletions
src/metabase/sync.clj
test/metabase/sync_test.clj
+15
-0
15 additions, 0 deletions
test/metabase/sync_test.clj
with
38 additions
and
4 deletions
src/metabase/sync.clj
+
23
−
4
View file @
e2dfd06b
...
...
@@ -34,6 +34,26 @@
[
:name
:string
]
[
:steps
[
:maybe
[
:sequential
sync-util/StepNameWithMetadata
]]]]]])
(
def
^
:private
phase->fn
{
:metadata
sync-metadata/sync-db-metadata!
:analyze
analyze/analyze-db!
:field-values
field-values/update-field-values!
})
(
defn-
scan-phases
[
scan
]
(
if
(
not=
:full
scan
)
[
:metadata
]
[
:metadata
:analyze
:field-values
]))
(
defn-
do-phase!
[
database
phase
]
(
let
[
f
(
phase->fn
phase
)
result
(
f
database
)]
(
if
(
instance?
Throwable
result
)
;; do nothing if we're configured to just move on.
(
when-not
sync-util/*log-exceptions-and-continue?*
;; but if we didn't expect any suppressed exceptions, rethrow it
(
throw
result
))
(
assoc
result
:name
(
name
phase
)))))
(
mu/defn
sync-database!
:-
SyncDatabaseResults
"Perform all the different sync operations synchronously for `database`.
...
...
@@ -49,10 +69,9 @@
{
:keys
[
scan
]
,
:or
{
scan
:full
}}
:-
[
:maybe
[
:map
[
:scan
{
:optional
true
}
[
:maybe
[
:enum
:schema
:full
]]]]]]
(
sync-util/sync-operation
:sync
database
(
format
"Sync %s"
(
sync-util/name-for-logging
database
))
(
cond->
[(
assoc
(
sync-metadata/sync-db-metadata!
database
)
:name
"metadata"
)]
(
=
scan
:full
)
(
conj
(
assoc
(
analyze/analyze-db!
database
)
:name
"analyze"
)
(
assoc
(
field-values/update-field-values!
database
)
:name
"field-values"
))))))
(
->>
(
scan-phases
scan
)
(
keep
(
partial
do-phase!
database
))
(
doall
)))))
(
mu/defn
sync-table!
"Perform all the different sync operations synchronously for a given `table`. Since often called on a sequence of
...
...
This diff is collapsed.
Click to expand it.
test/metabase/sync_test.clj
+
15
−
0
View file @
e2dfd06b
...
...
@@ -262,6 +262,21 @@
(
is
(
=
(
expected-movie-table
)
movie
))
(
is
(
=
(
expected-studio-table
)
studio
)))))))))
(
driver/register!
::sync-database-error-test
)
(
defmethod
driver/describe-database
::sync-database-error-test
[
_driver
_database
]
(
throw
(
Exception.
"OOPS!"
)))
(
deftest
sync-database!-error-test
(
testing
"Errors in sync-database! should be caught and handled correctly (#45848)"
(
mt/with-temp
[
Database
db
{
:engine
::sync-database-error-test
}]
(
binding
[
sync-util/*log-exceptions-and-continue?*
true
]
(
let
[
results
(
sync/sync-database!
db
)]
(
testing
"Skips the metadata step"
(
is
(
=
[
"analyze"
"field-values"
]
(
map
:name
results
)))))))))
;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;; !! !!
;; !! HEY! Your tests probably don't belong in this namespace! Put them in one appropriate to the specific part of !!
...
...
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