Opened 11 years ago

Closed 11 years ago

#21170 closed Bug (needsinfo)

Clearing DatabseCache doesn't work with Oracle backend.

Reported by: mmmnow@… Owned by: nobody
Component: Core (Cache system) Version: 1.6-beta-1
Severity: Normal Keywords:
Cc: Shai Berger Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have one row in my oracle cache table. I'm trying to clear it using standard django way:

from django.core.cache import cache
cache.clear()

But it doesn't work! The row is still in my cache table.

So I run python manage.py sell and put some code from DatabaseCache.clear() method:

from django.db import connections
table = connections['cache'].ops.quote_name('ws_cache_table')
cursor = connections['cache'].cursor()
cursor.execute('DELETE FROM %s' % table)

But it doesn't work either...

I don't get any exceptions thrown, my 'cache' connection is configured correctly in settings.py.

When I open SQL Developer and put

DELETE FROM ws_cache_table

Table gets truncated correctly.

On the other hand, when I add:

connections['cache'].commit()

I get exception django.db.transaction.TransactionManagementError: This code isn't under transaction management thrown but the table is truncated now.

Change History (6)

comment:1 by Anssi Kääriäinen, 11 years ago

Weirdness of old Django transaction management is the reason for the last error. You get exception and the commit both in one call. You can use commit_unless_managed() to just get a commit.

To me it seems that every writing operation should to commit_unless_managed() in 1.5.

1.6 should work automatically - either you are in autocommit mode which means every operation is committed automatically, or you are inside an atomic block in which case the transaction is going to be committed at the end of the block.

comment:2 by anonymous, 11 years ago

OK, so you say this is only a problem for Django < 1.6, correct?

comment:3 by Anssi Kääriäinen, 11 years ago

Yes, I think so. Adding tests might be a good idea so that we could actually verify that this works in 1.6 & master.

comment:4 by Anssi Kääriäinen, 11 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted
Version: 1.51.6-beta-1

Marking as accepted. Only tests should be needed. Lets not worry about fixing this in 1.5.

comment:5 by Shai Berger, 11 years ago

Cc: Shai Berger added

Which tests would these be?

There is a test for clearing the cache in tests/cache/tests.py, it is run also with a DBCache backend, and so is also run with Oracle whenever we run the full test suite -- which, AFAICT, currently passes for Oracle on 1.6 and master.

As far as I understand, there is nothing to solve here for Django>=1.6.

comment:6 by Shai Berger, 11 years ago

Resolution: needsinfo
Status: newclosed

So we're not fixing for pre-1.6; and there seems to be no problem for 1.6 and up.

If anyone sees a problem, or even wants to add a test for 1.6, feel free to reopen.

Note: See TracTickets for help on using tickets.
Back to Top