Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.

### Fixed

- `unable to use an index name because schema is not loaded` error after
a reconnect (#424).

## [v2.2.0] - 2024-12-16

The release introduces the IPROTO_INSERT_ARROW request (arrow.InsertRequest)
Expand Down
9 changes: 5 additions & 4 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,13 @@ func (conn *Connection) dial(ctx context.Context) error {
conn.Greeting.Salt = connGreeting.Salt
conn.serverProtocolInfo = c.ProtocolInfo()

spaceAndIndexNamesSupported :=
isFeatureInSlice(iproto.IPROTO_FEATURE_SPACE_AND_INDEX_NAMES,
if conn.schemaResolver == nil {
namesSupported := isFeatureInSlice(iproto.IPROTO_FEATURE_SPACE_AND_INDEX_NAMES,
conn.serverProtocolInfo.Features)

conn.schemaResolver = &noSchemaResolver{
SpaceAndIndexNamesSupported: spaceAndIndexNamesSupported,
conn.schemaResolver = &noSchemaResolver{
SpaceAndIndexNamesSupported: namesSupported,
}
}

// Watchers.
Expand Down
55 changes: 55 additions & 0 deletions tarantool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3868,6 +3868,61 @@ func TestWatcher_Unregister_concurrent(t *testing.T) {
wg.Wait()
}

func TestConnection_named_index_after_reconnect(t *testing.T) {
const server = "127.0.0.1:3015"

testDialer := dialer
testDialer.Address = server

inst, err := test_helpers.StartTarantool(test_helpers.StartOpts{
Dialer: testDialer,
InitScript: "config.lua",
Listen: server,
WaitStart: 100 * time.Millisecond,
ConnectRetry: 10,
RetryTimeout: 500 * time.Millisecond,
})
defer test_helpers.StopTarantoolWithCleanup(inst)
if err != nil {
t.Fatalf("Unable to start Tarantool: %s", err)
}

reconnectOpts := opts
reconnectOpts.Reconnect = 100 * time.Millisecond
reconnectOpts.MaxReconnects = 10

conn := test_helpers.ConnectWithValidation(t, testDialer, reconnectOpts)
defer conn.Close()

test_helpers.StopTarantool(inst)

request := NewSelectRequest("test").Index("primary").Limit(1)
_, err = conn.Do(request).Get()
if err == nil {
t.Fatalf("An error expected.")
}

if err := test_helpers.RestartTarantool(&inst); err != nil {
t.Fatalf("Unable to restart Tarantool: %s", err)
}

maxTime := reconnectOpts.Reconnect * time.Duration(reconnectOpts.MaxReconnects)
timeout := time.After(maxTime)

for {
select {
case <-timeout:
t.Fatalf("Failed to execute request without an error, last error: %s", err)
default:
}

_, err = conn.Do(request).Get()
if err == nil {
return
}
}
}

func TestConnect_schema_update(t *testing.T) {
conn := test_helpers.ConnectWithValidation(t, dialer, opts)
defer conn.Close()
Expand Down
Loading