File tree 4 files changed +48
-2
lines changed
4 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
24
24
- ConnectionPool does not properly handle disconnection with Opts.Reconnect
25
25
set (#272 )
26
26
- Watcher events loss with a small per-request timeout (#284 )
27
+ - Connect() panics on concurrent schema update (#278 )
27
28
28
29
## [ 1.10.0] - 2022-12-31
29
30
Original file line number Diff line number Diff line change @@ -181,6 +181,23 @@ local function push_func(cnt)
181
181
end
182
182
rawset (_G , ' push_func' , push_func )
183
183
184
+ local function create_spaces ()
185
+ for i = 1 ,10 do
186
+ local s = box .schema .space .create (' test' .. tostring (i ), {
187
+ id = 700 + i ,
188
+ if_not_exists = true ,
189
+ })
190
+ local idx = s :create_index (' test' .. tostring (i ) .. ' primary' , {
191
+ type = ' tree' ,
192
+ parts = {1 , ' uint' },
193
+ if_not_exists = true
194
+ })
195
+ idx :drop ()
196
+ s :drop ()
197
+ end
198
+ end
199
+ rawset (_G , ' create_spaces' , create_spaces )
200
+
184
201
local function tarantool_version_at_least (wanted_major , wanted_minor , wanted_patch )
185
202
-- https://github.com/tarantool/crud/blob/733528be02c1ffa3dacc12c034ee58c9903127fc/test/helper.lua#L316-L337
186
203
local major_minor_patch = _TARANTOOL :split (' -' , 1 )[1 ]
Original file line number Diff line number Diff line change @@ -325,8 +325,13 @@ func (conn *Connection) loadSchema() (err error) {
325
325
return err
326
326
}
327
327
for _ , index := range indexes {
328
- schema .SpacesById [index .SpaceId ].IndexesById [index .Id ] = index
329
- schema .SpacesById [index .SpaceId ].Indexes [index .Name ] = index
328
+ spaceId := index .SpaceId
329
+ if _ , ok := schema .SpacesById [spaceId ]; ok {
330
+ schema .SpacesById [spaceId ].IndexesById [index .Id ] = index
331
+ schema .SpacesById [spaceId ].Indexes [index .Name ] = index
332
+ } else {
333
+ return errors .New ("concurrent schema update" )
334
+ }
330
335
}
331
336
332
337
conn .lockShards ()
Original file line number Diff line number Diff line change @@ -3894,6 +3894,29 @@ func TestWatcher_Unregister_concurrent(t *testing.T) {
3894
3894
wg .Wait ()
3895
3895
}
3896
3896
3897
+ func TestConnect_schema_update (t * testing.T ) {
3898
+ conn := test_helpers .ConnectWithValidation (t , server , opts )
3899
+ defer conn .Close ()
3900
+
3901
+ for i := 0 ; i < 100 ; i ++ {
3902
+ fut := conn .Do (NewCallRequest ("create_spaces" ))
3903
+
3904
+ if conn , err := Connect (server , opts ); err != nil {
3905
+ if err .Error () != "concurrent schema update" {
3906
+ t .Errorf ("unexpected error: %s" , err )
3907
+ }
3908
+ } else if conn == nil {
3909
+ t .Errorf ("conn is nil" )
3910
+ } else {
3911
+ conn .Close ()
3912
+ }
3913
+
3914
+ if _ , err := fut .Get (); err != nil {
3915
+ t .Errorf ("Failed to call create_spaces: %s" , err )
3916
+ }
3917
+ }
3918
+ }
3919
+
3897
3920
// runTestMain is a body of TestMain function
3898
3921
// (see https://pkg.go.dev/testing#hdr-Main).
3899
3922
// Using defer + os.Exit is not works so TestMain body
You can’t perform that action at this time.
0 commit comments