Skip to content

[4pt] Upgrade crud from 0.5.0 to 0.6.0 getting a error with same handler #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
seet61 opened this issue Apr 1, 2021 · 2 comments
Closed
Assignees

Comments

@seet61
Copy link

seet61 commented Apr 1, 2021

We have app with http server and spaces.

Wheh we upgrade crud from 0.5.0 to 0.6.0 getting a error with same handler for http method.

-- country_list
        local country_list_space = box.schema.space.create('country_list', {
            engine = 'memtx',
            if_not_exists = true,
        })
        log.info('country_list space was configured')

        country_list_space:format({
            {name='Alfa2',type='string'},
            {name='Alfa3',type='string'},
            {name='Numeric',type='string'},
            {name='VAS',type='unsigned'},
            {name='Name',type='string'},
            {name='ttl',type='unsigned'},
            {name='bucket_id', type='unsigned'},
        })
        log.info('country_list was formatted')

        country_list_space:create_index('country_list_Alfa2_idx', {parts={{field='Alfa2'}},
            if_not_exists=true})
        log.info('country_list_Alfa2_idx')

        country_list_space:create_index('country_list_Alfa3_idx', {parts={{field='Alfa3'}},
            if_not_exists=true})
        log.info('country_list_Alfa3_idx')

        country_list_space:create_index('country_list_Numeric_idx', {parts={{field='Numeric'}},
            unique=false,
            if_not_exists=true})
        log.info('country_list_Numeric_idx')

        country_list_space:create_index('country_list_VAS_idx', {parts={{field='VAS'}},
            unique=false,
            if_not_exists=true})
        log.info('country_list_VAS_idx')

        country_list_space:create_index('bucket_id', {parts={{field='bucket_id'}},
            unique=false,
            if_not_exists=true})
        log.info('country_list_bucket_id')

        country_list_space:create_index('ttl', {parts={{field='ttl'}},
            unique=false,
            if_not_exists=true})
        log.info('country_list_ttl')

Http request:

POST /v1/cache/readByIndex HTTP/1.1
Host: 10.78.221.224:8086
Content-Type: application/json
Content-Length: 72

{"filter":"RUS","index":"country_list_Alfa3_idx","space":"country_list"}

At handler:

-- Read value from space by index
local function read_value_by_index(self)
    log.info('read_value_by_index request: ' .. tostring(self));
    log.info('read_value_by_index body: ' .. json.encode(self:json()))
....
    local args = self:json()
    local space = args.space
    local index = args.index
    local filter = args.filter
....
    log.debug('read_value_by_index: ' .. space .. " " .. index .. " " .. filter)
    local value, err = crud.select(space, {{'==', index, filter}}, {timeout = 5}) ---- handlers.lua:421: this row
    local response
    if err ~= nil then
<------>response = self:render({json = { filter = filter, message = err }})
<------>response.status = 400
    elseif #value.rows == 0 then
<------>response = self:render({json = { filter = filter }})
<------>response.status = 404
    else
<------>value = get_object(value.metadata, value.rows[1])
<------>log.debug('read_value_by_index value: ' .. json.encode(value))
<------>response = self:render({
<------>    json = value
<------>})
    end
....
    log.info('read_value_by_index response: ' .. json.encode(response))
    return response
end

At logs:

