ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.48k stars 2.2k forks source link

Database Error while reviewing (due to mismatched tags in template) #2652

Closed hssm closed 9 years ago

hssm commented 9 years ago

Originally reported on Google Code with ID 1750

What steps will reproduce the problem?
1. Open Ankidroid 
2. Start reviewing
3. Database error pops up ~every 3 cards, crashes app eventually.

What is the expected output? What do you see instead?
Expected: normal review.
Instead:  App crashes, progress lost.  Usually causes an ad-20130429115***.stacktrace
error.  

Does it happen again every time you repeat the steps above? Or did it
happen only one time?
This happens about every three cards, every time I try to review.  I have tried:  database
repair, restore from backup, full synch, uninstall/reinstall app (deleting all data
and decks)...still happens.

What version of AnkiDroid are you using? (Decks list > menu > About > Look
at the title)
2.0.1

On what version of Android? (Home screen > menu > About phone > Android
version)
4.0.4

If it is a crash or "Force close" and you can reproduce it, the following
would help immensely: 1) Install the "SendLog" app, 2) Reproduce the crash,
3) Immediately after, launch SendLog, 4) Attach the resulting file to this
report. That will make the bug much easier to fix.

Please provide any additional information below.

Reported by mehc012 on 2013-04-29 19:04:45


hssm commented 9 years ago
What is the exact message that appears?

I could not find any obvious problem in the log file.

Can you find your reports below?
http://ankidroid-triage.appspot.com/report_crashes?filter_version=2.0.1

Could you please upload your collection.anki2 file here? If it is not secret/sensitive.

Does the same happen with the newest alpha?
code.google.com/p/ankidroid/downloads

Thanks for your feedback!
Nicolas

Reported by nicolas.raoul on 2013-04-30 02:30:29

hssm commented 9 years ago
Seems to be the same problem here, since one or two weeks. Before I havent had any problem
for months, always syncronising three devices.  One is a Xiaomi One mobile phone with
Android 4.2, as well a Yuandao N90FHD tablet running Android 4.1.1., further one Laptop
with Kubuntu 13.04. The last time I didn't update AnkiDroid, using AnkiDroid Version
2.0.1 and Anki 2.0.8 at the moment. A week or two ago it started on my two Android
devices. (Actually Kubuntu got updated that time)

Starting Ankidroid is fine, answering one or sometimes more cards I get this popup:

Database error
An error occured while writing to the collection. This could be related to a corupt
database or to insufficient disc space.
If it happens more often, please try to check the database, repair the collection or
restoring from a backup. Click on Options for that.
Nevertheless, it could be a AnkiDroid bug as well; please report the error that we
can check this.
<Options><Report error><Close>

From check and repair database to purge the programm including all database and then
install>sync I tried all. Sometimes after sending a report I get this:
"Restoring collection if missing", which doesn't stop, even after hours. I have to
kill AnkiDroid after that popup.

The deck is huge, I use it three years. I wouldn't like to publish it here, but I could
upload it for a developper to check.

It works fine in Anki's desktop version, checking database here doesn't show any errors.
Ankiweb works fine as well. I tried as well exporting from Anki and importing on both
Android devices after a purge, the problem stays there.

Besides sending reports from Android is there anything a could do to help finding the
problem?
Cheers,
Marcus

Reported by unsermanninchina on 2013-06-01 08:55:15

hssm commented 9 years ago
sent a log using sendlog to nicolas

Reported by marwell.1980 on 2013-06-01 09:10:09

hssm commented 9 years ago
Sorry, marwell.1980@googlemail.com and unsermanninchina@googlemail.com both is me.
Marcus

Reported by unsermanninchina on 2013-06-01 09:22:16

hssm commented 9 years ago
I first did a full sync from Kubuntu 13.04 Anki 2.0.8 to ankiweb. Than full sync from
ankiweb to Ankidroid on my tablet. Didn't help, still the same message "Database error",
Ankidroid on my mobile and tablet are not usable.

I got another message after downloading the deck:
"Sync Log. no such table: meta (code 1):, while compiling:select dirMod from meta [OK]"

Reported by unsermanninchina on 2013-06-07 07:59:16

hssm commented 9 years ago
I treid 2.1alpha4,bug still remains

Reported by unsermanninchina on 2013-06-07 16:29:54

hssm commented 9 years ago
I have reinstalled the app 3 separate times now, made brand new decks on the computer,
downloaded shared decks from the internet, cleared out space on my phone, etc...no
dice.  Without fail, the program crashes after reviewing only 1 or 2 cards.  When it
does, it doesn't write the change (aka keeps having me review the same card), so perhaps
it's having a major error writing to the database.  

