1

Closed

BangoDatabaseStorage Exceptions

description

To reproduce just keep relaunching any Android app with Bango in debug mode from Eclipse (keep on hitting debug button until app crashes). I believe another precondition is to have BangoAgent.onStartSession as the very first (or only thing) the app does, so you could hit race condition in BangoAgent.onStartSession on application launch...
 
Stack Trace........
 
(1)java.lang.NullPointerException
at
com.bango.android.BangoDatabaseStorage.UpdateEventsPosted(BangoDatabaseS
torage.java:704)
at com.bango.android.BangoLogger.PostEvents(BangoLogger.java:251)
at com.bango.android.BangoPoster.run(BangoPoster.java:25)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:132)
at android.os.HandlerThread.run(HandlerThread.java:60)
 
 
(2)java.lang.NullPointerException
at
com.bango.android.BangoDatabaseStorage.DeleteEventsPosted(BangoDatabaseS
torage.java:732)
at com.bango.android.BangoLogger.PostEvents(BangoLogger.java:258)
at com.bango.android.BangoPoster.run(BangoPoster.java:25)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:132)
at android.os.HandlerThread.run(HandlerThread.java:60)
 
 
(3)java.lang.IllegalStateException: database
/data/data/com.BangoApp.mobile.android.tablet/databases/BangoAnalytics.db
(conn# 0) already closed
at
android.database.sqlite.SQLiteDatabase.verifyDbIsOpen(SQLiteDatabase.jav
a:2117)
at android.database.sqlite.SQLiteProgram.bind(SQLiteProgram.java:230)
at
android.database.sqlite.SQLiteProgram.bindLong(SQLiteProgram.java:278)
at
com.bango.android.BangoDatabaseStorage.LogEvent(BangoDatabaseStorage.jav
a:384)
at com.bango.android.BangoLogger.LogEvent(BangoLogger.java:434)
at com.bango.android.BangoLogger.LogInternalError(BangoLogger.java:547)
at
com.bango.android.BangoLogger.LogInternalErrorCritical(BangoLogger.java:
521)
at com.bango.android.BangoAgent.onStartSession(BangoAgent.java:312)
at com.bango.android.BangoAgent.onStartSession(BangoAgent.java:269)
at com.bango.android.BangoAgent.onStartSession(BangoAgent.java:252)
at
com.BangoApp.mobile.android.tablet.analytics.BangoAnalytics.start(BangoAnalyt
ics.java:29)
at
com.BangoApp.mobile.android.tablet.service.BangoAnalyticsService.onHandleInte
nt(BangoAnalyticsService.java:44)
at
android.app.IntentService$ServiceHandler.handleMessage(IntentService.jav
a:59)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:126)
at android.os.HandlerThread.run(HandlerThread.java:60)
 
(4)android.database.sqlite.SQLiteDatabaseLockedException: database is
locked
at android.database.sqlite.SQLiteDatabase.native_setLocale(Native
Method)
at
android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:211
5)
at
android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:
984)
at
android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:
956)
at
android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDataba
se.java:1021)
at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:734)
at
android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:
221)
at
android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenH
elper.java:149)
at
com.bango.android.BangoDatabaseStorage.OpenDatabase(BangoDatabaseStorage
.java:183)
at
com.bango.android.BangoDatabaseStorage.OpenDatabase(BangoDatabaseStorage
.java:149)
at
com.bango.android.BangoDatabaseStorage.LogEvent(BangoDatabaseStorage.jav
a:379)
at com.bango.android.BangoLogger.LogEvent(BangoLogger.java:434)
at com.bango.android.BangoLogger.LogInternalError(BangoLogger.java:547)
at
com.bango.android.BangoLogger.LogInternalErrorCritical(BangoLogger.java:
521)
at com.bango.android.BangoAgent.onStartSession(BangoAgent.java:312)
at com.bango.android.BangoAgent.onStartSession(BangoAgent.java:269)
at com.bango.android.BangoAgent.onStartSession(BangoAgent.java:252)
at
com.BangoApp.mobile.android.tablet.analytics.BangoAnalytics.start(BangoAnalyt
ics.java:29)
at
com.BangoApp.mobile.android.tablet.service.BangoAnalyticsService.onHandleInte
nt(BangoAnalyticsService.java:44)

 
(5)java.lang.NullPointerException
at com.bango.android.BangoLogger.LogEvent(BangoLogger.java:434)
at com.bango.android.BangoLogger.LogInternalError(BangoLogger.java:547)
at
com.bango.android.BangoLogger.LogInternalErrorCritical(BangoLogger.java:
521)
at com.bango.android.BangoAgent.onStartSession(BangoAgent.java:312)
at com.bango.android.BangoAgent.onStartSession(BangoAgent.java:269)
at com.bango.android.BangoAgent.onStartSession(BangoAgent.java:252)
at
com.BangoApp.mobile.android.tablet.analytics.BangoAnalytics.start(BangoAnalyt
ics.java:29)
at
com.BangoApp.mobile.android.tablet.service.BangoAnalyticsService.onHandleInte
nt(BangoAnalyticsService.java:44)
at
android.app.IntentService$ServiceHandler.handleMessage(IntentService.jav
a:59)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:126)
at android.os.HandlerThread.run(HandlerThread.java:60)
Closed Feb 15, 2012 at 1:34 PM by bangoyomi
Issue fixed in V.1.3.0

comments

bangoyomi wrote Dec 2, 2011 at 4:41 PM

This issue is caused when the posting thread created on ending a session is still active when a new session is started. Only one reference to a database is active, so one of the threads is denied access, causing the exceptions above.

There are now two new flags on the SDK, to specify the behaviour you want when exitting the app. The possible options are:
a) Retain the current scenario, where on end session a new thread is generated to post any unposted events. You may still on occasion get the error, but this should be very rare.
b) Post events from the main thread (setPostOnEndSessionAsync(false)). This will cause events to be posted from the main thread. This could however freeze the UI until all events are posted.
c) Post events only on start session (setPostOnEndSession(false)). This will disable the post on exit feature, and events will be posted whenever a new session is started. This allows the app to close normally without freezing the UI, but events will only be posted the next time a session start is logged.

bangoyomi wrote Feb 15, 2012 at 1:34 PM

Version 1.3.0 of the SDK now uses a databas ehelper class that deals with the issues caused by the synchronisation of the database calls.

wrote Feb 15, 2012 at 1:34 PM

wrote Feb 13, 2013 at 9:54 PM

wrote May 16, 2013 at 1:23 AM