drift
drift copied to clipboard
LEHER-48 copy current issue url database exception - no such table: feature_section_v2 (code 1):
#0 wrapDatabaseException (package:sqflite/src/exception_impl.dart:11)
#1 SqfliteDatabaseFactoryImpl.wrapDatabaseException (package:sqflite/src/factory_impl.dart:29)
#2 _SqfliteDatabaseBase&Object&SqfliteDatabaseMixin.safeInvokeMethod (package:sqflite/src/database_mixin.dart:183)
#3 _SqfliteDatabaseBase&Object&SqfliteDatabaseMixin.txnRawInsert. (package:sqflite/src/database_mixin.dart:340)
#4 _SqfliteDatabaseBase&Object&SqfliteDatabaseMixin.txnSynchronized. (package:sqflite/src/database_mixin.dart:290)
#5 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:31)
#6 _SqfliteDatabaseBase&Object&SqfliteDatabaseMixin.txnSynchronized (package:sqflite/src/database_mixin.dart:286)
#7 _SqfliteDatabaseBase&Object&SqfliteDatabaseMixin.txnWriteSynchronized (package:sqflite/src/database_mixin.dart:307)
#8 _SqfliteDatabaseBase&Object&SqfliteDatabaseMixin.txnRawInsert (package:sqflite/src/database_mixin.dart:339)
#9 _SqfliteDatabaseBase&Object&SqfliteDatabaseMixin&SqfliteDatabaseExecutorMixin.rawInsert (package:sqflite/src/database_mixin.dart:44)
#10 __SqfliteDelegate&DatabaseDelegate&_SqfliteExecutor.runInsert (package:moor_flutter/moor_flutter.dart:135)
#11 _DelegatedDatabase&QueryExecutor&_ExecutorWithQueryDelegate.runInsert. (package:moor/src/runtime/executor/helpers/engines.dart:62)
#12 _DelegatedDatabase&QueryExecutor&_ExecutorWithQueryDelegate._synchronized (package:moor/src/runtime/executor/helpers/engines.dart:22)
#13 _DelegatedDatabase&QueryExecutor&_ExecutorWithQueryDelegate.runInsert (package:moor/src/runtime/executor/helpers/engines.dart:60)
#14 InsertStatement.insert. (package:moor/src/runtime/statements/insert.dart:36)
#15 QueryExecutor.doWhenOpened. (package:moor/src/runtime/executor/executor.dart:26)
#16 _rootRunUnary (dart:async/zone.dart:1132)
#17 _CustomZone.runUnary (dart:async/zone.dart:1029)
#18 _FutureListener.handleValue (dart:async/future_impl.dart:126)
#19 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639)
#20 Future._propagateToListeners (dart:async/future_impl.dart:668)
#21 Future._complete (dart:async/future_impl.dart:473)
#22 _SyncCompleter.complete (dart:async/future_impl.dart:51)
#23 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:28)
#24 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:294)
#25 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:0)
#26 _asyncThenWrapperHelper. (dart:async-patch/async_patch.dart:77)
#27 _rootRunUnary (dart:async/zone.dart:1132)
#28 _CustomZone.runUnary (dart:async/zone.dart:1029)
#29 _FutureListener.handleValue (dart:async/future_impl.dart:126)
#30 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639)
#31 Future._propagateToListeners (dart:async/future_impl.dart:668)
#32 Future._complete (dart:async/future_impl.dart:473)
#33 _SyncCompleter.complete (dart:async/future_impl.dart:51)
#34 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:28)
#35 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:294)
#36 DelegatedDatabase.ensureOpen. (package:moor/src/runtime/executor/helpers/engines.dart:0)
#37 _asyncThenWrapperHelper. (dart:async-patch/async_patch.dart:77)
#38 _rootRunUnary (dart:async/zone.dart:1132)
#39 _CustomZone.runUnary (dart:async/zone.dart:1029)
#40 _FutureListener.handleValue (dart:async/future_impl.dart:126)
#41 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639)
#42 Future._propagateToListeners (dart:async/future_impl.dart:668)
#43 Future._addListener. (dart:async/future_impl.dart:348)
#44 _rootRun (dart:async/zone.dart:1124)
#45 _CustomZone.run (dart:async/zone.dart:1021)
#46 _CustomZone.runGuarded (dart:async/zone.dart:923)
#47 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963)
#48 _microtaskLoop (dart:async/schedule_microtask.dart:41)
#49 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
device info
id: O11019 androidId: 030b1464637c03a3 board: oppo6771_17331 bootloader: unknown brand: OPPO device: CPH1819 display: CPH1819EX_11_A.34 fingerprint: OPPO/CPH1819/CPH1819:8.1.0/O11019/1563627118:user/release-keys hardware: mt6771 host: CP-ubuntu-123 isPsychicalDevice: true manufacturer: OPPO model: CPH1819 product: CPH1819 tags: release-keys type: user versionBaseOs: OPPO/CPH1819/CPH1819:8.1.0/O11019/1560505424:user/release-keys versionCodename: REL versionIncremental: 1564584104 versionPreviewSdk: 0 versionRelase: 8.1.0 versionSdk: 27 versionSecurityPatch: 2019-08-05
Application parameters: version: 4.0.28 appName: Leher buildNumber: 258 packageName: com.leher environment: ApplicationProfile.release
I'm afraid I need more information to act on this.
- After you added the
feature_selection_v2table to your database (on@UseMoor), did you write a schema migration for it? This guide explains what to do. (Basically, usem.createTable(yourNewFeaturesTable)). - Are you using the latest moor version? Can you look in your
.packagesfile and report the resolved versions formoorandmoor_flutter? Thanks!
i dont need migration. i created latest db and latest table
and i use moor_flutter: ^1.7.0
This might be related to https://github.com/simolus3/moor/issues/135. Can you make sure that you're using moor: 1.7.2 (maybe use flutter_upgrade).
yes i am using
moor:
dependency: transitive
description:
name: moor
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.2"
moor_flutter:
dependency: "direct main"
description:
name: moor_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
moor_generator:
dependency: "direct dev"
description:
name: moor_generator
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.1"
Thanks for the info. Do you know how often that happens (if you delete your app's data and reinstall the app, does that error occur every time?). Can you try to turn on logStatements on the FlutterQueryExecutor and check whether moor is creating tables at all or if there's something wrong with the feature_selection_v2 table statement?
Sir it was a fresh install. And this happens on a random basis sometimes on upgrade too. After I cleared data everything worked fine. In my table schema there is a warning, please do check the screenshot below. Do you think this might cause any problem?
I'm using multiple DBs. One table in each db. To avoid migration I create a new db and with new schema(I don't need old data).
Some DBs are initiated on app launch which has no problem still now. And some Dbs like feature_section_v2 are initiated on screen launch means when the screen opened for the first time. And feature_section_v2 is not singleton.
Hope this will give you better understanding. And I will post logStatements in sometime.
****
Thanks for the detailed insights! I now have a better idea of what's going on.
please do check the screenshot below. Do you think this might cause any problem?
That shouldn't cause any problems, no. You can remove the warning with
environment:
sdk: '>=2.2.2 <3.0.0'
in your pubspec.
I'm using multiple DBs. One table in each db
I never tested using multiple databases in a project, but that shouldn't cause any errors.
And feature_section_v2 is not singleton.
Now that is a problem! If a database is opened multiple times, where will be problems with migrations, which could cause the feature_selection_v2 to not be written. Is it possible for you to make that database a singleton? Please note that databases don't use any resources until they're actually used, so making it a singleton shouldn't have a performance impact.
but i open database only one time
but i open database only one time
Interesting. But is feature_section_v2 the only table where this happens? If it only happens on databases that are not a singleton, then it looks like this is a problem with those databases. I will try to use a setup similar to the one you described and see if I can reproduce the problem.
To help diagnose this further, can you try to set singleInstance: false on the FlutterQueryExecutor with the feature section table? Does that affect the likelihood of the error?
no, i have one more db which is not singlton, but its working fine yet
One more thing that comes to my mind: Did you re-use a filename somewhere? E.g. is the database with the feature selection table passing the same path to the FlutterQueryExecutor as another database?
I mean if that's the only database that fails, there must be something on that database that is different from the others 🤔
I have a similar problem. At the first initialization on the iOS device, one of the four tables is not created. On an Android device, all tables are created. I am trying to detect this problem.
Uh oh. Can you try enabling the logStatements option on the FlutterQueryExecutor? Does the CREATE TABLE statement for the missing table appear at all? ~~Another shot might be to look at the _$YourDbClass superclass - does it contain the missing table in its allTables getter at the end of the class definition?~~ Edit: Of course it's in there, otherwise it wouldn't work on Android.
Uh oh. Can you try enabling the
logStatementsoption on theFlutterQueryExecutor? Does theCREATE TABLEstatement for the missing table appear at all?
CREATE TABLE statement for the missing table not appear on iOS. :(
Perhaps this is somehow related to the table itself? I will try to check it out soon.
CREATE TABLEstatement for the missing table not appear on iOS. :(
That's super weird, given that the same code works on Android. I assume there are no errors in the console when opening the database for the first time?
If you have multiple tables, can you change the migration override in your database to
@override
MigrationStrategy get migration {
return MigrationStrategy(onCreate: (m) async {
await m.createTable(theTableThatDoesntWork);
});
}
If you now delete and re-install your app, does the table get created in that case? If it doesn't, there's definitely something wrong with the table (I would love to take a look at the table then). If the table does get created, there's probably some async-related bug when moor creates tables.
I assume there are no errors in the console when opening the database for the first time?
At the first initialization, there are absolutely no errors, even when accessing an un-created table. The error No such table occurs only after restarting the application.
If you now delete and re-install your app, does the table get created in that case?
Nothing has changed, but I found a way to fix it. Flutter did not update the code changes on iOS devices. I had to roll back the project to an earlier number to check this. All tables are created.
Changes in project versions were minor, but perhaps this problem appeared after connecting firebase analytics. Similar cases have already been here.
This is a very strange situation, I will try to figure it out.
~~@singlakaran @Holofox Can you also try to apply this version~~? EDIT: Seems like this wasn't a moor bug, I've deleted the branch.
Sir it was a fresh install.
@singlakaran can you check if the phone that triggers the error has data saved in Google Drive? Launch the Google Drive app and then go to Settings > Backup and reset > App data . It could be that Google Drive has saved a previous version of your database.
Sir it was a fresh install.
@singlakaran can you check if the phone that triggers the error has data saved in Google Drive? Launch the Google Drive app and then go to Settings > Backup and reset > App data . It could be that Google Drive has saved a previous version of your database.
i will check and ping you.