I can no longer use ANY Anki on my phone ever, at any time, with any version of the
program, with any decks.  It just crashes nonstop.  This is a shame, because for a
while I was using it every day.  

Reported by mehc012 on 2013-06-15 22:27:49

hssm commented 9 years ago
Tried it on a different phone...same issue.  Within 2 cards it glitched.  However, I
should note that it's only specific decks.  Of my 4 decks, only 2 glitch out (on all
devices).  One of my others did previously, but I restored it to a backup on the desktop
version, then did a full sync, and it has worked ever since.  Unfortunately, the two
decks that currently cause problems are new decks, and have been glitched ever since
they were made, so I can't back it up.  I've tried exporting the decks without scheduling
data (which was a pain because there were a lot of cards) and then deleting, full sync,
re-import, full sync...no change.  

Both decks have some custom card types (as did the one that glitched previously, but
it did not start glitching until months after it was created).  

I can't think of any more relevant details...I use gesture navigation, but it seems
to have no effect on the glitch.  

Please PLEASE help me figure this out, I'm actually going crazy being unable to review
my cards on the go!!

Reported by mehc012 on 2013-06-15 22:47:59

hssm commented 9 years ago
When it crashes, do you get shown a screen that allows you to submit an error report?
If so, can you please submit the error report, then find it here and post a link:

http://ankidroid-triage.appspot.com/report_crashes/report_crashes?filter_version=2.0.1

Reported by perceptualchaos2 on 2013-06-16 00:46:07

hssm commented 9 years ago
I've submitted at least 30-60 error reports, probably far more.  I have no idea how
to track them down or follow up on them, though.

Reported by mehc012 on 2013-06-16 00:51:21

hssm commented 9 years ago
Please submit a new error report, then click the link in my previous post, find the
one that corresponds to yours, and post a link to it here.

Reported by perceptualchaos2 on 2013-06-16 00:58:57

hssm commented 9 years ago
This is assuming you are using v2.0.1 from the play store.

Reported by perceptualchaos2 on 2013-06-16 00:59:54

hssm commented 9 years ago
http://ankidroid-triage.appspot.com/view_crash?crash_id=4927092
http://ankidroid-triage.appspot.com/view_crash?crash_id=4927091

These ones all link to 'Known Issue Pending Investigation' but often they'll come up
as 'Unknown' bugs too.  There are about 4 more on there from tonight; sometimes multiple
errors will come up at once.  

Interestingly, it has also started having trouble switching decks.  That is to say,
when I try to open up a new deck, it comes up as the one I'm having trouble with until
I exit out to the 'Decks' page and select the new deck a second time.  

Reported by mehc012 on 2013-06-16 06:40:32

hssm commented 9 years ago
Your template is doing something unexpected, which explains why some cards work and
others don't. It's possible the notes that started failing had their template changed
to a bad one. Unexpected behaviour is handled differently in each client, so it's possible
that it appeared to work as you wanted on the desktop but crashes on AnkiDroid.

Of course, AnkiDroid still shouldn't crash in this case. Can you please share a deck
or your collection so we can see your templates? That way we can point out what the
problem is and hopefully also put in a fix to avoid crashing.

Note that this may not be the source of all "Database Error" errors, but it is for
the ones you linked.

Reported by Houssam.Salem.Au on 2013-06-16 08:44:01

hssm commented 9 years ago
Sure thing...sorry for the large size, but you can see why I'd like to avoid re-making
it!

Reported by mehc012 on 2013-06-16 16:58:50


hssm commented 9 years ago
That's the deck I care about...the other important one I 'fixed' a month ago by restoring
to a backup on the desktop and remaking all the new cards, then starting the review
over.  The third one I just don't care about; I'll probably just delete it eventually.
 This deck, though, is for my current class, and I'm adding cards to it at a rate of
~300-500/wk, so it would be nice if it worked again, though I have since started adding
them to a second deck in hopes that THAT one will not have glitches and I will be able
to review at least some of my cards!

Reported by mehc012 on 2013-06-16 17:01:20

