[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-353) removing an entity and adding another with same PK (in same TX) will not add second entity to index
Emmanuel Bernard (JIRA)
noreply at atlassian.com
Mon Apr 27 10:51:17 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33029#action_33029 ]
Emmanuel Bernard commented on HSEARCH-353:
------------------------------------------
This case cannot happen in the regular use of an ORM. I would argue that deleting and reusing the same id is pretty evil anyway regardless of ORMs.
PS: it can happen with ORMs but only for assigned ids and if the user reuse the same id. I can't see much valid reasons to do that.
Provided that HSEARCH-257 is really important, I think we will not solve this one.
Yan, which use case lead to uncover this bug?
> removing an entity and adding another with same PK (in same TX) will not add second entity to index
> ----------------------------------------------------------------------------------------------------
>
> Key: HSEARCH-353
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-353
> Project: Hibernate Search
> Issue Type: Bug
> Components: engine
> Affects Versions: 3.1.0.GA
> Reporter: Yan Falken
> Assignee: Sanne Grinovero
> Fix For: 3.1.1, 3.2.0
>
>
> Hi,
> I have the following problem with indexing in transaction with hibernate
> search: in case the transaction is opened and I want to perform multiple
> work types - only one type is actually performed after the commit and the others are
> ignored; example:
> TransactionManager tm = new DummyTransactionManager();
> tm.begin();
> SEntity se1 = new SEntity(10, "first", "second", true);
> Work delete = new Work(se1, "100", WorkType.DELETE);
> Work add = new Work(se1, "100", WorkType.ADD);
> Ctx ctx = new Ctx(tm.getTransaction());
> searchFactory.getWorker().performWork(delete, ctx);
> searchFactory.getWorker().performWork(add, ctx);
> tm.commit();
> only DELETE is performed - ADD is ignored
> log:
> 2009-03-23 13:45:02,195 TRACE main| MaskedProperty| found a match for key: [hibernate.search.default.indexBase] value: /tmp/c1idx
> 2009-03-23 13:45:02,195 TRACE main| MaskedProperty| found a match for key: [default.indexBase] value: /tmp/c1idx
> 2009-03-23 13:45:02,341 DEBUG main| BuilderIndexedEntity| Field selection in projections is set to false for entity problems.SEntity.
> 2009-03-23 13:45:02,502 DEBUG pool-1-thread-1| PerDPQueueProcessor| Skipping usage of an IndexWriter for updates
> 2009-03-23 13:45:02,503 TRACE pool-1-thread-1| PerDPQueueProcessor| Locking Workspace (or waiting to...)
> 2009-03-23 13:45:02,503 TRACE pool-1-thread-1| PerDPQueueProcessor| Workspace lock aquired.
> // opened
> 2009-03-23 13:45:02,503 DEBUG pool-1-thread-1| PerDPQueueProcessor| Opening an IndexReader for update
> 2009-03-23 13:45:02,503 TRACE pool-1-thread-1| Workspace| IndexReader opened
> // only remove
> 2009-03-23 13:45:02,503 TRACE pool-1-thread-1| eleteExtWorkDelegate| Removing class problems.SEntity#100 by id using an IndexReader.
> 2009-03-23 13:45:02,539 TRACE pool-1-thread-1| Workspace| IndexReader closed
> 2009-03-23 13:45:02,539 TRACE pool-1-thread-1| PerDPQueueProcessor| Unlocking Workspace
> I digged into the code a little bit and there is class method:
> org.hibernate.search.engine.DocumentBuilderIndexedEntity.addWorkToQueue() which is in it's beginning iterating the existing queue to avoid unecessary duplicated works
> if ( workType == WorkType.DELETE ) { //TODO add PURGE?
> //DELETE should have precedence over any update before (HSEARCH-257)
> //if an Add work is here, remove it
> //if an other delete is here remember but still search for Add
> if ( luceneWork instanceof AddLuceneWork ) {
> toDelete.add( luceneWork );
> }
> else if ( luceneWork instanceof DeleteLuceneWork ) {
> duplicateDelete = true;
> }
> }
> else {
> //we can safely say we are out, the other work is an ADD
> return;
> }
>
> I believe that return should be changed to continue. I did several tests and after the change it can handle ADD/DELETE works in one queue.
> There should be ability to in single transaction perform multiple work types as there is no way how to control the client to perform just one work type.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list