{"time": "2021-04-01T10:26:50.334+0300", "level": "INFO", "message": "read_value_by_index body: {\"filter\":\"RUS\",\"space\":\"country_list\",\"index\":\"country_list_Alfa3_idx\"}", "pid": 848 , "cord_name": "main", "fiber_id": 136157, "fiber_name": "http\/10.12.75.136:39966", "file": "\/usr\/share\/tarantool\/tarantool_cache\/app\/roles\/handlers.lua", "line": 413}
{"time": "2021-04-01T10:26:50.336+0300", "level": "INFO", "message": "read_value_by_index response: {\"status\":400,\"body\":\"{\\\"filter\\\":\\\"RUS\\\",\\\"message\\\":{\\\"line\\\":223,\\\"class_name\\\":\\\"SelectError\\\",\\\"err\\\":\\\"Tuple field 4 type does not match one required by operation: expected string\\\",\\\"file\\\":\\\"...che\\\\\\\/.rocks\\\\\\\/share\\\\\\\/tarantool\\\\\\\/crud\\\\\\\/select\\\\\\\/compat\\\\\\\/select.lua\\\",\\\"stack\\\":\\\"stack traceback:\\\\n\\\\t...che\\\\\\\/.rocks\\\\\\\/share\\\\\\\/tarantool\\\\\\\/crud\\\\\\\/select\\\\\\\/compat\\\\\\\/select.lua:223: in function <...che\\\\\\\/.rocks\\\\\\\/share\\\\\\\/tarantool\\\\\\\/crud\\\\\\\/select\\\\\\\/compat\\\\\\\/select.lua:175>\\\\n\\\\t[C]: in function 'xpcall'\\\\n\\\\t...antool\\\\\\\/tarantool_cache\\\\\\\/.rocks\\\\\\\/share\\\\\\\/tarantool\\\\\\\/errors.lua:145: in function 'select'\\\\n\\\\t\\\\\\\/usr\\\\\\\/share\\\\\\\/tarantool\\\\\\\/tarantool_cache\\\\\\\/app\\\\\\\/roles\\\\\\\/handlers.lua:421: in function <\\\\\\\/usr\\\\\\\/share\\\\\\\/tarantool\\\\\\\/tarantool_cache\\\\\\\/app\\\\\\\/roles\\\\\\\/handlers.lua:411>\\\\n\\\\t[C]: in function 'pcall'\\\\n\\\\t...che\\\\\\\/.rocks\\\\\\\/share\\\\\\\/tarantool\\\\\\\/metrics\\\\\\\/collectors\\\\\\\/shared.lua:100: in function 'sub'\\\\n\\\\t...l\\\\\\\/tarantool_cache\\", "pid": 848 , "cord_name": "main", "fiber_id": 136157, "fiber_name": "http\/10.12.75.136:39966", "file": "\/usr\/share\/tarantool\/tarantool_cache\/app\/roles\/handlers.lua", "line": 437}

After downgrade to 0.5.0 everything ok.
Tuple field 4 type does not match one required by operation: expected string. Why?

Tuple field 4 is {name='VAS',type='unsigned'}.

@dokshina dokshina changed the title Upgrade crud from 0.5.0 to 0.6.0 getting a error with same handler [4pt] Upgrade crud from 0.5.0 to 0.6.0 getting a error with same handler Apr 8, 2021
@seet61
Copy link
Author

seet61 commented Apr 15, 2021

# tarantool -version
Tarantool 2.6.2-0-g34d504d
Target: Linux-x86_64-RelWithDebInfo


10.78.221.228:3301> crud.select("country_list", {{'==', "country_list_Alfa3_idx", "RUS"}}, {timeout = 5})
---
- null
- line: 223
  class_name: SelectError
  err: 'Tuple field 4 type does not match one required by operation: expected string'
  file: '...che/.rocks/share/tarantool/crud/select/compat/select.lua'
  stack: "stack traceback:\n\t...che/.rocks/share/tarantool/crud/select/compat/select.lua:223:
    in function <...che/.rocks/share/tarantool/crud/select/compat/select.lua:175>\n\t[C]:
    in function 'xpcall'\n\t...antool/tarantool_cache/.rocks/share/tarantool/errors.lua:145:
    in function <...antool/tarantool_cache/.rocks/share/tarantool/errors.lua:139>\n\t[C]:
    in function 'pcall'\n\tbuiltin/box/console.lua:402: in function <builtin/box/console.lua:378>\n\t[C]:
    at 0x004ee0a0"
  str: 'SelectError: Tuple field 4 type does not match one required by operation:
    expected string'
...

Same problem.

We have problem only at test cluster with load.

At dev zone no such problem.

@olegrok
Copy link
Contributor

olegrok commented May 25, 2021

I assume it was related to tarantool/metrics#235. Feel free to reopen if problem exists after metrics upgrade.

@olegrok olegrok closed this as completed May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants