react-native-background-geolocation
react-native-background-geolocation copied to clipboard
[SQLite] Database locked
Your Environment
- Plugin version: 4.0.3
- Platform: Android
- OS version: 8.1 and 11
- Device manufacturer / model: TORQUE G03 (KYOCERA) and Xperia 5 (SONY)
- React Native version (
react-native -v): 0.63.4 - Plugin config
BackgroundGeolocation.ready(
{
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
locationAuthorizationRequest: "Always",
showsBackgroundLocationIndicator: true,
notification: {
title: I18n.t("smartButton.locationTrackingTitle"),
text: I18n.t("smartButton.locationTrackingContent"),
smallIcon: `@drawable/ic_push_notification`,
channelName: I18n.t("notificationChannel.backgroundLocationChannelName"),
},
stopTimeout: 5,
foregroundService: true,
debug: false,
speedJumpFilter: 100,
desiredOdometerAccuracy: 10,
maxRecordsToPersist: 1,
distanceFilter: 50,
elasticityMultiplier: 1.5,
fastestLocationUpdateInterval: 60000,
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true,
url: urlConstant.locationHandler,
logLevel: BackgroundGeolocation.LOG_LEVEL_INFO,
autoSync: true,
headers: {},
httpRootProperty: ".",
locationTemplate: "SOME TEMPLATE",
extras: {
extRefId: this.props.login.loginInfo.userInfo.ext_ref_id,
mobileId: this.props.login.loginInfo.mobile.mobile_id,
dataType: 0, // 0 means from app
},
locationAuthorizationAlert: {
titleWhenNotEnabled: I18n.t(
"smartButton.locationAuthorizationAlertTitleWhenNotEnabled"
),
titleWhenOff: I18n.t(
"smartButton.locationAuthorizationAlertTitleWhenOff"
),
instructions: I18n.t(
"smartButton.locationAuthorizationAlertInstructions"
),
cancelButton: I18n.t(
"smartButton.locationAuthorizationAlertCancelButton"
),
settingsButton: I18n.t(
"smartButton.locationAuthorizationAlertSettingsButton"
),
},
backgroundPermissionRationale: {
title: I18n.t("smartButton.locationBackgroundPermissionRationaleTitle"),
message: I18n.t(
"smartButton.locationBackgroundPermissionRationaleMessage"
),
positiveAction: I18n.t(
"smartButton.locationBackgroundPermissionRationalePositiveAction"
),
negativeAction: I18n.t(
"smartButton.locationBackgroundPermissionRationaleNegativeAction"
),
},
},
(state) => {
console.log(state);
NetInfo.fetch().then((state) => {
if (state.type && "wifi" === state.type) {
BackgroundGeolocation.logger
.uploadLog("https://myUrl.com")
.then((success) => {
BackgroundGeolocation.logger.destroyLog();
})
.catch((error) => {
console.log("[uploadLog] FAILURE:", error);
});
}
});
if (!state.enabled) {
BackgroundGeolocation.start()
.then((state) => {
console.log("[start] success - ", state);
})
.catch((error) => {
console.log("[start] error - ", error);
if (error === "Permission denied") {
BackgroundGeolocation.stop();
}
});
}
},
(error) => {
console.log("ready error", error);
BackgroundGeolocation.stop();
}
);
Expected Behavior
There are no crash happened.
Actual Behavior
Crash happened.
Steps to Reproduce
There are no reproduce steps because this happened in end user devices (Product version). Actually, we discovered this crash from Firebase Crashlytics.
Context
Debug logs
Logs
Fatal Exception: android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5): , while compiling: SELECT * FROM logging_event_exception ORDER BY EVENT_ID ASC
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:890)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:501)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:616)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1392)
at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1239)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1110)
at com.transistorsoft.locationmanager.logger.TSLogReader.getLog(:68)
at com.transistorsoft.locationmanager.logger.a.run(:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Plugin version: 4.0.3 vs 4.4.6 https://github.com/transistorsoft/react-native-background-geolocation/blob/master/CHANGELOG.md
Without a reproduction or knowing it is happening on current code I'm not sure what can be done. If you were looking through issues for your software and a colleague came to you with this report, what would you do?
That said, the stack trace is pretty good, @christocracy may be able to deduce something from that without further context...
One should not be calling .destroyLog(), .getLog() in production code.
The error comes from android-logger.
@mikehardy You're right, without a context or reproduction, it is truly hard to investigate, but that's what we got now. Thanks for your answer.
@christocracy Thanks for your reply, I will discuss to our customers whether logger code is able to be removed in production version. Could you explain why we can't use api log in production code ? Because we use log get from local database and upload to our log server, in case we need to investigate for future problems of end users. Thanks.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.