System details: Apache 2.2, Tomcat 6.0.20, Solr 1.4.0 (final), Windows Server 2003 SP2
Indexing stopped working on my site yesterday (more details on this below). New nodes are not added, but existing search works. When I attempt to re-index the site to see if that will fix the issue, I get the following error:
user warning: Column 'changed' cannot be null query: INSERT INTO apachesolr_search_node (nid, status, changed) SELECT n.nid, n.status, GREATEST(n.created, n.changed, c.last_comment_timestamp) AS changed FROM node n LEFT JOIN node_comment_statistics c ON n.nid = c.nid in
\htdocs\sites\all\modules\apachesolr\apachesolr.module on line 281.
I upgraded to 6.x-1.0-rc3 and Apache Solr 1.4.0 final release to see if that would fix the issue. The most frustrating thing is that I copied my entire Drupal site and Solr data to an xampp instance, and the problem vanishes.
The MySQL apachesolr_search_node table is emptied as the first query in the apachesolr.module apachesolr_rebuild_index_table function commands, but the insert fails.
But this may just be a symptom of a larger issue, as I indicated that I started all of this when new nodes ceased indexing.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | apachesolr-650534-1-D5.patch | 2.63 KB | claudiu.cristea |
| #12 | apachesolr_650534-12.patch | 2.22 KB | pwolanin |
| #7 | apachesolr_650534-7.patch | 1.43 KB | Scott Reynolds |
| #4 | apachesolr_ifnull_v1.patch | 725 bytes | dogbertdp |
Comments
Comment #1
dogbertdp commentedCorrection: Indexing of new nodes is working, it's just that some recent nodes are missing. I'm still unable to re-index the site without the same error occurring.
Comment #2
dogbertdp commentedIf I run the query below on my production MySQL database, which is using InnoDB, I get the error "#1048 - Column 'changed' cannot be null". The same query on my test MySQL database, which is using MyISAM apparently returns an 'empty set'. When I change my test database to Innodb, I get the same error. These are the lines along which I am troubleshooting this issue.
Here is the query:
This has been an issuing in MySQL in years past, but everything I'm finding suggests that all reported bugs related to this condition are resolved. I'm running MySQL 5.1.37, which is only a few months old as of this writing.
Here are the contents of my my.ini (sans comments with the disk paths sanitized):
[client]
port=3306
[mysql]
default-character-set=latin1
[mysqld]
port=3306
bind-address=127.0.0.1
basedir="[path-snip]/mysql/"
datadir="[path-snip]/mysql/Data/"
default-character-set=latin1
default-storage-engine=INNODB
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
max_connections=150
max_user_connections = 150
max_connect_errors = 1000
query_cache_size=16M
table_cache=1024
interactive_timeout = 25
wait_timeout = 1800
tmp_table_size=39M
thread_cache_size=286
join_buffer_size = 2M
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=77M
key_buffer_size=63M
read_buffer_size=64K
read_rnd_buffer_size=256K
sort_buffer_size=3M
innodb_additional_mem_pool_size=2551K
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=1250K
innodb_buffer_pool_size=121M
innodb_log_file_size=61M
innodb_thread_concurrency=8
set-variable = lower_case_table_names=0
Note that I updated the title to reflect my findings.
Any ideas?
Mike Hays
Comment #3
dogbertdp commentedOk, so I'm grokking what is going on here. The bug is deeper than I thought. It has little to do with InnoDB, it just turns out that InnoDB doesn't deal with what is going on as "well" as MyISAM.
The following query:
Always returns NULL for changed on my site, as I don't have comments enabled. So a query for last_comment_timestamp in node_comment_statistics will always return NULL, and as of MySQL 5.0.13 GREATEST will return NULL if anything it evaluates against IS NULL (c.f., http://bugs.mysql.com/bug.php?id=15610).
Since comments aren't required for Drupal, we need to handle this in the re-index code.
Here is my suggestion:
In the above case, if node_comment_statistics changed is NULL, it will be set to zero, which will always evaluate as less than node created or changed.
Thoughts?
Comment #4
dogbertdp commentedThe attached patch makes the changes proposed in #3.
Comment #5
pwolanin commentedsomehow I thought there was already a patch in the queue to fix this bug, but I'm not seeing it immediately. At the least, it's ringing a bell as something reported before.
An alternative is to issue a different query if comment module is not enabled?
Comment #6
Scott Reynolds commentedI would advocate this. Complex queries tend to be fragile and this patch is complex needlessly. We should do a
Comment #7
Scott Reynolds commentedAttach is a patch against 2.x. Relatively untested so please do review.
Comment #8
pwolanin commentedlooks reasonable - comment module populates this column when it's enabled, right?
Comment #9
robertdouglass commentedin a later incarnation we can test on entity type.
Comment #10
dogbertdp commentedVery good. I reverted my changes from #4, applied the patch in #7, and my test site re-indexes as expected. I then enabled the Comment module, confirmed that the 'node_comment_statistics' table last_comment_timestamp column is now populated (it is), and re-indexed the site with no errors.
Looks like a winner to me.
Comment #11
pwolanin commentedpatch applies with offset to 6.x-1.x. I think this is safe to commit.
Comment #12
pwolanin commentedcomitted this to 6.x-1.x
Comment #13
robertdouglass commentedCommitted to 6.2.
Comment #14
spjsche commentedSubscribing....
Comment #15
spjsche commentedI am running Drupal v6.15 and have installed the latest version of Apache Solr 6.x-2.x-dev. I have the comments module disabled and cannot get anything to index, keep getting the user warning below even though there are nodes to index.
Is this the same issue as mentioned above ?
# user warning: Column 'changed' cannot be null query: INSERT INTO apachesolr_search_node (nid, status, changed) SELECT n.nid, n.status, GREATEST(n.created, n.changed, c.last_comment_timestamp) AS changed FROM node n LEFT JOIN node_comment_statistics c ON n.nid = c.nid in ..................\sites\all\modules\apachesolr\apachesolr.module on line 277.
# 0 items successfully processed.
Thanks
Stephen
Comment #16
robertdouglass commented@spjsche will take a look.
Comment #17
claudiu.cristeaCommitted to DRUPAL-5--2, in #317980.
Attached the patch.
Comment #18
jpmckinney commentedSee http://bugs.mysql.com/bug.php?id=15610. If node_comment_statistics has no matching row, c.last_comment_timestamp will be NULL, and GREATEST(NULL, 1) will return NULL. Fixed by running COALESCE(c.last_comment_timestamp, 0).
http://drupal.org/cvs?commit=359076
http://drupal.org/cvs?commit=359078
Comment #19
pwolanin commenteddoes this need to be applied to 6.x-1.x? Let's make sure any cross-branch bugs are fixed in all branches.
Comment #20
jpmckinney commentedFixed in 6-1 and 5-2.
http://drupal.org/cvs?commit=360732
http://drupal.org/cvs?commit=360734