Index: sql/connection.cc |
diff --git a/sql/connection.cc b/sql/connection.cc |
index 662127c2796d67112ef9ccfff4d42d6a188f6b03..20f0f075cbafb0dd6c09f4afe5f4a021f5522b36 100644 |
--- a/sql/connection.cc |
+++ b/sql/connection.cc |
@@ -512,6 +512,8 @@ void Connection::Preload() { |
// work. There could be two prepared statements, one for cache_size=1 one for |
// cache_size=goal. |
void Connection::ReleaseCacheMemoryIfNeeded(bool implicit_change_performed) { |
+ DCHECK(is_open()); |
+ |
// If memory-mapping is not enabled, the page cache helps performance. |
if (!mmap_enabled_) |
return; |
@@ -1364,8 +1366,10 @@ void Connection::DoRollback() { |
RecordUpdateTime(delta); |
RecordOneEvent(EVENT_ROLLBACK); |
- // The cache may have been accumulating dirty pages for commit. |
- ReleaseCacheMemoryIfNeeded(false); |
+ // The cache may have been accumulating dirty pages for commit. Note that in |
+ // some cases sql::Transaction can fire rollback after a database is closed. |
+ if (is_open()) |
+ ReleaseCacheMemoryIfNeeded(false); |
needs_rollback_ = false; |
} |