Skip to content

Commit 9648c4f

Browse files
test: change space id range
In Tarantool, user space ids starts from 512. You can set arbitrary id or use autoincrement (sequence also starts from 512). Unfortunately, mixing spaces with autoincremented ids and spaces with explicit ids may cause id conflict [1]. Since there are cases when we cannot explicitly set space id (creating a space with SQL), a short range of free ids (from 512 to 515) causes problems. This patch increases range of free ids (now it's from 512 to 615) so it should be ok until [1] is resolved. 1. tarantool/tarantool#8036 Part of #215
1 parent 265f96c commit 9648c4f

6 files changed

+39
-39
lines changed

config.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ box.cfg{
77

88
box.once("init", function()
99
local st = box.schema.space.create('schematest', {
10-
id = 516,
10+
id = 616,
1111
temporary = true,
1212
if_not_exists = true,
1313
field_count = 7,
@@ -36,7 +36,7 @@ box.once("init", function()
3636
st:truncate()
3737

3838
local s = box.schema.space.create('test', {
39-
id = 517,
39+
id = 617,
4040
if_not_exists = true,
4141
})
4242
s:create_index('primary', {
@@ -46,7 +46,7 @@ box.once("init", function()
4646
})
4747

4848
local s = box.schema.space.create('teststring', {
49-
id = 518,
49+
id = 618,
5050
if_not_exists = true,
5151
})
5252
s:create_index('primary', {
@@ -56,7 +56,7 @@ box.once("init", function()
5656
})
5757

5858
local s = box.schema.space.create('testintint', {
59-
id = 519,
59+
id = 619,
6060
if_not_exists = true,
6161
})
6262
s:create_index('primary', {
@@ -66,7 +66,7 @@ box.once("init", function()
6666
})
6767

6868
local s = box.schema.space.create('SQL_TEST', {
69-
id = 520,
69+
id = 620,
7070
if_not_exists = true,
7171
format = {
7272
{name = "NAME0", type = "unsigned"},
@@ -82,7 +82,7 @@ box.once("init", function()
8282
s:insert{1, "test", "test"}
8383

8484
local s = box.schema.space.create('test_perf', {
85-
id = 521,
85+
id = 621,
8686
temporary = true,
8787
if_not_exists = true,
8888
field_count = 3,
@@ -117,7 +117,7 @@ box.once("init", function()
117117
end
118118

119119
local s = box.schema.space.create('test_error_type', {
120-
id = 522,
120+
id = 622,
121121
temporary = true,
122122
if_not_exists = true,
123123
field_count = 2,

example_custom_unpacking_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func Example_customUnpacking() {
8787
log.Fatalf("Failed to connect: %s", err.Error())
8888
}
8989

90-
spaceNo := uint32(517)
90+
spaceNo := uint32(617)
9191
indexNo := uint32(0)
9292

9393
tuple := Tuple2{Cid: 777, Orig: "orig", Members: []Member{{"lol", "", 1}, {"wut", "", 3}}}

example_test.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func ExampleConnection_Select() {
5151
conn.Replace(spaceNo, []interface{}{uint(1111), "hello", "world"})
5252
conn.Replace(spaceNo, []interface{}{uint(1112), "hallo", "werld"})
5353

54-
resp, err := conn.Select(517, 0, 0, 100, tarantool.IterEq, []interface{}{uint(1111)})
54+
resp, err := conn.Select(617, 0, 0, 100, tarantool.IterEq, []interface{}{uint(1111)})
5555

5656
if err != nil {
5757
fmt.Printf("error in select is %v", err)
@@ -75,7 +75,7 @@ func ExampleConnection_SelectTyped() {
7575
defer conn.Close()
7676
var res []Tuple
7777

78-
err := conn.SelectTyped(517, 0, 0, 100, tarantool.IterEq, tarantool.IntKey{1111}, &res)
78+
err := conn.SelectTyped(617, 0, 0, 100, tarantool.IterEq, tarantool.IntKey{1111}, &res)
7979

8080
if err != nil {
8181
fmt.Printf("error in select is %v", err)
@@ -96,7 +96,7 @@ func ExampleConnection_SelectTyped() {
9696
func ExampleConnection_SelectAsync() {
9797
conn := example_connect(opts)
9898
defer conn.Close()
99-
spaceNo := uint32(517)
99+
spaceNo := uint32(617)
100100

101101
conn.Insert(spaceNo, []interface{}{uint(16), "test", "one"})
102102
conn.Insert(spaceNo, []interface{}{uint(17), "test", "one"})
@@ -223,7 +223,7 @@ func ExampleSelectRequest() {
223223
conn := example_connect(opts)
224224
defer conn.Close()
225225

226-
req := tarantool.NewSelectRequest(517).
226+
req := tarantool.NewSelectRequest(617).
227227
Limit(100).
228228
Key(tarantool.IntKey{1111})
229229
resp, err := conn.Do(req).Get()
@@ -253,7 +253,7 @@ func ExampleUpdateRequest() {
253253
conn := example_connect(opts)
254254
defer conn.Close()
255255

256-
req := tarantool.NewUpdateRequest(517).
256+
req := tarantool.NewUpdateRequest(617).
257257
Key(tarantool.IntKey{1111}).
258258
Operations(tarantool.NewOperations().Assign(1, "bye"))
259259
resp, err := conn.Do(req).Get()
@@ -284,7 +284,7 @@ func ExampleUpsertRequest() {
284284
defer conn.Close()
285285

286286
var req tarantool.Request
287-
req = tarantool.NewUpsertRequest(517).
287+
req = tarantool.NewUpsertRequest(617).
288288
Tuple([]interface{}{uint(1113), "first", "first"}).
289289
Operations(tarantool.NewOperations().Assign(1, "updated"))
290290
resp, err := conn.Do(req).Get()
@@ -305,7 +305,7 @@ func ExampleUpsertRequest() {
305305
}
306306
fmt.Printf("response is %#v\n", resp.Data)
307307

308-
req = tarantool.NewSelectRequest(517).
308+
req = tarantool.NewSelectRequest(617).
309309
Limit(100).
310310
Key(tarantool.IntKey{1113})
311311
resp, err = conn.Do(req).Get()
@@ -830,12 +830,12 @@ func ExampleSchema() {
830830
}
831831

832832
space1 := schema.Spaces["test"]
833-
space2 := schema.SpacesById[516]
833+
space2 := schema.SpacesById[616]
834834
fmt.Printf("Space 1 ID %d %s\n", space1.Id, space1.Name)
835835
fmt.Printf("Space 2 ID %d %s\n", space2.Id, space2.Name)
836836
// Output:
837-
// Space 1 ID 517 test
838-
// Space 2 ID 516 schematest
837+
// Space 1 ID 617 test
838+
// Space 2 ID 616 schematest
839839
}
840840

841841
// Example demonstrates how to retrieve information with space schema.
@@ -854,7 +854,7 @@ func ExampleSpace() {
854854

855855
// Access Space objects by name or ID.
856856
space1 := schema.Spaces["test"]
857-
space2 := schema.SpacesById[516] // It's a map.
857+
space2 := schema.SpacesById[616] // It's a map.
858858
fmt.Printf("Space 1 ID %d %s %s\n", space1.Id, space1.Name, space1.Engine)
859859
fmt.Printf("Space 1 ID %d %t\n", space1.FieldsCount, space1.Temporary)
860860

@@ -875,7 +875,7 @@ func ExampleSpace() {
875875
fmt.Printf("SpaceField 2 %s %s\n", spaceField2.Name, spaceField2.Type)
876876

877877
// Output:
878-
// Space 1 ID 517 test memtx
878+
// Space 1 ID 617 test memtx
879879
// Space 1 ID 0 false
880880
// Index 0 primary
881881
// &{0 unsigned} &{2 string}

multi/config.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ rawset(_G, 'get_cluster_nodes', get_cluster_nodes)
1313

1414
box.once("init", function()
1515
local s = box.schema.space.create('test', {
16-
id = 517,
16+
id = 617,
1717
if_not_exists = true,
1818
})
1919
s:create_index('primary', {type = 'tree', parts = {1, 'string'}, if_not_exists = true})
@@ -22,7 +22,7 @@ box.once("init", function()
2222
box.schema.user.grant('test', 'read,write,execute', 'universe')
2323

2424
local sp = box.schema.space.create('SQL_TEST', {
25-
id = 521,
25+
id = 621,
2626
if_not_exists = true,
2727
format = {
2828
{name = "NAME0", type = "unsigned"},

multi/multi_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
var server1 = "127.0.0.1:3013"
1818
var server2 = "127.0.0.1:3014"
19-
var spaceNo = uint32(517)
19+
var spaceNo = uint32(617)
2020
var spaceName = "test"
2121
var indexNo = uint32(0)
2222
var connOpts = tarantool.Opts{

tarantool_test.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func convertUint64(v interface{}) (result uint64, err error) {
9999
}
100100

101101
var server = "127.0.0.1:3013"
102-
var spaceNo = uint32(517)
102+
var spaceNo = uint32(617)
103103
var spaceName = "test"
104104
var indexNo = uint32(0)
105105
var indexName = "primary"
@@ -1776,29 +1776,29 @@ func TestSchema(t *testing.T) {
17761776
}
17771777
var space, space2 *Space
17781778
var ok bool
1779-
if space, ok = schema.SpacesById[516]; !ok {
1780-
t.Errorf("space with id = 516 was not found in schema.SpacesById")
1779+
if space, ok = schema.SpacesById[616]; !ok {
1780+
t.Errorf("space with id = 616 was not found in schema.SpacesById")
17811781
}
17821782
if space2, ok = schema.Spaces["schematest"]; !ok {
17831783
t.Errorf("space with name 'schematest' was not found in schema.SpacesById")
17841784
}
17851785
if space != space2 {
1786-
t.Errorf("space with id = 516 and space with name schematest are different")
1786+
t.Errorf("space with id = 616 and space with name schematest are different")
17871787
}
1788-
if space.Id != 516 {
1789-
t.Errorf("space 516 has incorrect Id")
1788+
if space.Id != 616 {
1789+
t.Errorf("space 616 has incorrect Id")
17901790
}
17911791
if space.Name != "schematest" {
1792-
t.Errorf("space 516 has incorrect Name")
1792+
t.Errorf("space 616 has incorrect Name")
17931793
}
17941794
if !space.Temporary {
1795-
t.Errorf("space 516 should be temporary")
1795+
t.Errorf("space 616 should be temporary")
17961796
}
17971797
if space.Engine != "memtx" {
1798-
t.Errorf("space 516 engine should be memtx")
1798+
t.Errorf("space 616 engine should be memtx")
17991799
}
18001800
if space.FieldsCount != 7 {
1801-
t.Errorf("space 516 has incorrect fields count")
1801+
t.Errorf("space 616 has incorrect fields count")
18021802
}
18031803

18041804
if space.FieldsById == nil {
@@ -1908,20 +1908,20 @@ func TestSchema(t *testing.T) {
19081908
}
19091909

19101910
var rSpaceNo, rIndexNo uint32
1911-
rSpaceNo, rIndexNo, err = schema.ResolveSpaceIndex(516, 3)
1912-
if err != nil || rSpaceNo != 516 || rIndexNo != 3 {
1911+
rSpaceNo, rIndexNo, err = schema.ResolveSpaceIndex(616, 3)
1912+
if err != nil || rSpaceNo != 616 || rIndexNo != 3 {
19131913
t.Errorf("numeric space and index params not resolved as-is")
19141914
}
1915-
rSpaceNo, _, err = schema.ResolveSpaceIndex(516, nil)
1916-
if err != nil || rSpaceNo != 516 {
1915+
rSpaceNo, _, err = schema.ResolveSpaceIndex(616, nil)
1916+
if err != nil || rSpaceNo != 616 {
19171917
t.Errorf("numeric space param not resolved as-is")
19181918
}
19191919
rSpaceNo, rIndexNo, err = schema.ResolveSpaceIndex("schematest", "secondary")
1920-
if err != nil || rSpaceNo != 516 || rIndexNo != 3 {
1920+
if err != nil || rSpaceNo != 616 || rIndexNo != 3 {
19211921
t.Errorf("symbolic space and index params not resolved")
19221922
}
19231923
rSpaceNo, _, err = schema.ResolveSpaceIndex("schematest", nil)
1924-
if err != nil || rSpaceNo != 516 {
1924+
if err != nil || rSpaceNo != 616 {
19251925
t.Errorf("symbolic space param not resolved")
19261926
}
19271927
_, _, err = schema.ResolveSpaceIndex("schematest22", "secondary")

0 commit comments

Comments
 (0)