Conversation

arpan14

Key changes

  • maintainMultiplexedSession - method executed as part of background task.
  • getMultiplexedSessionWithFallback - method to obtain a multiplexed session.

@arpan14arpan14 requested a review from a team as a code owner March 28, 2024 14:12
@product-auto-labelproduct-auto-label bot added size: lPull request size is large.api: spannerIssues related to the googleapis/java-spanner API.labels Mar 28, 2024
@arpan14arpan14 requested a review from olavloite March 28, 2024 14:12
@arpan14arpan14 added the owlbot:runAdd this label to trigger the Owlbot post processor.label Apr 2, 2024
@gcf-owl-botgcf-owl-bot bot removed the owlbot:runAdd this label to trigger the Owlbot post processor.label Apr 2, 2024
@arpan14arpan14 requested a review from a team as a code owner April 2, 2024 15:07
@arpan14arpan14 requested a review from olavloite April 4, 2024 16:57
@arpan14arpan14 requested a review from olavloite April 5, 2024 19:00

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I really like how the structure is now looking! This will significantly simplify the entire session pool once we can get rid of all 'normal' sessions. I left a couple of minor comments, but I think that structurally this is largely how it should be.

@arpan14arpan14 requested a review from olavloite April 8, 2024 16:53
}

SessionFutureWrapper getWrappedMultiplexedSessionFuture() {
return new MultiplexedSessionFutureWrapper(currentMultiplexedSessionReference.get());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only need one instance of MultiplexedSessionFutureWrapper per instance of SettableFuture that we have for the multiplexed session, as the wrapper does not contain any additional state. So we should just create one instance of it per multiplexed session that we have (meaning one at startup, and one each time that we successfully refresh the multiplexed session). That will reduce the number of objects that we have to create each time a read-only operation is executed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for the time-being it is stateless. Hence, stored a local variable MultiplexedSessionFutureWrapper and managing this in the call back methods.

I fore-see that we may need to store the state of span in the Future object. I'll change this back to a stateful object based on how that refactoring goes at - #3016

return new MultiplexedSessionFutureWrapper(currentMultiplexedSessionReference.get());
}

MultiplexedSessionFuture getMultiplexedSession() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method still used? Or can we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is called by all invocations which need a session to be available (for ex - maintainer). Modifying the logic in this method to

MultiplexedSessionFuture getMultiplexedSession() {
    return (MultiplexedSessionFuture) getWrappedMultiplexedSessionFuture().get();
  }

This allows callers to not do a get().get() on wrapper as post initialization there will always be a instance available.

Copy link
Contributor Author

@arpan14 arpan14 Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, i've added necessary docs to mention this method is blocking. Also checked that all places that invoke this method have a isDone() check.

@arpan14arpan14 closed this Apr 9, 2024
@arpan14arpan14 force-pushed the mux-pr-create-session branch from 449aefa to 2e85bd5 Compare April 9, 2024 16:39
@product-auto-labelproduct-auto-label bot added size: uPull request is empty.and removed size: lPull request size is large.labels Apr 9, 2024
@arpan14arpan14 reopened this Apr 9, 2024
@product-auto-labelproduct-auto-label bot added size: lPull request size is large.and removed size: uPull request is empty.labels Apr 9, 2024
@arpan14arpan14 added the owlbot:runAdd this label to trigger the Owlbot post processor.label Apr 9, 2024
@gcf-owl-botgcf-owl-bot bot removed the owlbot:runAdd this label to trigger the Owlbot post processor.label Apr 9, 2024
@arpan14arpan14 merged commit 5de1d87 into googleapis:main Apr 9, 2024
@arpan14arpan14 deleted the mux-pr-create-session branch April 9, 2024 17:51
Sign up for free to join this conversation on . Already have an account? Sign in to comment
Issues related to the googleapis/java-spanner API.size: lPull request size is large.
None yet

Successfully merging this pull request may close these issues.