Skip to content
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

Crud errors after space drop in migrations #308

Closed
iDneprov opened this issue Jul 11, 2022 · 6 comments · Fixed by #309
Closed

Crud errors after space drop in migrations #308

iDneprov opened this issue Jul 11, 2022 · 6 comments · Fixed by #309
Assignees
Labels
bug Something isn't working

Comments

@iDneprov
Copy link

iDneprov commented Jul 11, 2022

If you call box.space.space_name:drop() in migrations. Then during operations applied to other spaces on crud 0.10.0 and newer an error appears.
If you change crud version to 0.9.0, everything works again.

Reproducer

Error example:

localhost:3301> crud.select('trm_1')
---
- null
- line: 181
  class_name: CallError
  err: 'Failed for 275e2b29-64ba-470e-9a4e-18153132f465: Function returned an error:
    {"base_type":"LuajitError","type":"LuajitError","message":"...are\/tarantool\/crud\/common\/sharding\/sharding_metadata.lua:61:
    attempt to index a nil value","trace":[{"file":"\/opt\/actions-runners\/sdk_01\/_work\/sdk\/sdk\/tarantool-2.8\/src\/lua\/utils.c","line":449}]}'
  file: '...ktop/vtb-dws/.rocks/share/tarantool/crud/common/call.lua'
  stack: "stack traceback:\n\t...ktop/vtb-dws/.rocks/share/tarantool/crud/common/call.lua:181:
    in function 'any'\n\t...are/tarantool/crud/common/sharding/sharding_metadata.lua:97:
    in function <...are/tarantool/crud/common/sharding/sharding_metadata.lua:90>\n\t[C]:
    in function 'pcall'\n\t...are/tarantool/crud/common/sharding/sharding_metadata.lua:37:
    in function '_fetch_on_router'\n\t...are/tarantool/crud/common/sharding/sharding_metadata.lua:133:
    in function 'fetch_sharding_key_on_router'\n\t...dws/.rocks/share/tarantool/crud/select/compat/select.lua:63:
    in function 'func'\n\t...op/vtb-dws/.rocks/share/tarantool/crud/common/schema.lua:88:
    in function 'wrap_func_reload'\n\t...dws/.rocks/share/tarantool/crud/select/compat/select.lua:288:
    in function <...dws/.rocks/share/tarantool/crud/select/compat/select.lua:251>\n\t[C]:
    in function 'pcall'\n\t...dws/.rocks/share/tarantool/crud/common/sharding/init.lua:163:
    in function <...dws/.rocks/share/tarantool/crud/common/sharding/init.lua:158>\n\t[C]:
    in function 'xpcall'\n\t...neprov/Desktop/vtb-dws/.rocks/share/tarantool/errors.lua:145:
    in function <...neprov/Desktop/vtb-dws/.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 0x0109c56660"
  str: 'CallError: Failed for 275e2b29-64ba-470e-9a4e-18153132f465: Function returned
    an error: {"base_type":"LuajitError","type":"LuajitError","message":"...are\/tarantool\/crud\/common\/sharding\/sharding_metadata.lua:61:
    attempt to index a nil value","trace":[{"file":"\/opt\/actions-runners\/sdk_01\/_work\/sdk\/sdk\/tarantool-2.8\/src\/lua\/utils.c","line":449}]}'
...
@no1seman
Copy link

no1seman commented Jul 11, 2022

+1 If any space dropped - crud 0.10.0+ fails to work with the same error. Seems that there is a problem in triggers on box.space._space

@no1seman no1seman added the bug Something isn't working label Jul 11, 2022
@DifferentialOrange
Copy link
Member

At the first glance, it seems that the reason is that space is dropped, but its sharding info is not cleaned up. So, as a workaround, I suggest you to do a proper ddl space drop.

@no1seman
Copy link

yea, right you are but why not add a check that space was dropped and not take any sharding info into account?

It's quite common problem, because ddl and migrations doesn't contain any high level helpers to unregister sharding keys, so nobody do it in real life.

DifferentialOrange added a commit that referenced this issue Jul 19, 2022
Before this patch, in case there is a sharding key record
in _ddl_sharding_key for a non-existing space (for example, if ddl space
wasn't properly dropped) and sharding info needs to be updated, any crud
request will fail with "attempt to index a nil value" error. This patch
fixes the behavior and adds a log warning if ddl configuration is
invalid.

Closes #308
@DifferentialOrange
Copy link
Member

yea, right you are but why not add a check that space was dropped and not take any sharding info into account?

It's quite common problem, because ddl and migrations doesn't contain any high level helpers to unregister sharding keys, so nobody do it in real life.

Yes, we will definitely fix it in a patch.

@no1seman
Copy link

Here is an example of consequences of our API: https://t.me/tarantoolru/188981

User can't clean __ddl_sharding_key and thus can't continue to use crud

@DifferentialOrange
Copy link
Member

DifferentialOrange commented Jul 20, 2022

Here is an example of consequences of our API: https://t.me/tarantoolru/188981

User can't clean __ddl_sharding_key and thus can't continue to use crud

Yeah, I already saw that one. Refer to #310 ticket. Solutions for this issue and #310 one are already prepared. After review, we will merge them to master and publish a bugfix release 0.12.1 (it shouldn't be too long).

DifferentialOrange added a commit that referenced this issue Jul 21, 2022
Overview

    This is a bugfix release. It introduces several fixes related
    to crud and ddl module integration.

Breaking changes

    There are no breaking changes in the release.

Bugfixes

    * Fetching invalid ddl configuration (sharding key for non-existing
    space) is no longer breaks CRUD requests (#308, PR #309).
    * ddl space record delete no more throws error if crud
    is used (#310, PR #311).
    * crud sharding metainfo is now updated on ddl record
    delete (#310, PR #311).
DifferentialOrange added a commit that referenced this issue Jul 21, 2022
Overview

    This is a bugfix release. It introduces several fixes related
    to crud and ddl module integration.

Breaking changes

    There are no breaking changes in the release.

Bugfixes

    * Fetching invalid ddl configuration (sharding key for non-existing
    space) is no longer breaks CRUD requests (#308, PR #309).
    * ddl space record delete no more throws error if crud
    is used (#310, PR #311).
    * crud sharding metainfo is now updated on ddl record
    delete (#310, PR #311).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants