tudoutiao / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

Error in FullTextTrigger #91

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Steps to reproduce the problem:
1. Download http://iris.kase.kz/swf/error_db.7z  (500K) or
http://iris.kase.kz/swf/error_db.zip (1700K)
2. Execute query "UPDATE news SET readed='Y' WHERE news_id = 184611"
3. You can see exception: "org.h2.jdbc.JdbcSQLException: General error:
java.lang.NullPointerException; SQL statement:..."

H2 version is 1.1.114

Original issue reported on code.google.com by victor.p...@gmail.com on 25 Jun 2009 at 12:54

GoogleCodeExporter commented 8 years ago
See also my issue 84.

Original comment by victor.p...@gmail.com on 25 Jun 2009 at 12:55

GoogleCodeExporter commented 8 years ago
Variable "indexColumns" is NULL in "FullText.hasChanged()" method.

Original comment by victor.p...@gmail.com on 25 Jun 2009 at 12:56

GoogleCodeExporter commented 8 years ago
I think that method FullTextLucene.init() is not executed at all. Why?

Original comment by victor.p...@gmail.com on 25 Jun 2009 at 1:10

GoogleCodeExporter commented 8 years ago
Initial error in "org.apache.lucene.index.IndexModifier".

Original comment by victor.p...@gmail.com on 25 Jun 2009 at 1:27

GoogleCodeExporter commented 8 years ago
Corrupted index :(

Original comment by victor.p...@gmail.com on 25 Jun 2009 at 1:37

GoogleCodeExporter commented 8 years ago
Hi,

Could you try out the latest release (1.1.115)? I believe this problem is 
fixed. See
also http://www.h2database.com/html/changelog.html

Original comment by thomas.t...@gmail.com on 27 Jun 2009 at 9:38

GoogleCodeExporter commented 8 years ago
Version 1.1.115 give the same results.

Original comment by victor.p...@gmail.com on 29 Jun 2009 at 7:42

GoogleCodeExporter commented 8 years ago
It seems that the error appeared due to a Lucene index corruption. 
I don't know cause of this corruption but it is not the first time I have seen 
it.
So what do you think about idea to store Lucene index directly in the H2 
database?
Does it improve the stability of index?

Original comment by victor.p...@gmail.com on 29 Jun 2009 at 8:17

GoogleCodeExporter commented 8 years ago
Hi,

I understand now. Unfortunately H2 throws the 'wrong' exception. It swallows the
Lucene exception, and you only see the NullPointerException. I will change H2 
so the
'right' exception is thrown:

Caused by: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed 
out:
SimpleFSLock@/Users/tmueller/Desktop/error_db/store/write.lock
    at org.apache.lucene.store.Lock.obtain(Lock.java:70)
    at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:598)
    at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:410)

Original comment by thomas.t...@gmail.com on 29 Jun 2009 at 7:12

GoogleCodeExporter commented 8 years ago
Hi,

> So what do you think about idea to store Lucene index directly in the H2 
database?
> Does it improve the stability of index?

I'm not sure if that would really solve the problem. I will add a feature 
request for
it, but I'm afraid I will not have time to implement it myself in the near 
future.

Original comment by thomas.t...@gmail.com on 29 Jun 2009 at 7:16

GoogleCodeExporter commented 8 years ago
> I will change H2 so the 'right' exception is thrown...

OK. It is very good.

Original comment by victor.p...@gmail.com on 30 Jun 2009 at 5:34

GoogleCodeExporter commented 8 years ago
> I'm not sure if that would really solve the problem. I will add a feature 
request
> for it, 

OK.

> but I'm afraid I will not have time to implement it myself in the near future.

No wonder. I will try to make some experiments.

Original comment by victor.p...@gmail.com on 30 Jun 2009 at 5:46

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
If I'm correct, starting from 1.1.114 the fulltext triggers were updated to use 
new
FullText.hasChanged() method to detect if changes really happened in indexed 
columns:

  static boolean hasChanged(Object[] oldRow, Object[] newRow, int[] indexColumns) {
        for (int c : indexColumns) {
            Object o = oldRow[c], n = newRow[c];
            if (!o.equals(n)) {
                return true;
            }
        }
        return false;
    } 

Atleast with my code the .114 and .115 fulltext updates do not work when 
updating
previously NULL valued columns to a new value (null or not). At line 692:

if (!o.equals(n)) {

When o is null, the trigger fails with obvious NPE. The new hasChanged method 
does
not handle null values correctly.

I have not encountered situation where indexColumns array is null - and causing 
NPE.

I hope this can be fixed soon :)

Original comment by ilkka.my...@gmail.com on 30 Jun 2009 at 2:35

GoogleCodeExporter commented 8 years ago
Could this be fixed with following change to FullText.java line 692:

if ( ( o != null && ! o.equals(n) ) || ( o == null && n != null ) ) {

?

Original comment by ilkka.my...@gmail.com on 30 Jun 2009 at 2:39

GoogleCodeExporter commented 8 years ago
Hi,

Thanks a lot! I will change the code to:

if (o == null) {
    if (n != null) {
        return true;
    }
} else if (!o.equals(n)) {
    return true;
}

Regards,
Thomas

Original comment by thomas.t...@gmail.com on 2 Jul 2009 at 8:08

GoogleCodeExporter commented 8 years ago
Issue 93 has been merged into this issue.

Original comment by thomas.t...@gmail.com on 2 Jul 2009 at 8:13

GoogleCodeExporter commented 8 years ago
This bug is fixed with the latest release (1.1.116).
If there is still a problem, please open a new issue.

Original comment by thomas.t...@gmail.com on 18 Jul 2009 at 9:53