Commit Graph

242 Commits

Author SHA1 Message Date
Vasu Nori
b438902369 if db close() fails due to un-closed sql statements, print useful msg
The current error message says "close failed due to unfinalised statements".
This CL fixes that message by incorporating one of the un-closed sql statements
should help developers debug the problem.

Change-Id: I2a24c6ba876caa008507b236052c5f03e8cbb27e
2010-11-29 14:10:46 -08:00
Vasu Nori
00e4017189 Revert "Merge "print certain rows from downloads.db when bugreports are taken""
This reverts commit 34878787f0, reversing
changes made to 5a2755d0c9.
2010-11-29 11:03:23 -08:00
Vasu Nori
624002b0d5 print certain rows from downloads.db when bugreports are taken
when downloads fail/get stuck, we need to look at the database state
for those downloads. and when the users report such problems, it is
a royal pain not to have that info and most users don't seem to bother
sending database dumps because it is a bit of work.

so lets just dump info about downloads that failed or
downloads from GSF (OTAs, for example)

helps debugging. there is STOP ship comment to not dump data once
HC is released.

Change-Id: Id1254982fd82b4c55f1816a2491f00966840f024
2010-11-22 11:59:04 -08:00
Jean-Baptiste Queru
8565a8ebbc resolved conflicts for merge of 1a2344b8 to master
Change-Id: I974f7f388ddc74d661f07fda1e308e7c15e00dfc
2010-11-17 17:31:25 -08:00
Jean-Baptiste Queru
1a2344b8b2 am 09e50cdb: Merge "Reorder lock acquision vs try."
* commit '09e50cdbc62938b178f4c9a66b3cec8a466daaa8':
  Reorder lock acquision vs try.
2010-11-17 17:16:06 -08:00
Jean-Baptiste Queru
09e50cdbc6 Merge "Reorder lock acquision vs try." 2010-11-17 17:03:10 -08:00
Jean-Baptiste Queru
0b92c44f8a am 7ee42771: Merge "resolved conflicts for merge of 8fc378f9 to gingerbread-plus-aosp" into gingerbread-plus-aosp
* commit '7ee427714d4621bd9a0b15364a073aff60ebf20c':
  Added buildQuery and buildUnionSubQuery methods without misleading selectionArgs parameter.
2010-11-17 16:54:39 -08:00
Jean-Baptiste Queru
f4072fcc14 resolved conflicts for merge of 8fc378f9 to gingerbread-plus-aosp
Change-Id: I938c0a66ad4271b33626d6b12406a2f6c6d1b6d8
2010-11-17 16:47:59 -08:00
Brian Muramatsu
46a8851360 Fix NPE in SQLiteDatabase#updateWithOnConflict
Bug 3188586

...to restore old behavior of throwing IllegalArgumentException
when values is null.

Change-Id: Ic2df542b2cdbdb7571080eb7f0fc6a4fe1678446
2010-11-12 14:00:36 -08:00
Jonas Schwertfeger
8402903723 Added buildQuery and buildUnionSubQuery methods without misleading selectionArgs parameter.
The signatures of the existing buildQuery and buildUnionSubQuery methods include a selectionArgs
parameter that is not actually being used in the method implementations.  This parameter leads
to the misconception that SQL paramter substitution is carried out by these methods.  I added
new variants of these methods without that parameter and deprecated the old variants.

Change-Id: I1bf770d5c777649e9aac36d93aa93bd65bbcc2a3
2010-11-12 12:18:37 +01:00
Vasu Nori
8fcda30283 on readonly databases, don't set journal mode and don't allow WAL
nothing should be 'set' on readonly databases
bug:3173033

Change-Id: I1143971f6d06139a7e1ef9e73a92e46342264075
2010-11-08 13:48:45 -08:00
Vasu Nori
b642518e54 fix broken build
Change-Id: If1e5639f48d5155e141bce4bf5deef9de5668c27
2010-11-05 14:47:59 -07:00
Vasu Nori
7301a23fb2 Let cachefull-warning be under SQLiteDebug.DEBUG_SQL_CACHE flag
This warning doesn't really matter much. If a developer wants to
debug the cache usage, it can be done by turning on this flag.
adb bugreport also displays cachestats - which can be used as a debugging tool.

Change-Id: Ied173714d535c271133247ee4768f86d3be359cf
2010-11-05 11:55:57 -07:00
Jean-Baptiste Queru
b079e7d408 am c91e4673: am bbd212d7: Merge "Document per-implementation behaviors of native get* methods"
* commit 'c91e46730d14611fb85cd7b2d3e51dac5ce538a2':
  Document per-implementation behaviors of native get* methods
