I'm not sure even what the spam module thinks it's doing. I'm getting a fresh pair of entries with each cron pass:

trackback	0	2005-10-27 12:33	spam_delete_trackback: deleted trackback "".	Anonymous	details
trackback	321	2005-10-27 12:33	spam_cron: deleting trackback	Anonymous	details

However, there *is* no trackback 321. I have no idea where it's getting that number, or why it's stuck. Trackback #0 is of course complete nonsense. There is no further useful information in the details.

Comments

Zed Pobre’s picture

Found the source of the problem: I apparently have invalid entries in the spam_tracker table. There are 6 entries where id = 0 (all where source = 'list' and probability = 1 and all have the same hash). I've dropped those entries and will be checking back to see if the problem goes away.

This means that spam.module needs to have a sanity check in spam_cron() to make sure that results from the spam_tracker query actually exist in their respective tables, and if not, to clear the spam_tracker entry without going on to attempt to delete a nonexistent comment/trackback.

Zed Pobre’s picture

To be complete, I also cleared the line with id = 321.

Zed Pobre’s picture

A few cron passes have gone by now, and the errors have disappeared. Those entries appear to have been the problem.

jeremy’s picture

Is that a typo that the source was 'list'? Did you mean to type 'trackback'?

Your suggested solution is easier said than done. What was showing up in the spam log? If it gets as far as spam_delete_trackback(), the spam_tracker entry should be automatically removed.

jeremy’s picture

If I add an entry of type 'list', I get the following expected error when trying to run cron:

Fatal error: Call to undefined function: spam_delete_list() in /var/www/drupal-4.6.3/modules/spam.module on line 330

If I add a bogus entry of type 'trackback' (either with a positive id, or an id of 0) the bogus entry is quietly deleted when cron runs. The following logs show up in the spam log, and the entry is deleted from the spam_tracker table:

trackback	0	2005-11-01 00:45	spam_delete_trackback: deleted trackback "".	Jeremy	details
trackback	0	2005-11-01 00:45	spam_cron: deleting trackback	Jeremy	details
Zed Pobre’s picture

Well, I'm not sure how the entries got in there originally (though I do have a vague memory of having tampered with spam.module and lists some time ago), but they definitely weren't being removed. Those lines I posted at the start appeared in the logs at every single cron pass. I suspect that the trackback discrepancy may have come from my having deleted a trackback_received entry by hand (via psql) at one point, though I couldn't tell you for sure. Possibly it was a trackback that I deleted from inside Drupal during a time when I had spam.module disabled.

jeremy’s picture

Based on my own testing, I suspect it is either a problem you introduced in your earlier tweaking (I'm not sure what 'lists' you're referring to), or it is a problem specific to PostgreSQL. I am unable to duplicate it on my development server.

I'll leave this open for a couple of weeks, let me know if you have the problem again.

Zed Pobre’s picture

Priority: Normal » Minor

Eh, well, now that I've dumped the corrupt entries, I'm pretty sure it *won't* happen again. I still think a sanity check on the spam_tracker table is a good idea, but it's obviously not a high priority. Changing priority to minor with this.

jeremy’s picture

I still think a sanity check on the spam_tracker table is a good idea

I disagree. I don't see any need. In all my testing, the only way I could break something was by adding an entry to spam_tracker of a non-existent type. This will never happen unless someone is manually adding entries, in which case there are many other ways things can break, too.

Another thing is that the spam_tracker table isn't just used by the spam module. It's also used by third party modules via the Spam API.

If bad entries are getting into the spam_tracker table, that's a bug that should be fixed. I will leave this issue open for now as I'm interested in hearing if anyone else has run into a similar problem with the latest code.

Zed Pobre’s picture

I'm pretty sure I know how this is happening now. It happens when someone (so far, always a spammer) sends a trackback with a site, name, subject, url, or excerpt longer than the database constraints allow. The spam_tracker insert goes through fine, but then the trackback_received insert fails, leaving a spam_tracker entry pointing to a nonexistent trackback_received entry.

I *suspect* that this is a Postgresql-specific problem, and that MySQL is silently truncating the data to fit in the field. I haven't tested it with a MySQL system to be sure.

I created a view to track the problem more precisely with:

CREATE VIEW trackback_check (sid,id,trid,prob,name,subject) AS
   SELECT spam_tracker.sid, spam_tracker.id, trid, probability AS prob, name, subject
   FROM spam_tracker
   LEFT JOIN trackback_received ON spam_tracker.id = trackback_received.trid
  WHERE spam_tracker.source::text = 'trackback'::text;

In MySQL, you'll probably have to perform the select fresh each time, adding a search for where trid is null, as I don't think it supports views. In Postgres, that shows the pattern of holes quite nicely. I'm up to over 10,000 holes now, not counting the ones I've manually deleted, just from the last four or so months.

I still think that a check at the delete stage for this problem (so that spam_tracker entries not associated with trackback_received entries can simply be automatically deleted) would be a good sanity check to have, because this is immensely hard and time consuming to fix with PostgreSQL 7.x. (8.x added a proprietary extension USING to the DELETE syntax which I could use combined with a view to take care of it periodically, but alas, I cannot upgrade at this time.)

jeremy’s picture

Status: Active » Fixed

No updates for a very long time. Marking as fixed as I assume it's no longer a problem.

The spam api will be much improved in the upcoming 5.x-2.x version of the module.

Anonymous’s picture

Status: Fixed » Closed (fixed)