views:

111

answers:

1

Hi,

Can someone explain to me the inner workings of acts_as_xapian_jobs table?

I ran into an issue with the acts_as_xapian plugin recently, where I kept getting the following error when it creates an object with xapian indexed fields:

Mysql::Error: Duplicate entry 'String-2147483647' for key 2: 
INSERT INTO `acts_as_xapian_jobs` (`action`, `model`, `model_id`) 
VALUES ('update', 'String', 23730251831560)

It turns out the model_id exceeded the max int value of 2147483647. The workaround was to update model_id to use bigint. Why would the model_id be so huge? By looking at content of acts_as_xapian_jobs, it seems it creates a row for every field that is being indexed.. Understanding how a job gets created in the table would help a great deal.

Here's a sampling of the table:

mysql> select * from acts_as_xapian_jobs limit 5\G
*************************** 1. row ***************************
      id: 19
   model: String
model_id: 23804037900560
  action: update
*************************** 2. row ***************************
      id: 49
   model: String
model_id: 23804037191200
  action: update
*************************** 3. row ***************************
      id: 79
   model: String
model_id: 23804037932180
  action: update
*************************** 4. row ***************************
      id: 109
   model: String
model_id: 23804037101700
  action: update
*************************** 5. row ***************************
      id: 139
   model: String
model_id: 23804037722160
  action: update

Thanks in advance,

Amie

+1  A: 

I've recently discovered acts_as_xapian and I've been playing around with it a bit. It seems like the acts_as_xapian_jobs table gets updated any time a model is changed. Then, the Xapian index is actually updated the next time rake xapian:update_index is run.

So, the acts_as_xapian_jobs table basically just contains the ids of records in the model which need to be re-indexed. As far as I can tell, records only get added to the table when your model has changed, so -- are you changing/updating lots of entries in your database? This might be why you've overflowed the max int value.

Hope this helps!

Feross
Thanks for the reply @Feross. This was a while ago, and if I remember correctly, I was using a forked version of acts_as_xapian, and it worked fine after switched to the original version. It's been working great ever since!
Grnbeagle