2010-11-03 10:59:44 -07:00
Jean-Baptiste Queru
ae60b8a132 am 0b5d57ab: am 715f8610: Merge "Clarify documentation of Cursor get* methods."
* commit '0b5d57ab7ea062af4502be5af2d51883d251c0bc':
  Clarify documentation of Cursor get* methods.
2010-11-03 10:59:36 -07:00
Jean-Baptiste Queru
c91e46730d am bbd212d7: Merge "Document per-implementation behaviors of native get* methods"
* commit 'bbd212d77852be155a815a0d2ad1da0df2c0dfe1':
  Document per-implementation behaviors of native get* methods
2010-11-02 14:18:07 -07:00
Jean-Baptiste Queru
0b5d57ab7e am 715f8610: Merge "Clarify documentation of Cursor get* methods."
* commit '715f86107763ee95e7d6558dd8da390a63da63e2':
  Clarify documentation of Cursor get* methods.
2010-11-02 14:18:02 -07:00
Vasu Nori
820e9b6b9c deperecate Cursor requery() and sa, Loader should be used instead
the warning printed currently "do requery on background thread"
is not that useful in processes such as gapps, acore.
to reduce the deluge of bugs assigned to me, I think a simple
deprecation warning is better.

Change-Id: I7a1129ea889f10e72895092a3cdd48cc96d0d1f0
2010-11-02 11:14:38 -07:00
Daniel Trebbien
adf4194458 Document per-implementation behaviors of native get* methods
Change-Id: I5d20d7796b85ce62750dd50dd79e47d76716b24c
2010-11-02 09:35:12 -07:00
Daniel Trebbien
65068b099e Clarify documentation of Cursor get* methods.
Make clear in the Javadoc comments of the `Cursor` get* methods that
implementations thereof can have implementation-defined behavior. In some cases,
these changes actually correct the documentation. For example, in the case of
`getShort` and the `SQLiteCursor` implementation thereof, non-numeric data is
*not* converted to a `short` via Short#valueOf or even in a functionally-
equivalent manner.

Change-Id: Ib2f81811a603680b52fc482eb9c0f3195447566f
2010-11-02 09:24:07 -07:00
Daniel Trebbien
38767b34ba Reorder lock acquision vs try.
In two places involving locking, reordered the code so that the lock
acquisition is performed outside of the `try` block and everything
else that needs to run while the lock is locked *within* the `try`
block.

Change-Id: I3dad2c4bbf60b219fc6db2aa35e2ed296cb39128
2010-11-01 14:13:56 -07:00
Vasu Nori
02fc2b01a3 cleanup some of the STOPSHIP comments
removing a check no longer required.
bug:3143859

Change-Id: I6a2ed242d234a4eb78b116bde81efd31e82fafaf
2010-10-28 14:41:59 -07:00
Vasu Nori
6db925001e Merge "increase sql statement printed in finalier warnings from 100 to 1000" 2010-10-25 12:08:46 -07:00
Vasu Nori
b73cf1cc39 increase sql statement printed in finalier warnings from 100 to 1000
100 for sql statement seems too small for some apps (gmail is one example)

Change-Id: I4d29bffc0da5a854ca650d083b81df8769b35b77
2010-10-25 11:55:56 -07:00
Vasu Nori
74fb2685e2 when printing cache-full warning, print the sql statements in cache
this should help debug developers in idetifying the sql statements
taking up cache slots

Change-Id: Ibc0140c273adc5c8d58ab359d2c4d4ce14b6b63b
2010-10-25 11:50:56 -07:00
Vasu Nori
f0808f810e when printing requery on UI warning, include additional info
this hsould help figure out which module is doing query on UI thread.

Change-Id: If3062a35fa1fb50063b678c3c9311d6b1504fa9b
2010-10-08 14:48:48 -07:00
Vasu Nori
6d970255af STOPSHIP - add illegalStateException to catch potential deadlocks in db
database lock() should not be called from a synchronized methods
in database layer. add code to check.
this will catch potential deadlock situations sooner

Change-Id: I9d913f5e2af304f4d9ad5b2641c3a768c4bc97f9
2010-10-05 10:50:45 -07:00
Brad Fitzpatrick
e0ad63bf1e resolved conflicts for merge of 6718b365 to master
Change-Id: I32762a4a3b00856f6765d50667b667264a385fc6
2010-10-01 13:57:04 -07:00
Brad Fitzpatrick
6718b365bc am 32e60c79: Update StrictMode\'s public API.
Merge commit '32e60c7942eeba920ec5c27b372ec0899fd75a20' into gingerbread-plus-aosp

* commit '32e60c7942eeba920ec5c27b372ec0899fd75a20':
  Update StrictMode's public API.
