File tree 4 files changed +51
-1
lines changed
4 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ Place it into project library path in your IDE.
67
67
68
68
* ` tarantool.persistent ` - Enable persistent connections (don't close connections between sessions) (defaults: True, ** can't be changed in runtime** )
69
69
* ` tarantool.timeout ` - Connection timeout (defaults: 10 seconds, can be changed in runtime)
70
- * ` tarantool.retry_count ` - Count of retries for connecting (defaults: 1, can be changed in runtime)
70
+ * ` tarantool.retry_count ` - Amount of attempts to connect (defaults: 1, can be changed in runtime)
71
71
* ` tarantool.retry_sleep ` - Sleep between connecting retries (defaults: 0.1 second, can be changed in runtime)
72
72
* ` tarantool.request_timeout ` - Read/write timeout for requests (defaults: 10 second, can be changed in runtime)
73
73
Original file line number Diff line number Diff line change @@ -257,6 +257,11 @@ static int __tarantool_connect(tarantool_object *t_obj) {
257
257
double_to_ts (INI_FLT ("retry_sleep" ), & sleep_time );
258
258
char * err = NULL ;
259
259
260
+ if (count < 1 ) {
261
+ THROW_EXC ("tarantool.retry_count should be 1 or above" );
262
+ return FAILURE ;
263
+ }
264
+
260
265
if (t_obj -> is_persistent ) {
261
266
if (!obj -> persistent_id )
262
267
obj -> persistent_id = pid_pzsgen (obj -> host , obj -> port ,
Original file line number Diff line number Diff line change @@ -163,5 +163,33 @@ public static function provideGoodCredentials()
163
163
['guest ' , null ],
164
164
];
165
165
}
166
+
167
+ public function test_10_zero_retry_exception () {
168
+ /* A connection to call iproto_connect_count(). */
169
+ $ tarantool = new Tarantool ('localhost ' , self ::$ port , 'test ' , 'test ' );
170
+ $ iproto_connect_count_before =
171
+ $ tarantool ->call ('iproto_connect_count ' )[0 ][0 ];
172
+
173
+ $ saved_retry_count = ini_get ('tarantool.retry_count ' );
174
+ ini_set ('tarantool.retry_count ' , 0 );
175
+
176
+ $ exp_err = 'tarantool.retry_count should be 1 or above ' ;
177
+ try {
178
+ $ c = new Tarantool ('localhost ' , self ::$ port );
179
+ $ c ->connect ();
180
+ $ this ->assertFalse (true );
181
+ } catch (Exception $ e ) {
182
+ $ this ->assertInstanceOf (TarantoolException::class, $ e );
183
+ $ this ->assertEquals ($ exp_err , $ e ->getMessage ());
184
+ } finally {
185
+ ini_set ('tarantool.retry_count ' , $ saved_retry_count );
186
+ }
187
+
188
+ /* Verify that no connection attempts were performed. */
189
+ $ iproto_connect_count_after =
190
+ $ tarantool ->call ('iproto_connect_count ' )[0 ][0 ];
191
+ $ this ->assertEquals ($ iproto_connect_count_before ,
192
+ $ iproto_connect_count_after );
193
+ }
166
194
}
167
195
Original file line number Diff line number Diff line change @@ -180,5 +180,22 @@ function test_6(...)
180
180
return ...
181
181
end
182
182
183
+ iproto_connect_counter = 0
184
+ function iproto_connect_count ()
185
+ return iproto_connect_counter
186
+ end
187
+
188
+ box .session .on_connect (function ()
189
+ -- box.session.type() was introduced in 1.7.4-370-g0bce2472b.
190
+ --
191
+ -- We're interested in iproto sessions, but it is okay for our
192
+ -- usage scenario to count replication and console sessions
193
+ -- too: we only see to a delta and AFAIK our testing harness
194
+ -- does not perform any background reconnections.
195
+ if box .session .type == nil or box .session .type () == ' binary' then
196
+ iproto_connect_counter = iproto_connect_counter + 1
197
+ end
198
+ end )
199
+
183
200
require (' console' ).listen (os.getenv (' ADMIN_PORT' ))
184
201
You can’t perform that action at this time.
0 commit comments