Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
81a4830c
Commit
81a4830c
authored
8 years ago
by
Raphael Collet
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] base: race condition in filestore GC (`ir.attachment`)
parent
806989b7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
odoo/addons/base/ir/ir_attachment.py
+12
-1
12 additions, 1 deletion
odoo/addons/base/ir/ir_attachment.py
with
12 additions
and
1 deletion
odoo/addons/base/ir/ir_attachment.py
+
12
−
1
View file @
81a4830c
...
...
@@ -138,8 +138,17 @@ class IrAttachment(models.Model):
if
self
.
_storage
()
!=
'
file
'
:
return
# prevent all concurrent updates on ir_attachment while collecting!
# Continue in a new transaction. The LOCK statement below must be the
# first one in the current transaction, otherwise the database snapshot
# used by it may not contain the most recent changes made to the table
# ir_attachment! Indeed, if concurrent transactions create attachments,
# the LOCK statement will wait until those concurrent transactions end.
# But this transaction will not see the new attachements if it has done
# other requests before the LOCK (like the method _storage() above).
cr
=
self
.
_cr
cr
.
commit
()
# prevent all concurrent updates on ir_attachment while collecting!
cr
.
execute
(
"
LOCK ir_attachment IN SHARE MODE
"
)
# retrieve the file names from the checklist
...
...
@@ -168,6 +177,8 @@ class IrAttachment(models.Model):
with
tools
.
ignore
(
OSError
):
os
.
unlink
(
filepath
)
# commit to release the lock
cr
.
commit
()
_logger
.
info
(
"
filestore gc %d checked, %d removed
"
,
len
(
checklist
),
removed
)
@api.depends
(
'
store_fname
'
,
'
db_datas
'
)
...
...
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