2010-10-01 13:05:02 -07:00
Brad Fitzpatrick
32e60c7942 Update StrictMode's public API.
This makes it more future-proof and maintainable, not exposing the
internal bitpacking state.

The implementation is unchanged (the policy is still just an int we pass
around).

Also starts to introduce VmPolicy, for things which are process-wide,
not per-thread.  As an initial user, make SQLite's Cursor finalization
leak warnings use StrictMode.

Change-Id: Idedfba4e965716f5089a52036421460b1f383725
2010-10-01 12:54:10 -07:00
Vasu Nori
2467561ac2 SQLiteDatabase: fix inconsistent locking
Synchronized blocks should never call lock() or any operation that
does it. otherwise, bugs like bug:3032897 will occur.
Remove synchronization on all methods in SQLiteStatement
and SQLiteProgram because the caller is supposed to
do the synchronization if the same SQLiteStatement or
SQLiteQuery (which extends SQLiteProgram) object
is used by more than one thread at the same time.
(documentation on SQLiteStatement, SQLiteProgram
mentions this note)

Change-Id: Ifd6ee94d743c38c187e2eb778c57076da7a15073
2010-09-28 13:38:14 -07:00
Vasu Nori
587423afb5 fix this: closing database twice fails with IllegalStateException
Change-Id: Idda35e49d539845099b377872f9a6f0e0caa4626
2010-09-27 18:26:25 -07:00
Vasu Nori
8fef1b7520 reduce synchronization on SQLiteDatabase wherever possible
Change-Id: Ibb8617667752eab45d29b01d332b68c3547bdea8
2010-09-27 14:05:09 -07:00
Vasu Nori
ffe06127f6 remove public API setConnectionPoolSize()
because connection pool size is now settable by modifying config.xml
of the device.

Change-Id: I973cc11d7dc10c8d95ab83e2f691068f6019fa33
2010-09-27 13:30:49 -07:00
Vasu Nori
5a049b0fff temporarily comment out dbstats info code when doing adb bugreport
could this be causing bugs like bug:2990184

Change-Id: I315aaa93c1d71922ad4bc96ba0a14a9261a6f39a
2010-09-24 09:26:43 -07:00
Vasu Nori
b745ec9542 am 173ea091: Merge "DO NOT MERGE - use appropriate names on SQL numbers in \'adb bugreport\'" into gingerbread
Merge commit '173ea0912af296c6e80d14b764046534b316d21f' into gingerbread-plus-aosp

* commit '173ea0912af296c6e80d14b764046534b316d21f':
  DO NOT MERGE - use appropriate names on SQL numbers in 'adb bugreport'
2010-09-21 12:25:39 -07:00
Vasu Nori
9540a8d320 DO NOT MERGE - use appropriate names on SQL numbers in 'adb bugreport'
output now looks like the following
  SQL
                  heap:      551          MEMORY_USED:      551
    PAGECACHE_OVERFLOW:      113          MALLOC_SIZE:       50

 DATABASES
    pgsz   dbsz   Lookaside(b)  Dbname
       1    148           500  contacts2.db
       1      8             0    (attached) presence_db
       1     18            31  :memory:SQL

Change-Id: I8bb65a522fd9478ff2f6a8c27e69f9e6c10aef8a
2010-09-21 12:07:24 -07:00
Vasu Nori
4d76d0b832 STOPSHIP follow up to Change-Id: I392875b62ed270741633f5bffa519932e4a9f985
adding back an object that originally existed (when the bug appeared randomly)

Change-Id: Ie6fef529e7b366aaecaace5d3409f2cdc551c8ae
2010-09-21 11:28:49 -07:00
Vasu Nori
627b331b32 add new param to device config properties: db connection pool size
connection pool = number of database connections opened when the app opens
a database. These pooled connections are used by readers only and they
use the sqlite write-ahead-logging option to increase reader
concurrency.
The size of this connection pool depends on the number of CPUs, RAM etc.
On most single-core devices, this can be set to 1.
But on some multi-core devices with more RAM, pool size can be
more than 1.
On a device with more resources, here are the results of a test (in
coretests/src/android/database/sqlite/SQLiteDatabaseTest.java)
which measures the reader-parallelism achieved for different connection
pool sizes.
connpool-size = 1
  num xacts by writer = 467
  num-reads-in-xact/NOT-in-xact by reader1 = 1358/14542, by reader2 = 1431/14269
connpool-size = 2
  num xacts by writer = 473
  num-reads-in-xact/NOT-in-xact by reader1 = 5703/35227, by reader2 = 6222/35898
connpool-size = 3
  num xacts by writer = 542
  num-reads-in-xact/NOT-in-xact by reader1 = 6531/32329, by reader2 = 6252/32728
