[JAVA-4325] Commit Transaction reactive streams question Created: 02/Oct/21  Updated: 04/May/22  Resolved: 04/Nov/21

Status: Closed
Project: Java Driver
Component/s: Reactive Streams
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Rron Jahiri Assignee: Jeffrey Yemin
Resolution: Won't Fix Votes: 0
Labels: external-user
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

https://github.com/mongodb/mongo-java-driver/blob/master/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ClientSessionPublisherImpl.java#L153

On this class when calling method commitTransaction it returns a publisher. If client creates a publisher without subscribing to it it returns error. It should not return an error when client is not subscribed to that publisher.



 Comments   
Comment by Jeffrey Yemin [ 04/Nov/21 ]

Hi rron@kodelabs.com

As it's been this way for quite a while, we are not inclined to change it back at this point. If we get more user complaints about it, we will reconsider.

Comment by Rron Jahiri [ 21/Oct/21 ]

Version that I was using was 4.1.0

Comment by Jeffrey Yemin [ 20/Oct/21 ]

Hi rron@kodelabs.com,

Thanks for clarifying.  Can you let us know the last release where it worked as you expected?

Comment by Rron Jahiri [ 18/Oct/21 ]

Hi , 
The issue happens this way : 

  public Publisher<Void> mongodbError(ClientSession clientSession) {
    Publisher<Void> voidPublisher = clientSession.commitTransaction();  //it returns an error 
    //do stuff
 
    //
    clientSession.startTransaction();
    return voidPublisher;
  }

So if you create a publisher before calling startTransaction(); it returns error. I had a case like that where we created a publisher before starting transaction but we didn't subscribe to it until we started transaction. It used to work on older versions. I made a work around for it but I think it should be fixed too.

Comment by Valentin Kavalenka [ 07/Oct/21 ]

Hi rron@kodelabs.com,
Thanks for reporting the issue you encountered.

The method ClientSessionPublisherImpl.commitTransaction returns a Publisher<Void>, therefore the method cannot "know" whether or not the returned Publisher will be subscribed to or not, and cannot throw an error if the Publisher does not get subscribed to. So it must be something else that throws the error you are talking about, but I cannot figure out what that is from the description. Could you please clarify the scenario with more details and attach the full stack trace of the exception that you are observing? If you can attach code that reproduces the error, that would be even better.

Generated at Thu Feb 08 09:01:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.