lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Upayavira ...@odoko.co.uk>
Subject Re: Solr 5.4 Transaction
Date Tue, 07 Jun 2016 10:12:34 GMT
There is no equivalent to transactions in Lucene or Solr. A commit
persists newly added documents to disk - all of them, regardless of
which client sent them. A rollback discards all uncommitted documents,
regardless of which client sent them, which renders a rollback pretty
un-useful.

If you need a transaction system, you're gonna need to manage it
yourself. You could, before updating some documents, retrieve and store
them. Then, should the transaction fail, you post your old documents
over the top of your changes. You might be able to use some of the
features of partial updates (e.g. the _version_ field) to ensure that
you don't accidentally overwrite someone else's changes.

But basically, if you want a transaction system, you're gonna have to
build it yourself. (Or, push the data to a database that *does* support
transactions, and then have a process that pulls updates from the DB to
Solr).

Upayavira

On Tue, 7 Jun 2016, at 10:52 AM, Vincenzo D'Amore wrote:
> Hi Pithon,
> 
> I have to state beforehand that I worked with transactions on Solr 4.8.1,
> so I'm not sure the transactions are changed in Solr over time.
> And, I have to add, the transactions support not is very well documented,
> so most of what I know is based on my experience.
> 
> Given that, Solr clients connects via HTTP, which is a stateless
> protocol,
> so many clients can connect concurrently.
> That's important point, and IMHO it make a great difference from other
> products that have clients with an "open connection", which enable them
> to
> have a transaction at protocol level.
> 
> So this means that when a client commit (or rollback)  to all active
> clients are involved.
> When a client rollbacks, all the previous work done by all the clients
> will
> be rollbacked.
> 
> That's why, if you really need to rollback, only one client should be
> connected at a time.
> 
> I think, if you really want implement transactions with Solr, what you
> can
> do is add a layer, your own layer, that transparently give this
> functionality.
> 
> Best regards,
> Vincenzo
> 
> 
> 
> On Tue, Jun 7, 2016 at 11:14 AM, Pithon Philippe
> <ppithon.sigal@gmail.com>
> wrote:
> 
> > Thanks,
> > my problem is for rollback transaction by user...
> > if there is a problem in trycatch for a user, the rollback run for all
> > users commit...
> > Philippe
> >
> > 2016-06-07 9:23 GMT+02:00 Mikhail Khludnev <mkhludnev@griddynamics.com>:
> >
> > > Hello,
> > >
> > > That's how Lucene work underneath.
> > > Just ad-hoc idea you can have isolated per session indices and then add
> > > them altogether. Thinking deeper, we can consider per thread invertors
> > > which somehow isolated, perhaps something transactional might be built on
> > > top of them, but it's really deep hack.
> > > Anyway, it.s not clear what you want to achieve and why by this way.
> > Also,
> > > this question suits for dev@ much more.
> > > 07 июня 2016 г. 9:41 пользователь "Pithon Philippe" <
> > > ppithon.sigal@gmail.com>
> > > написал:
> > >
> > > > Hi,
> > > > I have a question on Solr Transaction as relational databases
> > > >
> > > > The Solr commit is not isolated for each client session, right?
> > > > In my test (source below) The commit in a session adds records of other
> > > > sessions
> > > > is there a documentation on this?
> > > > is what's planned improvements on this? version 6, version 7?
> > > > Thank you for any ideas!
> > > >
> > > >
> > > > Source example  :
> > > >
> > > > public class TransactionTest {
> > > >
> > > > static final String BASE_URL = "http://localhost:8983/solr/test";
> > > >
> > > > public static void main(String[] args) {
> > > >
> > > > try {
> > > > new TransactionTest();
> > > > } catch (Exception e) {
> > > > e.printStackTrace();
> > > > }
> > > >
> > > > }
> > > >
> > > > public TransactionTest() throws Exception {
> > > >
> > > > HttpSolrClient solrClient = new HttpSolrClient(BASE_URL);
> > > >
> > > > DTOMail mail = new DTOMail();
> > > > mail.setType("mail");
> > > > mail.setBody("test body");
> > > >
> > > > System.out.println("add been");
> > > > solrClient.addBean(mail);
> > > >
> > > > pause();
> > > >
> > > > System.out.println("commit");
> > > > solrClient.commit();
> > > >
> > > > solrClient.close();
> > > > }
> > > >
> > > > private void pause() {
> > > >
> > > > try {
> > > > System.in.read();
> > > > } catch (Exception e) {
> > > > }
> > > >
> > > > }
> > > >
> > > > }
> > > >
> > >
> >
> 
> 
> 
> -- 
> Vincenzo D'Amore
> email: v.damore@gmail.com
> skype: free.dev
> mobile: +39 349 8513251

Mime
View raw message