Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【windows】open database crash #720

Open
baneyue opened this issue Oct 29, 2021 · 6 comments
Open

【windows】open database crash #720

baneyue opened this issue Oct 29, 2021 · 6 comments

Comments

@baneyue
Copy link

baneyue commented Oct 29, 2021

The following error occurs occasionally when opening dB on windows. However, it can be accessed by changing the external SQLite tool of DB

══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞══════════════════════
The following _CastError was thrown:
type 'Null' is not a subtype of type 'String' in type cast

When the exception was thrown, this was the stack:
#0 SqfliteIsolate.handle (package:sqflite_common_ffi/src/isolate.dart:41:33)

#1 FfiMethodCallHandler._isolateHandle (package:sqflite_common_ffi/src/database_factory_ffi.dart:95:12)

#2 FfiMethodCallHandler.handleInIsolate (package:sqflite_common_ffi/src/database_factory_ffi.dart:51:20)

#3 _SqfliteDatabaseFactoryImpl.invokeMethod (package:sqflite_common/src/mixin/factory.dart:20:8)

#4 SqfliteDatabaseMixin.openDatabase (package:sqflite_common/src/database_mixin.dart:556:9)

#5 SqfliteDatabaseMixin.doOpen (package:sqflite_common/src/database_mixin.dart:649:22)

#6 SqfliteDatabaseOpenHelper.openDatabase (package:sqflite_common/src/database.dart:44:7)

#7 SqfliteDatabaseFactoryMixin.openDatabase. (package:sqflite_common/src/factory_mixin.dart:111:18)

#8 ReentrantLock.synchronized. (package:synchronized/src/reentrant_lock.dart:37:18)

#9 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)

#10 queryAllUser_labelid (package:wxwork_helper/demo/MainViewPage/Tool/MessageQueryDBTool.dart:247:19)

═════════════════════════════════════════════════════════════════

image

@alextekartik
Copy link
Contributor

Thanks for the report. I you can manage to show the message where it fails (and the sql statement executed); it would help a a lot in reproducing on my side

@baneyue
Copy link
Author

baneyue commented Nov 2, 2021

only when open database。the database is exists and can open with other sqlite db tools.

image
image

@baneyue
Copy link
Author

baneyue commented Nov 9, 2021

@alextekartik Is there any progress on this issue

@alextekartik
Copy link
Contributor

alextekartik commented Nov 9, 2021

I could not manage to reproduce. What could help to try on your side:

  • Add some print before to see your path. Build your path (absolute? or relative?) using join only and not a mix of join and \\:
  // instead of var path = join(WechatDbPathString + currentUserModel.vid + '\\', 'user.db');
  var path = join(WechatDbPathString + currentUserModel.vid, 'user.db');
  // instead of  join(DatasavePathString + `\\`, id);
  var path = join(DatasavePathString, id);
  // print for debugging
  print('opening $path');
  • You might try to use path_provider for setting the default location of your database.
  • Check the database (PRAGMA integrity_check) using desktop tools (https://sqliteviewer.com/blog/database-disk-image-malformed)
  • Or good if you can share your database so I can try to open it in a unit test.
  • You can add extra logs from sqflite itself to see if more info get printed that help analyzing the issue.
  • If you can debug the crash, good if you code see the content of the error map in your first picture (error is Map). It seems to be a map without some expected keys), maybe its content will help.
  • Try to use flutter_lints. You are missing some await (setDatabasesPath) and here the content of the path is important to see (it should be absolute).
  • Ah also in your report, good if you can copy the code and paste between triple-ticks instead of pasting images. It is easier to make comment on code.

@baneyue
Copy link
Author

baneyue commented Nov 9, 2021

thanks a lot ,

@baneyue
Copy link
Author

baneyue commented Nov 19, 2021

We have found the cause of this problem because. Wal. SHM and. DB files are out of sync. Our usage scenario will dynamically replace dB. However, the two runtime intermediate files. Wal and. SHM are not replaced synchronously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants