spanner: fix incorrect decreasing metrics

This issue happens when the number of sessions is downsizing to a
smaller value during a health recyling period (10 mins). When the
session pool does not need this many sessions, the health maintainer
will adjust the number of sessions to a lower number.

The current implementation to decrease numReads and numWrites is
incorrect because `p.idleList.Remove` and `p.idleWriteList.Remove`
always return a non-nil value. This leads to a decrease for both
metrics at the same time.

Change-Id: Ie21c30200559ebbe95ec09c65e7e54040fcf0cfc
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/54830
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Knut Olav Løite <koloite@gmail.com>
diff --git a/spanner/session.go b/spanner/session.go
index 69e7232..ec4051a 100644
--- a/spanner/session.go
+++ b/spanner/session.go
@@ -1054,14 +1054,12 @@
 	// If the session is in the idlelist, remove it.
 	if ol != nil {
 		// Remove from whichever list it is in.
-		var elem interface{}
-		elem = p.idleList.Remove(ol)
-		if elem != nil {
-			p.decNumReadsLocked(ctx)
-		}
-		elem = p.idleWriteList.Remove(ol)
-		if elem != nil {
+		p.idleList.Remove(ol)
+		p.idleWriteList.Remove(ol)
+		if s.isWritePrepared() {
 			p.decNumWritesLocked(ctx)
+		} else {
+			p.decNumReadsLocked(ctx)
 		}
 	}
 	if s.invalidate() {