Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor 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
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
d75425f2
Commit
d75425f2
authored
5 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-4577: synchronize append with MySQL to prevent DB dead locks
parent
63050f44
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/properties/PropertyManager.java
+16
-3
16 additions, 3 deletions
src/main/java/org/olat/properties/PropertyManager.java
with
16 additions
and
3 deletions
src/main/java/org/olat/properties/PropertyManager.java
+
16
−
3
View file @
d75425f2
...
...
@@ -32,13 +32,13 @@ import java.util.List;
import
javax.persistence.Query
;
import
javax.persistence.TypedQuery
;
import
org.apache.logging.log4j.Logger
;
import
org.olat.basesecurity.IdentityRef
;
import
org.olat.core.commons.persistence.DBFactory
;
import
org.olat.core.commons.persistence.QueryBuilder
;
import
org.olat.core.id.Identity
;
import
org.olat.core.id.OLATResourceable
;
import
org.olat.core.logging.AssertException
;
import
org.apache.logging.log4j.Logger
;
import
org.olat.core.logging.Tracing
;
import
org.olat.core.util.StringHelper
;
import
org.olat.group.BusinessGroup
;
...
...
@@ -607,6 +607,17 @@ public class PropertyManager implements UserDataDeletable {
public
void
appendTextProperty
(
Identity
identity
,
BusinessGroup
grp
,
OLATResourceable
resourceable
,
String
category
,
String
name
,
String
textValue
)
{
if
(
DBFactory
.
getInstance
().
isMySQL
())
{
synchronized
(
this
)
{
// without produce dead lock in MySQL
executeAppendTextProperty
(
identity
,
grp
,
resourceable
,
category
,
name
,
textValue
);
}
}
else
{
executeAppendTextProperty
(
identity
,
grp
,
resourceable
,
category
,
name
,
textValue
);
}
}
private
void
executeAppendTextProperty
(
Identity
identity
,
BusinessGroup
grp
,
OLATResourceable
resourceable
,
String
category
,
String
name
,
String
textValue
)
{
QueryBuilder
sb
=
new
QueryBuilder
();
sb
.
append
(
"update "
).
append
(
Property
.
class
.
getName
()).
append
(
" v "
)
.
append
(
" set v.textValue=concat(v.textValue,:text), lastModified=:now"
);
...
...
@@ -637,12 +648,14 @@ public class PropertyManager implements UserDataDeletable {
query
.
setParameter
(
"groupKey"
,
grp
.
getKey
());
}
int
row
=
query
.
executeUpdate
();
int
row
=
query
.
executeUpdate
();
DBFactory
.
getInstance
().
commit
();
if
(
row
==
0
)
{
Property
prop
=
createPropertyInstance
(
identity
,
grp
,
resourceable
,
category
,
name
,
null
,
null
,
null
,
textValue
);
saveProperty
(
prop
);
DBFactory
.
getInstance
().
commit
();
}
DBFactory
.
getInstance
().
commit
();
}
/**
...
...
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