okhdar / anymemo

Automatically exported from code.google.com/p/anymemo
GNU General Public License v2.0
0 stars 0 forks source link

Database freezes #158

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Run more than 10-30 flashcards in one session.

What is the expected output? What do you see instead?
After exiting the database we use, it won't refresh progress but will freeze 
and block on "Loading databese" (see attacheched screenschoot), only other 
databases will refresh their progress. Database can be unblocked only when we 
try to enter "Card list" mode. Application will crash, we will be able to use 
database but the last progress will be lost. This bug happens in all versions 
Anymemo above 9.0.1.

What is the AnyMemo version (E.g 8.999.1, 9.0, 9.1.1)?
AnyMemo 9.1 and Anymemo 10.0 Beta 2.

What is your Android phone model?
Samsung Galaxy SIII and Asus Google Nexus 7

What is your Android version?
4.1.2 and 4.2.1

Original issue reported on code.google.com by C80.poc...@gmail.com on 9 Jan 2013 at 6:30

Attachments:

GoogleCodeExporter commented 9 years ago
It means the "niem-pol.txt.db" is somehow corrupt. Could you send me a copy to 
liberty @ anymemo . org (I won't share it) so I can take a look and attempt to 
recover the db content if possible?

Original comment by mrlhwlib...@gmail.com on 9 Jan 2013 at 6:34

GoogleCodeExporter commented 9 years ago
It happens with all databases, not only this one. Databases downloaded from 
anymemo.org freeze too. I mean this databases:
Anymemo.org -> "Languages - German" -> "German - Polish"
Anymemo.org -> "Languages - Polish" -> "Polish - German"

My friend has the same problems with his own databases and databases downloaded 
from anymemo.org, he has Samsung Galaxy S3 too.

Original comment by C80.poc...@gmail.com on 9 Jan 2013 at 6:41

Attachments:

GoogleCodeExporter commented 9 years ago
I downloaded the GermanPol.xml.db and PolishGer.xml.db from anymemo.org. It 
doesn't seems to have any problem. Have you originally learned the db on an 
older device and transfered to a newer device or you have upgraded the device 
from 2.x to 4.x? Android 2.x's Sqlite db has a bug that can cause crash on 4.x. 

You can attach at least one db that has the problem and I can confirm. 

Original comment by mrlhwlib...@gmail.com on 9 Jan 2013 at 6:49

GoogleCodeExporter commented 9 years ago
Databases freeze from the begining. They were used with Anymemo 9.1 from Google 
Play. They freeze, so i downloaded Anymemo 10 beta2, but it freeze too.

My friend did the same way apart, but no luck.

I've sended my databases.

Original comment by C80.poc...@gmail.com on 9 Jan 2013 at 7:00

GoogleCodeExporter commented 9 years ago
Problem is that DB freezes sometimes after 10, sometimes after 30 flashcards. 
My database created from Q&A files freezes always before 20 flashcards, but 
database from Anymemo.org freezes sometimes after 20 ans simetimes after 40 
flashcards.

Once my database freezes after 8 flashcards.

Original comment by C80.poc...@gmail.com on 9 Jan 2013 at 7:09

GoogleCodeExporter commented 9 years ago
It didn't crash on my device (Galaxy nexus Android 4.2.1). I tried learn 50 
cards without crash.

It does look like some locking or memory issue, but I also tried on an 4.1.2 
emulator with only 512M memory, it also works fine.

Maybe I need more assistant from you to determine the problem. You can report 
the crash to Google play if the "Force close" dialog show up. Also you can 
download an app called aLogcat and email me the log after you crash AnyMemo.

Original comment by mrlhwlib...@gmail.com on 9 Jan 2013 at 7:17

GoogleCodeExporter commented 9 years ago
Emmmm. I did find this issue when I tried open and close again and again in 
emulator. There is indeed some issues around. I need further investigate it in 
high priority. Accept the issue.

E/org.liberty.android.fantastischmemo.AMGUIUtility(  540): 
java.sql.SQLException: Getting a writable database from helper 
AnyMemoDBOpenHelper@41069098 failed
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:22)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
com.j256.ormlite.android.AndroidConnectionSource.getReadWriteConnection(AndroidC
onnectionSource.java:65)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
com.j256.ormlite.android.AndroidConnectionSource.getReadOnlyConnection(AndroidCo
nnectionSource.java:51)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
com.j256.ormlite.dao.BaseDaoImpl.queryForId(BaseDaoImpl.java:219)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
org.liberty.android.fantastischmemo.ui.QACardActivity$InitTask.doInBackground(QA
CardActivity.java:438)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
org.liberty.android.fantastischmemo.ui.QACardActivity$InitTask.doInBackground(QA
CardActivity.java:1)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.os.AsyncTask$2.call(AsyncTask.java:287)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
java.lang.Thread.run(Thread.java:856)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540): Caused by: 
android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 
5): , while compiling: PRAGMA journal_mode
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnecti
on.java:882)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:
627)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:31
3)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConne
ction.java:287)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:215)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnecti
onPool.java:463)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:804)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java
:224)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.ja
va:164)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  at 
com.j256.ormlite.android.AndroidConnectionSource.getReadWriteConnection(AndroidC
onnectionSource.java:63)
E/org.liberty.android.fantastischmemo.AMGUIUtility(  540):  ... 10 more

