Skip to content

Commit 7a96270

Browse files
Add logs to find the issue at root
1 parent 21733d5 commit 7a96270

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/AsyncResultSetImpl.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -470,14 +470,14 @@ public void run() {
470470
// Non-streaming result sets do not trigger this callback, and for those result sets, we
471471
// need to eagerly start the ProduceRowsRunnable.
472472
synchronized (monitor) {
473-
if (state == State.STREAMING_IN_PROGRESS
474-
|| state == State.RUNNING
475-
|| state == State.CONSUMING) {
476-
return;
477-
}
478-
if (state == State.STREAMING_INITIALIZED) {
479-
state = State.STREAMING_IN_PROGRESS;
480-
}
473+
// if (state == State.STREAMING_IN_PROGRESS
474+
// || state == State.RUNNING
475+
// || state == State.CONSUMING) {
476+
// return;
477+
// }
478+
// if (state == State.STREAMING_INITIALIZED) {
479+
// state = State.STREAMING_IN_PROGRESS;
480+
// }
481481
if (!initiateStreaming(AsyncResultSetImpl.this)) {
482482
initiateProduceRows();
483483
}
@@ -492,6 +492,7 @@ public void run() {
492492
/** Sets the callback for this {@link AsyncResultSet}. */
493493
@Override
494494
public ApiFuture<Void> setCallback(Executor exec, ReadyCallback cb) {
495+
System.out.println("Inside setCallback");
495496
synchronized (monitor) {
496497
Preconditions.checkState(!closed, "This AsyncResultSet has been closed");
497498
Preconditions.checkState(
@@ -660,7 +661,7 @@ public void onStreamMessage(PartialResultSet partialResultSet, boolean bufferIsF
660661
!partialResultSet.getResumeToken().isEmpty()
661662
|| bufferIsFull
662663
|| partialResultSet == GrpcStreamIterator.END_OF_STREAM;
663-
if (startJobThread || state != State.STREAMING_IN_PROGRESS) {
664+
if (startJobThread || state != State.STREAMING_INITIALIZED) {
664665
initiateProduceRows();
665666
}
666667
}

google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ private ByteString generateTransactionName(String session) {
651651
counter = new AtomicLong();
652652
transactionCounters.put(session, counter);
653653
}
654+
System.out.printf("Generating session using Session ID %s\n", session);
654655
return ByteString.copyFromUtf8(
655656
String.format("%s/transactions/%d", session, counter.incrementAndGet()));
656657
}
@@ -1999,6 +2000,7 @@ private void ensureMostRecentTransaction(Session session, ByteString transaction
19992000
if (index > -1) {
20002001
long id = Long.parseLong(transactionId.toStringUtf8().substring(index + 1));
20012002
if (id != counter.get()) {
2003+
System.out.printf("Session ID %s TransactionId %s\n", session.getName(), transactionId.toStringUtf8());
20022004
throw Status.FAILED_PRECONDITION
20032005
.withDescription(
20042006
String.format(

google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnInvalidatedSessionTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,8 @@ private void asyncRunner_withReadFunction(
14341434
runner.runAsync(
14351435
txn -> {
14361436
AsyncResultSet rs = readFunction.apply(txn);
1437+
System.out.println(rs);
1438+
System.out.println("Creating a new AsyncResultSet");
14371439
ApiFuture<Void> fut =
14381440
rs.setCallback(
14391441
queryExecutor,
@@ -1450,6 +1452,7 @@ private void asyncRunner_withReadFunction(
14501452
}
14511453
}
14521454
});
1455+
System.out.println("After setCallback");
14531456
return ApiFutures.transform(
14541457
fut, input -> counter.get(), MoreExecutors.directExecutor());
14551458
},
@@ -1573,6 +1576,8 @@ private void asyncTransactionManager_readAsync(
15731576
context.then(
15741577
(transaction, ignored) -> {
15751578
AsyncResultSet rs = fn.apply(transaction);
1579+
System.out.println(rs);
1580+
System.out.println("1. Creating a new AsyncResultSet");
15761581
ApiFuture<Void> fut =
15771582
rs.setCallback(
15781583
queryExecutor,

0 commit comments

Comments
 (0)