Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
b66e8534
Kaydet (Commit)
b66e8534
authored
Mar 22, 2014
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #22308 -- Regression from
0f956085
.
Rewrote the test for #9479 according to the original ticket.
üst
3a97f992
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
16 deletions
+14
-16
tests.py
tests/delete_regress/tests.py
+14
-16
No files found.
tests/delete_regress/tests.py
Dosyayı görüntüle @
b66e8534
...
@@ -15,46 +15,44 @@ from .models import (Book, Award, AwardNote, Person, Child, Toy, PlayedWith,
...
@@ -15,46 +15,44 @@ from .models import (Book, Award, AwardNote, Person, Child, Toy, PlayedWith,
# Can't run this test under SQLite, because you can't
# Can't run this test under SQLite, because you can't
# get two connections to an in-memory database.
# get two connections to an in-memory database.
@skipUnlessDBFeature
(
'test_db_allows_multiple_connections'
)
class
DeleteLockingTest
(
TransactionTestCase
):
class
DeleteLockingTest
(
TransactionTestCase
):
available_apps
=
[
'delete_regress'
]
available_apps
=
[
'delete_regress'
]
def
setUp
(
self
):
def
setUp
(
self
):
transaction
.
set_autocommit
(
False
)
# Create a second connection to the default database
# Create a second connection to the default database
new_connections
=
ConnectionHandler
(
settings
.
DATABASES
)
new_connections
=
ConnectionHandler
(
settings
.
DATABASES
)
self
.
conn2
=
new_connections
[
DEFAULT_DB_ALIAS
]
self
.
conn2
=
new_connections
[
DEFAULT_DB_ALIAS
]
self
.
conn2
.
set_autocommit
(
False
)
self
.
conn2
.
set_autocommit
(
False
)
def
tearDown
(
self
):
def
tearDown
(
self
):
transaction
.
rollback
()
transaction
.
set_autocommit
(
True
)
# Close down the second connection.
# Close down the second connection.
self
.
conn2
.
rollback
()
self
.
conn2
.
rollback
()
self
.
conn2
.
close
()
self
.
conn2
.
close
()
@skipUnlessDBFeature
(
'test_db_allows_multiple_connections'
)
def
test_concurrent_delete
(
self
):
def
test_concurrent_delete
(
self
):
"Deletes on concurrent transactions don't collide and lock the database. Regression for #9479"
"""Concurrent deletes don't collide and lock the database (#9479)."""
# Create some dummy data
with
transaction
.
atomic
():
with
transaction
.
atomic
():
Book
.
objects
.
create
(
id
=
1
,
pagecount
=
100
)
Book
.
objects
.
create
(
id
=
1
,
pagecount
=
100
)
Book
.
objects
.
create
(
id
=
2
,
pagecount
=
200
)
Book
.
objects
.
create
(
id
=
2
,
pagecount
=
200
)
Book
.
objects
.
create
(
id
=
3
,
pagecount
=
300
)
Book
.
objects
.
create
(
id
=
3
,
pagecount
=
300
)
with
transaction
.
atomic
():
# Start a transaction on the main connection.
self
.
assertEqual
(
3
,
Book
.
objects
.
count
())
self
.
assertEqual
(
3
,
Book
.
objects
.
count
())
# Delete something using connection 2
.
# Delete something using another database connection
.
cursor2
=
self
.
conn2
.
cursor
()
with
self
.
conn2
.
cursor
()
as
cursor2
:
cursor2
.
execute
(
'DELETE from delete_regress_book WHERE id=1'
)
cursor2
.
execute
(
"DELETE from delete_regress_book WHERE id = 1"
)
self
.
conn2
.
_
commit
()
self
.
conn2
.
commit
()
# Now perform a queryset delete that covers the object
# In the same transaction on the main connection, perform a
# deleted in connection 2. This causes an infinite loop
# queryset delete that covers the object deleted with the other
# under MySQL InnoDB unless we keep track of already
# connection. This causes an infinite loop under MySQL InnoDB
# deleted objects.
# unless we keep track of already deleted objects.
with
transaction
.
atomic
():
Book
.
objects
.
filter
(
pagecount__lt
=
250
)
.
delete
()
Book
.
objects
.
filter
(
pagecount__lt
=
250
)
.
delete
()
self
.
assertEqual
(
1
,
Book
.
objects
.
count
())
self
.
assertEqual
(
1
,
Book
.
objects
.
count
())
...
...
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