Original comment by mrlhwlib...@gmail.com on 9 Jan 2013 at 7:20

GoogleCodeExporter commented 9 years ago
I'm not sure if this can help. I used errdump and get this:

--------- beginning of /dev/log/main
01-09 09:28:23.855 E/System  (32559): Uncaught exception thrown by finalizer
01-09 09:28:23.860 E/System  (32559): java.io.IOException: close failed: EIO 
(I/O error)
01-09 09:28:23.860 E/System  (32559):   at 
libcore.io.IoUtils.close(IoUtils.java:41)
01-09 09:28:23.860 E/System  (32559):   at 
java.io.FileOutputStream.close(FileOutputStream.java:139)
01-09 09:28:23.860 E/System  (32559):   at 
java.io.FileOutputStream.finalize(FileOutputStream.java:153)
01-09 09:28:23.860 E/System  (32559):   at 
java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:186)
01-09 09:28:23.860 E/System  (32559):   at 
java.lang.Daemons$FinalizerDaemon.run(Daemons.java:169)
01-09 09:28:23.860 E/System  (32559):   at java.lang.Thread.run(Thread.java:856)
01-09 09:28:23.860 E/System  (32559): Caused by: libcore.io.ErrnoException: 
close failed: EIO (I/O error)
01-09 09:28:23.860 E/System  (32559):   at libcore.io.Posix.close(Native Method)
01-09 09:28:23.860 E/System  (32559):   at 
libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
01-09 09:28:23.860 E/System  (32559):   at 
libcore.io.IoUtils.close(IoUtils.java:38)
01-09 09:28:23.860 E/System  (32559):   ... 5 more

Original comment by C80.poc...@gmail.com on 9 Jan 2013 at 8:40

GoogleCodeExporter commented 9 years ago
aLogcat on Nexus 7 (android 4.2.1) gives it:

--------- beginning of /dev/log/main
D/dalvikvm( 2279): GC_CONCURRENT freed 200K, 5% free 8630K/9004K, paused 
4ms+5ms, total 36ms
D/dalvikvm( 2279): GC_FOR_ALLOC freed 843K, 13% free 8109K/9284K, paused 16ms, 
total 16ms
D/dalvikvm( 2279): GC_CONCURRENT freed 128K, 10% free 8383K/9284K, paused 
3ms+10ms, total 39ms
E/SpannableStringBuilder( 2279): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a 
zero length
E/SpannableStringBuilder( 2279): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a 
zero length
E/SpannableStringBuilder( 2279): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a 
zero length
E/SpannableStringBuilder( 2279): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a 
zero length
W/IInputConnectionWrapper( 2279): getExtractedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextBeforeCursor on inactive 
InputConnection
W/IInputConnectionWrapper( 2279): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper( 2279): getExtractedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextBeforeCursor on inactive 
InputConnection
W/IInputConnectionWrapper( 2279): getExtractedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextBeforeCursor on inactive 
InputConnection
W/IInputConnectionWrapper( 2279): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper( 2279): getExtractedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextBeforeCursor on inactive 
InputConnection
W/IInputConnectionWrapper( 2279): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper( 2279): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper( 2279): endBatchEdit on inactive InputConnection
W/IInputConnectionWrapper( 2279): getExtractedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextBeforeCursor on inactive 
InputConnection
W/IInputConnectionWrapper( 2279): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper( 2279): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper( 2279): endBatchEdit on inactive InputConnection
W/IInputConnectionWrapper( 2279): getExtractedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextBeforeCursor on inactive 
InputConnection
W/IInputConnectionWrapper( 2279): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper( 2279): getExtractedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextBeforeCursor on inactive 
InputConnection
W/IInputConnectionWrapper( 2279): getExtractedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextBeforeCursor on inactive 
InputConnection
W/IInputConnectionWrapper( 2279): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 2279): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper( 2279): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper( 2279): endBatchEdit on inactive InputConnection
D/dalvikvm( 2279): GC_CONCURRENT freed 137K, 5% free 8746K/9176K, paused 
3ms+9ms, total 38ms
D/dalvikvm( 2279): WAIT_FOR_CONCURRENT_GC blocked 2ms
D/dalvikvm( 2279): GC_FOR_ALLOC freed 744K, 12% free 8292K/9420K, paused 17ms, 
total 17ms
W/IInputConnectionWrapper( 2279): getTextBeforeCursor on inactive 
InputConnection
D/dalvikvm( 2279): GC_CONCURRENT freed 149K, 9% free 8575K/9400K, paused 
10ms+35ms, total 163ms