connpool-size = 4
  num xacts by writer = 578
  num-reads-in-xact/NOT-in-xact by reader1 = 6009/32701, by reader2 = 5977/32953
connpool-size = 5
  num xacts by writer = 547
  num-reads-in-xact/NOT-in-xact by reader1 = 6554/31186, by reader2 = 5318/31022
connpool-size = 6
  num xacts by writer = 534
  num-reads-in-xact/NOT-in-xact by reader1 = 5317/31463, by reader2 = 5413/31537
connpool-size = 7
  num xacts by writer = 549
  num-reads-in-xact/NOT-in-xact by reader1 = 5396/28004, by reader2 = 5214/28496

seems like connection pool size of 3 is optimal on this device.

Change-Id: I348ff5a31783c31b5e3e5ac78b7c2cea54ef114a
2010-09-21 11:05:39 -07:00
Vasu Nori
4e874edf69 don't compile statement for certain SQL statements
SQL statements such as Create table, Pragma, Begin, Commit, Rollback
etc don't need a compiled statement.

Change-Id: I55f5e4e6cbb41cbe83e592e25ba852fe23e2b39f
2010-09-17 10:15:40 -07:00
Vasu Nori
23221192a0 change error message on cl I392875b62ed270741633f5bffa519932e4a9f985
Change-Id: I9eaf201822a9efd8afbdf5cd0e7ef2f01749b955
2010-09-16 13:59:31 -07:00
Vasu Nori
6728ebfa92 STOPSHIP some debugging code to help find reproducible testcases
sometimes mReferenceCount in SQLiteCloasable.java has some huge number
(a memory address probably)
this causes a database.close() or sqliteStatement.close() to randomly
fail and not release the object. and that usually causes a finalizer
warning or sqlite to return error "dbclose failed due to
unfinalised statements"

Change-Id: I392875b62ed270741633f5bffa519932e4a9f985
2010-09-16 09:57:42 -07:00
Vasu Nori
5e89ae29f0 fix compiled statement bugs, synchronization bugs
1. when LRU cache wants to remove the eldest entry, it may be finalizing
a statement that is still in use
2. a couple of synchronization issues.
3. a bit code refactoring in SQLiteCompiledSql
4. remove a bunch of unsed debug code from SQLiteDatabase

Change-Id: I45454dc2dbadd7d8842ba77dd2b0e9ff138ec6f4
2010-09-15 15:30:24 -07:00
Makoto Onuki
90bf7c7916 Add AbstractCursor.getNotificationUri.
We'll need it for some tests.

Change-Id: I5db9f570d8ff2f58c73654fbe4a6df881894f865
2010-09-15 13:21:51 -07:00
Vasu Nori
071df261ed change TAG value from "Cursor" to "SQLiteCursor"
it is confusing to figure out where the debug messages are coming from.
this TAG value change helps

Change-Id: I3a6f445fbced4a962cc13dbb8dd1d7968f9aec9d
2010-09-14 16:02:02 -07:00
Vasu Nori
b83cb7cda3 revert Change-Id: Ic610a0c38e7bd7c77006a08c7b82fa01957739e5
can't change return type from void to int.

Change-Id: Iec3d95c731f117aca20b29c719cef7bcc6356ac0
2010-09-14 13:36:01 -07:00
Vasu Nori
5402590f1c change return type from void to int on execSQL() methods
1. let execSQL() methods return the number of rows affected by the SQL
staement executed.
2. remove synchronized on 2 public methods. since public API is not
supposed to have synchronized, this was a mistake in previously submitted
CL

Change-Id: Ic610a0c38e7bd7c77006a08c7b82fa01957739e5
2010-09-14 12:14:26 -07:00
Vasu Nori
b729dcc8a9 Revert "caching code retooled to reduce locking + handle SMP"
This reverts commit 992f7d52fa.

Change-Id: Ia5b789d1b2195d6ce43baffe24296c857f9b30f6
2010-09-14 11:55:24 -07:00
Vasu Nori
d31211fd46 sql statement with syntax errors can leave database lock in bad state
bug:2995940
Change-Id: I8571943cb278bbc622b04549478badb56e5f7573
2010-09-13 15:47:49 -07:00
Vasu Nori
992f7d52fa caching code retooled to reduce locking + handle SMP
1. Moved all code related to compiled-sql statement cache to SQLiteCache.java
Removed all caching related code from everywhere else.
2. Moved all code related to compiling a sql statement and caching it to
SQLiteCompiledSql.java. There was some code in SQLiteProgram.java
releated to this. moved it out.
3. Added state to SQLiteCompiledSql. This is to help in debugging.
Change-Id: I63ab0c9c4419e964eb9796d284dd389985763d83
2010-09-13 14:38:24 -07:00