Skip to content
Commit 30fb30df authored by Lee Shombert's avatar Lee Shombert
Browse files

Fix SQL crash and tests

Bug: 291766410

This fixes a problem in the prepared statement cache handling.  If a
DDL statement is executed, the cache should be invalidated.  The
existing code evicted all statements from all caches synchronously
with the DDL statement.  This meant that caches in use by other
threads were modified by the thread executing the DDL statement.  This
caused crashes inside sqlite under stress.

The fix uses a sequence number that lets cache uses know if a prepared
statement is stale.  Stale statements are disposed of in the thread
that owns the cache as they are fetched.  Statements that are not
fetched are evicted normally by the LRU cache.

This change appears to be performance-neutral.  The database
performance tests show a +-2% skew with respect to baseline.

The fix solves issues with SQLiteDatabaseTest.testStressDDLEvicts().
That test has been changed to run 5000 iterations instead of 1000, to
provide a more stressful test.

Two other unit tests are fixed:
 * DatabaseGeneralTest.testOpenDatabaseLookasidConfig().  That test
   was broken when the return value of SQLiteDebug.getDatabaseInfo()
   was modified with an extra array entry.
 * DatabaseErrorHandlerTest.testDatabaseIsCorrupt().  The commit that
   broke the test is unknown.

There are no errors in the unit tests below.

Test: atest
 * FrameworksCoreTests:android.database
 * CtsDatabaseTestCases

Change-Id: I117241f33584cf94a1e5ca00d18268f7fbc45c3e
parent 252fbd83
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment