Skip to content

Commit 26b47e2

Browse files
hide debug printout
1 parent 7e01125 commit 26b47e2

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

connection.go

+22-22
Original file line numberDiff line numberDiff line change
@@ -433,17 +433,17 @@ func Connect(addr string, opts Opts) (conn *Connection, err error) {
433433
}
434434

435435
if conn.isWatchersRequired() {
436-
fmt.Printf("starting on_shutdown...\n")
436+
// fmt.Printf("starting on_shutdown...\n")
437437
watcher, werr := conn.NewWatcher("box.shutdown", func(event WatchEvent) {
438-
fmt.Printf("event connection: %s\n", event.Conn.Addr())
439-
fmt.Printf("event key: %s\n", event.Key)
440-
fmt.Printf("event value: %v\n", event.Value)
438+
// fmt.Printf("event connection: %s\n", event.Conn.Addr())
439+
// fmt.Printf("event key: %s\n", event.Key)
440+
// fmt.Printf("event value: %v\n", event.Value)
441441
boolVal, ok := event.Value.(bool)
442442
if ok && (boolVal == true) {
443443
// defer cause otherwise we'll block ourselves on ack wait
444444
defer event.Conn.shutdownOnServerEvent()
445445
}
446-
fmt.Printf("callback finished\n")
446+
// fmt.Printf("callback finished\n")
447447
})
448448

449449
if werr != nil {
@@ -459,11 +459,11 @@ func Connect(addr string, opts Opts) (conn *Connection, err error) {
459459
func (conn *Connection) shutdownOnServerEvent() {
460460
conn.mutex.Lock()
461461

462-
fmt.Printf("starting shutdown... (%v)\n", conn.UniqueId())
462+
// fmt.Printf("starting shutdown... (%v)\n", conn.UniqueId())
463463
atomic.StoreUint32(&(conn.shutdownInProgress), shutdownInProgress)
464464
defer atomic.StoreUint32(&(conn.shutdownInProgress), shutdownNotInProgress)
465465

466-
fmt.Printf("wait for futures to finish... (%v)\n", conn.UniqueId())
466+
// fmt.Printf("wait for futures to finish... (%v)\n", conn.UniqueId())
467467
conn.shutdownWg.Wait()
468468

469469
// fmt.Printf("defer unregister watcher...\n")
@@ -474,10 +474,10 @@ func (conn *Connection) shutdownOnServerEvent() {
474474
"connection closed after server shutdown",
475475
}
476476

477-
fmt.Printf("close the connection... (%v)\n", conn.UniqueId())
477+
// fmt.Printf("close the connection... (%v)\n", conn.UniqueId())
478478
conn.closeConnection(err, false)
479479

480-
fmt.Printf("finish shutdown... (%v)\n", conn.UniqueId())
480+
// fmt.Printf("finish shutdown... (%v)\n", conn.UniqueId())
481481

482482
conn.mutex.Unlock()
483483

@@ -787,9 +787,9 @@ func (conn *Connection) readIdResponse(r io.Reader) (Response, error) {
787787

788788
func (conn *Connection) createConnection(reconnect bool) (err error) {
789789
var reconnects uint
790-
fmt.Printf("conn.state is %v (%v)\n", conn.state, conn.UniqueId())
790+
// fmt.Printf("conn.state is %v (%v)\n", conn.state, conn.UniqueId())
791791
for conn.c == nil && conn.state == connDisconnected {
792-
fmt.Printf("createConnection iteration (%v)\n", conn.UniqueId())
792+
// fmt.Printf("createConnection iteration (%v)\n", conn.UniqueId())
793793

794794
now := time.Now()
795795
err = conn.dial()
@@ -809,11 +809,11 @@ func (conn *Connection) createConnection(reconnect bool) (err error) {
809809
conn.notify(ReconnectFailed)
810810
reconnects++
811811

812-
fmt.Printf("until sleep %v (%v)\n", time.Now(), conn.UniqueId())
812+
// fmt.Printf("until sleep %v (%v)\n", time.Now(), conn.UniqueId())
813813
conn.mutex.Unlock()
814814
time.Sleep(time.Until(now.Add(conn.opts.Reconnect)))
815815
conn.mutex.Lock()
816-
fmt.Printf("after sleep %v (%v)\n", time.Now(), conn.UniqueId())
816+
// fmt.Printf("after sleep %v (%v)\n", time.Now(), conn.UniqueId())
817817
}
818818
if conn.state == connClosed {
819819
err = ClientError{ErrConnectionClosed, "using closed connection"}
@@ -850,29 +850,29 @@ func (conn *Connection) closeConnection(neterr error, forever bool) (err error)
850850
return
851851
}
852852

853-
func (conn *Connection) UniqueId() string {
854-
return fmt.Sprintf("conn %v", conn.control)
855-
}
853+
// func (conn *Connection) UniqueId() string {
854+
// return fmt.Sprintf("conn %v", conn.control)
855+
// }
856856

857857
func (conn *Connection) reconnect(neterr error, c net.Conn) {
858-
fmt.Printf("reconnect head (%v)\n", conn.UniqueId())
858+
// fmt.Printf("reconnect head (%v)\n", conn.UniqueId())
859859
conn.mutex.Lock()
860860
defer conn.mutex.Unlock()
861-
fmt.Printf("conn.opts.Reconnect %d (%v)\n", conn.opts.Reconnect, conn.UniqueId())
861+
// fmt.Printf("conn.opts.Reconnect %d (%v)\n", conn.opts.Reconnect, conn.UniqueId())
862862
if conn.opts.Reconnect > 0 {
863863
if c == conn.c {
864-
fmt.Printf("reconnect attempt (%v)\n", conn.UniqueId())
864+
// fmt.Printf("reconnect attempt (%v)\n", conn.UniqueId())
865865
conn.closeConnection(neterr, false)
866866
if err := conn.createConnection(true); err != nil {
867-
fmt.Printf("kill that one (folded)(%v)\n", conn.UniqueId())
867+
// fmt.Printf("kill that one (folded)(%v)\n", conn.UniqueId())
868868
conn.closeConnection(err, true)
869869
}
870870
}
871871
} else {
872-
fmt.Printf("kill that one (%v)\n", conn.UniqueId())
872+
// fmt.Printf("kill that one (%v)\n", conn.UniqueId())
873873
conn.closeConnection(neterr, true)
874874
}
875-
fmt.Printf("reconnect end (%v)\n", conn.UniqueId())
875+
// fmt.Printf("reconnect end (%v)\n", conn.UniqueId())
876876
}
877877

878878
func (conn *Connection) lockShards() {

graceful_shutdown/tarantool_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestGracefulShutdown(t *testing.T) {
4848
// fmt.Printf("opts are is %v\n", opts)
4949
// fmt.Printf("opts.Reconnect is %v\n", opts.Reconnect)
5050
conn := test_helpers.ConnectWithValidation(t, server, opts)
51-
fmt.Printf("test connect unique id: %v\n", conn.UniqueId())
51+
// fmt.Printf("test connect unique id: %v\n", conn.UniqueId())
5252

5353
_, err = conn.Eval("box.ctl.set_on_shutdown_timeout(10)", []interface{}{})
5454
require.Nil(t, err)
@@ -63,7 +63,7 @@ func TestGracefulShutdown(t *testing.T) {
6363
req := tarantool.NewEvalRequest("require('fiber').sleep(1); return 'nice sleep'")
6464

6565
fut := conn.Do(req)
66-
fmt.Printf("test future is %v\n", fut)
66+
// fmt.Printf("test future is %v\n", fut)
6767

6868
require.Nil(t, inst.Cmd.Process.Signal(syscall.SIGTERM))
6969

@@ -96,12 +96,12 @@ func TestGracefulShutdown(t *testing.T) {
9696
err = test_helpers.RestartTarantool(&inst)
9797
require.Nilf(t, err, "Failed to restart tarantool")
9898

99-
fmt.Printf("opts are is %v\n", opts)
99+
// fmt.Printf("opts are is %v\n", opts)
100100
connected := test_helpers.WaitUntilReconnected(conn, retries, timeout)
101101
require.True(t, connected, "Reconnect success")
102102

103103
fut = conn.Do(req)
104-
fmt.Printf("test future is %v\n", fut)
104+
// fmt.Printf("test future is %v\n", fut)
105105

106106
require.Nil(t, inst.Cmd.Process.Signal(syscall.SIGTERM))
107107

test_helpers/utils.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ func DeleteRecordByKey(t *testing.T, conn tarantool.Connector,
4747
// Returns false in case of connection is not in the connected state
4848
// after specified retries count, true otherwise.
4949
func WaitUntilReconnected(conn *tarantool.Connection, retries uint, timeout time.Duration) bool {
50-
fmt.Printf("WaitUntilReconnected %v %v \n", retries, timeout)
50+
// fmt.Printf("WaitUntilReconnected %v %v \n", retries, timeout)
5151

5252
for i := uint(0); ; i++ {
53-
fmt.Printf("reconnect in tests iteration i=%v\n", i)
53+
// fmt.Printf("reconnect in tests iteration i=%v\n", i)
5454

5555
connected := conn.ConnectedNow()
5656
if connected {
57-
fmt.Printf("ConnectedNow true\n")
57+
// fmt.Printf("ConnectedNow true\n")
5858
return true
5959
}
6060

@@ -65,7 +65,7 @@ func WaitUntilReconnected(conn *tarantool.Connection, retries uint, timeout time
6565
time.Sleep(timeout)
6666

6767
// resp, err := conn.Do(tarantool.NewPingRequest()).Get()
68-
fmt.Printf("reconnect in tests iteration i=%v\n", i)
68+
// fmt.Printf("reconnect in tests iteration i=%v\n", i)
6969
// fmt.Printf("reconnect tests; err ping %v\n", err)
7070
}
7171

0 commit comments

Comments
 (0)