hssm commented 9 years ago
The problem in this deck is the card type called "Picture/Name". You have this in your
template:
{{#Picture}}{{#Name}}Which muscle is depicted here? <br> {{Picture}}{{/Picture}}{{/Name}}

Notice how your closing tags at the end are in the wrong order? 
You have:
{{#Picture}}{{#Name}}___{{/Picture}}{{/Name}}

When it should be:
{{#Picture}}{{#Name}}___{{/Name}}{{/Picture}}

So any time a card of this type comes up, the error occurs.

Reported by Houssam.Salem.Au on 2013-06-16 17:37:54

hssm commented 9 years ago
You are the best!  
I'm really sorry for the bother; it didn't occur to me that that kind of error would
cause the issue.  I figured that if there were something wrong with the card, it would
manifest on the desktop as well, but I suppose there's more space on a desktop program
to compensate for user stupidity, haha!

I will look for any similar mistakes in my other decks!

Reported by mehc012 on 2013-06-16 17:54:34

hssm commented 9 years ago
Do you see any major problems with the 'Basic' Card type?  That one is throwing errors
as well.  

Reported by mehc012 on 2013-06-16 17:59:28

hssm commented 9 years ago
This is the error that comes up for the 'Basic' card, even after I change it so that
it is identical to the built in "Basic w/ Optional Reverse" card (aka no typing, no
conditionals except for the "Add Reverse").  

http://ankidroid-triage.appspot.com/view_crash?crash_id=4934095

Reported by mehc012 on 2013-06-16 18:10:48

hssm commented 9 years ago
I have now tried editing the 'Basic' card type down to the simplest possible setup:
 just {{Front}} on the front and the standard {{Frontside}} <hr id=answer> {{Back}}
on the back.  Still throws errors.  I'm not sure what to try from here.

Reported by mehc012 on 2013-06-16 18:16:31

hssm commented 9 years ago
The error in your link is quite descriptive:
Section close tag with mismatched open tag [line=2, expected=Innervation, got=Name]

Are you sure the card you are trying to review is of the Basic note type? It sounds
to me like it's loading something else. You can create a filtered deck to use only
Basic cards with the following search parameters to check: deck:Anatomy note:Basic

Reported by Houssam.Salem.Au on 2013-06-16 18:23:23

hssm commented 9 years ago
It's listed in the Browser (both on the PC and the Android) as a Basic card, I added
it as a Basic card, and the content is not of the sort that I would have ever put in
a different card type.  I'm only having issues with the 'Basic' cards in that one deck,
though...other decks are fine. 

Reported by mehc012 on 2013-06-16 18:31:46

hssm commented 9 years ago
OK, to be fair, I was only having issues with THAT particular card...now that I've suspended
that card, I'm having issues with the one that comes before it, which is of a different
note type.  I guess it's not a template issue this time?  Maybe the whole deck is just
screwed on the phone now?

Reported by mehc012 on 2013-06-16 18:37:32

hssm commented 9 years ago
How are you verifying the note type of the card that is throwing errors? The error is
preventing you from seeing the card, and the order of cards is random by default. The
random order is reshuffled if you make changes (e.g., suspending a card), so the sequence
until you get a faulty card changes.

Reported by Houssam.Salem.Au on 2013-06-16 18:41:15

hssm commented 9 years ago
http://ankidroid-triage.appspot.com/view_crash?crash_id=4927099

It's still coming up with the same error you saw before, only now it's on ANOTHER card
type, neither Basic nor the one with those Fields. 

And 5min ago, before I suspended the card that was throwing this error previously,
the card that's throwing it now worked perfectly every time.  It's like I can't get
past this point in the deck, no matter what.  Maybe it's the card AFTER these in the
queue that's causing the issues, and so it's throwing an error when it tries to move
on?  I'll go check the note type associated with those fields, sorry to waste your
time with all these comments.

Reported by mehc012 on 2013-06-16 18:41:44

hssm commented 9 years ago
Sorry, missed your last comment, but it seems that we came to the same conclusion! 
I always assumed that the error was due to the card that didn't get updated in the
deck (I suppose I assumed that it would first save the information about the card I
just answered and update the 'Due' date, and THEN load a new card...since the 'Due'
date wasn't updated, I assumed the error came in that step).  

At any rate, thank you for showing me how to use the error reports and find what was
throwing them.  I know I over-commented on here and I hope it didn't spam you, but
I found it helpful both for talking it out for myself and because you came up with
the answers wonderfully quickly!  Thank you so much for your help, it seems to be working
fine now!  Even better, I'll be able to follow up on my own error reports and narrow
down the problem myself in the future, which is an invaluable tool and is entirely
due to your help!

Reported by mehc012 on 2013-06-16 18:47:22

hssm commented 9 years ago
No problem, glad your issue is solved.

Indeed, the problem is happening while trying to figure out what the card should look
like by parsing the template, so it only fails when loading a new card. "Database error"
is not an entirely accurate error message in this case, so I can see why it might have
confused you.

Reported by Houssam.Salem.Au on 2013-06-16 18:52:41

hssm commented 9 years ago
Oh, cool...just out of idle curiosity, why does this cause the prior card not to be
updated?

Reported by mehc012 on 2013-06-16 18:59:25

hssm commented 9 years ago
I'm not certain, but my guess is the changes to the database aren't being flushed since
the application terminates abnormally. I think for efficiency reasons it's not done
on every review (but again, I can't say with certainty without looking at the code).

Reported by Houssam.Salem.Au on 2013-06-16 19:11:03

hssm commented 9 years ago
I've made a new issue to catch errors of this type instead of crashing... Merging this
into the new issue since it's more descriptive.

Reported by perceptualchaos2 on 2013-06-17 00:07:26

hssm commented 9 years ago
After reading post #17 I checked the model of my decks and found the problem. One of
the front card definitions in Anki desktop had a doubled end of card {/Card:ZH>D}}".
One in the first row (which shouldn't be there) and one at the end:
{{#Card:ZH>D}}<div class=card>{{Card}}</div>{{/Card:ZH>D}}
[sound:0.ogg]
{{#多音字}}<div class=多音字>多音字!</span></div>{{/多音字}}
<div class=HZ>{{Hanzi}}</div>
{{#Pinyin}}<div class=Read>{{Pinyin}}</div>{{/Pinyin}}<br>
{{#Langzeichen}}<div class=LZ>{{Langzeichen}}</div>{{/Langzeichen}}
{{#BeispielZH}}<div class=BZH>{{BeispielZH}}</div>{{/BeispielZH}}
{{#BeispielZHPinyin}}<div class=BZHP>{{BeispielZHPinyin}}</div>
{{/BeispielZHPinyin}}{{#GrammatikZH}}<div class=GZH>{{GrammatikZH}}</div>
{{/GrammatikZH}}{{#HanziStrichfolgen}}<div class=BZH>{{HanziStrichfolgen}}</div>{{/HanziStrichfolgen}}
{{Sound}}
<div class=EX
{{#Wortart}}<span style="color: #ff0000; text-align: center; ">{{Wortart}}</span> {{/Wortart}}
{{#checked}}<span style="font-size: 30px; color: #00ff00">{{checked}}</span>&#8195{{/checked}}
{{#Names}}<span style="font-size: 30px; color: #aa00ff">{{Names}}</span>{{/Names}}
</div>
{{#MWReading}}<span style="color: #ff1000;font-size: 26px;">量词?</span>{{/MWReading}}{{/Card:ZH>D}}

After changing the first row into 
{{#Card:ZH>D}}<div class=card>{{Card}}</div>
and a full sync up and than on my mobile devices solved the problem! 

For my case that havent been a programs bug but my mistake. Anki Desktop Linux version
2.0.11 didn't show any problem, even with this wrong syntax showing the right version
of front card. Thank you for your hints and help!
Marcus

Reported by unsermanninchina on 2013-06-19 09:54:43

hssm commented 9 years ago
This issue has been fixed in the latest beta. Could someone please install the beta
and confirm that it's functioning as expected? Please post your report in issue 1784.

Beta can be downloaded and installed from below:
https://code.google.com/p/ankidroid/downloads/detail?name=AnkiDroid-2.0.2beta1.apk

If you have questions about installing please read the Wiki article about it:
https://code.google.com/p/ankidroid/wiki/Installation#APK

Reported by perceptualchaos2 on 2013-08-23 04:19:22

hssm commented 9 years ago
A year after the last message in this thread, I started getting the following error
(which has been mentioned before) when syncing AnkiDroid on my phone:
"Sync Log. no such table: meta (code 1):, while compiling:select dirMod from meta [OK]"
However, the sync seems to complete successfully (when verified on another client,
e.g. AnkiWeb or the  desktop client).
Should I worry about this error message?

I think it started appearing after upgrading to 2.2.1 or 2.2.2, and there might have
been a conflict while syncing (possibly due to bad connection), which I chose to resolve
by uploading the local data and overwriting the server data.

Reported by daniel.hershcovich on 2014-08-07 11:24:59

hssm commented 9 years ago
The issue you describe is unrelated to this bug, but it is something that I would like
to get fixed. Your collection is actually syncing normally - the failure is only in
the media sync portion. Please continue the discussion at Issue 2228

Reported by Houssam.Salem.Au on 2014-08-07 15:05:02