Original comment by C80.poc...@gmail.com on 9 Jan 2013 at 9:11

GoogleCodeExporter commented 9 years ago
The log you posted is not helpful. Android logs everything in the logcat. The 
one AnyMemo uses start with "E/org.liberty.android.fantastischmemo".

In any case, the bug is that AnyMemo 10.0 beta will corrupt the db.
Once the db is corrupt, 9.x and 10.x will not be able to open it for a while. 
Rebooting the phone could get the db recovered but the change may not be saved. 
Also next time, it might still get corrupt.

This is a critical bug in AnyMemo 10. I will see how I can fix it. Thank you 
for reporting this bug. Raise to "Critical".

Original comment by mrlhwlib...@gmail.com on 9 Jan 2013 at 9:37

GoogleCodeExporter commented 9 years ago
Found the possible problem.
Android 4.1 introduced a hidden feature that can make the db connection faster.
However, the db close is not synchronized any more and can cause dead lock.
AnyMemo 9.x is using customized SQLite helper to provide compatibility to 
Android 1.6. In AnyMemo 10.x, AnyMemo uses the system's sqlite helper but hit 
the problem of Android 4.1+'s SQLite helper. This very bug cause AnyMemo failed 
on Andorid 4.1+ devices.
I need to see what I can do with that.. Very annoying Android incompatibility 
problem.

Original comment by mrlhwlib...@gmail.com on 9 Jan 2013 at 10:43

GoogleCodeExporter commented 9 years ago
I have the same problem with db, I creaty on my own in my German lessons. You 
already found problem, so fingers crossed for near solution :)

Original comment by radek.re...@gmail.com on 10 Jan 2013 at 7:28

GoogleCodeExporter commented 9 years ago
... forget: Nexus S, stock ROM 4.1.2, only rooted.

Original comment by radek.re...@gmail.com on 10 Jan 2013 at 7:28

GoogleCodeExporter commented 9 years ago
Not quite easy to fix. Attempt several things, but it still has the same 
problem. Need more time to dig out resolution.

Original comment by mrlhwlib...@gmail.com on 10 Jan 2013 at 3:22

GoogleCodeExporter commented 9 years ago

Original comment by mrlhwlib...@gmail.com on 10 Jan 2013 at 3:22

GoogleCodeExporter commented 9 years ago
Googled around for this issue. Seems like it did cause trouble for different 
apps for Android Jelly Bean (4.1.x 4.2.x).
But I don't know how they get resolve it.

I really hate Android change thing silently.

Original comment by mrlhwlib...@gmail.com on 10 Jan 2013 at 7:10

GoogleCodeExporter commented 9 years ago
Some people suggest to use one single db connection across the app.
This is unachievable for AnyMemo since AnyMemo is using multiple db at run time.

If anyone can provide some suggestion, please help. Thanks.

https://github.com/eleybourn/Book-Catalogue/issues/373

https://bugzil.la/791958

Original comment by mrlhwlib...@gmail.com on 10 Jan 2013 at 7:20

GoogleCodeExporter commented 9 years ago
Try to fix the issue by this commit.
http://code.google.com/p/anymemo/source/detail?r=126444f8484300f14c3df8b84e9b5e6
65ab70d9a

The APK should be generated by today's nightly build.
http://anymemo.info/autobuild/

Original comment by mrlhwlib...@gmail.com on 11 Jan 2013 at 2:23

GoogleCodeExporter commented 9 years ago
Well done. Everything works fine. I've learned (on Nexus 7 with Android 4.2.1) 
more than 370 flashcards and databases didn't freeze. 

Original comment by C80.poc...@gmail.com on 12 Jan 2013 at 3:39

GoogleCodeExporter commented 9 years ago
Great! close this bug.  Thank you for your extremely detailed report that helps 
a great deal to fix the problem.

Original comment by mrlhwlib...@gmail.com on 12 Jan 2013 at 6:10