Commit de679fb3 authored by shess@chromium.org's avatar shess@chromium.org

Revert [SQLite] Hack to touch page cache to debug slow connection close.

Original CL http://codereview.chromium.org/7891025 , http://crrev.com/101034

The hypothesis discussed in that CL seems proven out, as the
shutdown-hang crashes mostly moved from sqlite3_close() into
sqlite3_95527().

BUG=95527
TEST=Monitor crash in bug, see if it changes.


Review URL: https://chromiumcodereview.appspot.com/9845034

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137989 0039d316-1c4b-4281-b951-d872f2087c98
parent 8f115af1
...@@ -125,21 +125,6 @@ void Connection::Close() { ...@@ -125,21 +125,6 @@ void Connection::Close() {
ClearCache(); ClearCache();
if (db_) { if (db_) {
// TODO(shess): Some additional code to debug http://crbug.com/95527 .
// If you are reading this due to link errors or something, it can
// be safely removed.
#if defined(HAS_SQLITE3_95527)
unsigned int nTouched = 0;
sqlite3_95527(db_, &nTouched);
// If a VERY large amount of memory was touched, crash. This
// should never happen.
// TODO(shess): Pull this in. It should be page_size * page_cache
// or something like that, 4M or 16M. For now it's just to
// prevent optimization.
CHECK_LT(nTouched, 1000*1000*1000U);
#endif
// TODO(shess): Histogram for failure. // TODO(shess): Histogram for failure.
sqlite3_close(db_); sqlite3_close(db_);
db_ = NULL; db_ = NULL;
......
...@@ -126259,94 +126259,3 @@ SQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule( ...@@ -126259,94 +126259,3 @@ SQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */
/************** End of fts3_icu.c ********************************************/ /************** End of fts3_icu.c ********************************************/
/* Touch the bigs of pCache which will be processed by
** pcache1TruncateUnsafe(), pcache1FreePage(), and pcache1Free()
** during sqlite3_close(). *pnTouched will have the number of bytes
** represented by the pages touched added to it. */
SQLITE_PRIVATE void pcache1VisitUnsafe(PCache1 *pCache,
unsigned int *pnTouched){
unsigned int iHash;
assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
for(iHash=0; iHash<pCache->nHash; iHash++){
PgHdr1 *pp = pCache->apHash[iHash];
PgHdr1 *lp = pp;
unsigned int s = 0;
while (pp) {
/* Crash if a loop is detected. */
/* NOTE(shess): Touches the PgHdr1 structure as a side effect.
** If this check is removed, revise the code to match ordering
** in pcache1TruncateUnsafe(). Yes, I realize this is
** probably reordered to heck and back.
*/
if (lp == pp->pNext) {
int *zero = NULL;
*zero = 42;
}
/* Touch the data area, in case it's on a prior VM page. */
*pnTouched += sqlite3MallocSize(PGHDR1_TO_PAGE(pp));
pp = pp->pNext;
/* Bump the loop-detection pointer forward every time s is an
** even power of 2. */
s++;
if (!(s & (s-1))) {
lp = pp;
}
}
}
}
/* TODO(shess): Debugging code for http://crbug.com/95527 .
** Touch the entire page cache for the given db. The idea is that if
** paging activity is causing the slowdown, the shutdown monitor will
** see things happening here, rather than in sqlite3_close().
*/
int sqlite3_95527(sqlite3 *db, unsigned int *pnTouched){
unsigned int iDb;
/* This code assumes that pcache1 is the pager cache implementation. */
if (sqlite3GlobalConfig.pcache.xTruncate != pcache1Truncate) {
return SQLITE_OK;
}
/* This setup is like sqlite3_close(). */
if( !db ){
return SQLITE_OK;
}
if( !sqlite3SafetyCheckSickOrOk(db) ){
return SQLITE_MISUSE_BKPT;
}
sqlite3_mutex_enter(db->mutex);
/* A sqlite3* connection may refer to multiple underlying database
files. Usually these will be 'main' and 'temp', with 'temp' having
no btree or pager. */
for(iDb=0; iDb<db->nDb; iDb++){
Btree *b;
Pager *p;
PCache1 *pCache;
struct Db *pDb = &db->aDb[iDb];
if (!pDb) continue;
b = pDb->pBt;
if (!b) continue;
p = sqlite3BtreePager(b);
if (!p) continue;
pCache = (PCache1*)p->pPCache->pCache;
if (!pCache) continue;
pcache1EnterMutex(pCache->pGroup);
pcache1VisitUnsafe(pCache, pnTouched);
pcache1LeaveMutex(pCache->pGroup);
}
sqlite3_mutex_leave(db->mutex);
return SQLITE_OK;
}
...@@ -6477,18 +6477,3 @@ struct sqlite3_rtree_geometry { ...@@ -6477,18 +6477,3 @@ struct sqlite3_rtree_geometry {
#endif /* ifndef _SQLITE3RTREE_H_ */ #endif /* ifndef _SQLITE3RTREE_H_ */
#ifdef __cplusplus
extern "C" {
#endif
/* Fault in page cache for db. See http://crbug.com/95527 .
** *pnTouched will accumulate the number of bytes represented by the
** touched pages. */
int sqlite3_95527(sqlite3 *db, unsigned int *pnTouched);
/* Let our code know that it's safe to call the function. */
#define HAS_SQLITE3_95527
#ifdef __cplusplus
} /* end of the 'extern "C"' block */
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment