On Fri, 11 Jan 2008 00:43:19 -0200
Leonardo Santagada <[EMAIL PROTECTED]> wrote:

> No, actually my problem is that the solr index is mirroring data on a  
> database (a Zope app to be more acurate) so it would be better if I  
> could send the whole transaction together so I don't have to keep it  
> on separate files... wich I have to do so I can not send anything if  
> the transaction is aborted (I can't abort a solr add right?).
> 
> Maybe I should explain more, but I think this is pretty comon to  
> anyone trying to keep database transactions and a solr index in sync,  
> as solr doesn't support two phase commit or anything like that.

Hola Leonardo,
I haven't have to do this, but I am starting to design something along these 
lines.

if you execut your 'add' and 'deletes' from a stored proc, inside a 
transaction, you can simply have an extra table with Solr doc ids and the 
action to perform (add / delete). 
eg, 
exec(delete_from_my_db('xyz') ->
being transaction
 {do here all your DB work}
 {add to tblSolrWork the ID to delete}
end transaction
Hence , If the transaction fails, those records will never actually exist.

You can then have a process that every x seconds/minutes/hours (depending on 
your needs), scans this tbSolrWork table and performs whatever adds or deletes 
are needed. Of course, for the add, you'll also need to get the information to 
add from somewhere, but I imagine you already do that.

Whether and how you could do this in Zope, I have no idea, but if you solve it 
it would be great if you could share it here .

You could also make use of  triggers (on insert / update and onDelete 
triggers), but I suppose that is a bit more DB dependent than plain SP work - 
though it may be simpler to implement than changing all your code to call the 
SP instead of direct SQL cmds...

good luck,
B
_________________________
{Beto|Norberto|Numard} Meijome

"He can compress the most words into the smallest idea of any man I know."
  Abraham Lincoln

I speak for myself, not my employer. Contents may be hot. Slippery when wet. 
Reading disclaimers makes you go blind. Writing them is worse. You have been 
Warned.

Reply via email to