Skip to content

Exception on connection to server with foreign_key #282

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
sergeybe opened this issue Feb 24, 2023 · 2 comments · Fixed by #285
Closed

Exception on connection to server with foreign_key #282

sergeybe opened this issue Feb 24, 2023 · 2 comments · Fixed by #285
Assignees
Labels
bug Something isn't working

Comments

@sergeybe
Copy link

I'm trying to run the next simple server code with foreign_key:

box.cfg{listen = 3301}

box.once("some_bug", function()
    box.schema.user.grant('guest', 'read,write,execute,create,alter,drop,usage,session', 'universe')

    table1 = box.schema.space.create('table1')
    table1:format({
        { name = 'id', type = 'integer' },
        { name = 'title', type = 'string' },
    })

    table2 = box.schema.space.create('videohash')
    table2:format({
        { name = 'id', type = 'integer' },
        { name = 'table1_id', type = 'integer', 
          foreign_key = { fk_video = { space = 'table1', field = 'id' }} },   -- Problem line here
        { name = 'name', type = 'string' },
    })
end)

require('console').start()

Then I'm trying to run:

% python
Python 3.11.2 (main, Feb 16 2023, 03:07:35) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tarantool
>>> connection = tarantool.Connection('localhost', 3301)
Traceback (most recent call last):
  File "/Users/user/.virtualenvs/test1/lib/python3.11/site-packages/tarantool/schema.py", line 163, in __init__
    format_raw = to_unicode_recursive(space_row[6], 3)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/.virtualenvs/test1/lib/python3.11/site-packages/tarantool/schema.py", line 74, in to_unicode_recursive
    val = to_unicode_recursive(val, max_depth - 1)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/.virtualenvs/test1/lib/python3.11/site-packages/tarantool/schema.py", line 67, in to_unicode_recursive
    val = to_unicode_recursive(val, max_depth - 1)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/.virtualenvs/test1/lib/python3.11/site-packages/tarantool/schema.py", line 66, in to_unicode_recursive
    key = to_unicode_recursive(key, max_depth - 1)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/.virtualenvs/test1/lib/python3.11/site-packages/tarantool/schema.py", line 61, in to_unicode_recursive
    raise RecursionError('Max recursion depth is reached')
tarantool.schema.RecursionError: Max recursion depth is reached

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/.virtualenvs/test1/lib/python3.11/site-packages/tarantool/connection.py", line 1042, in connect
    self.load_schema()
  File "/Users/user/.virtualenvs/test1/lib/python3.11/site-packages/tarantool/connection.py", line 1261, in load_schema
    self.schema.fetch_space_all()
  File "/Users/user/.virtualenvs/test1/lib/python3.11/site-packages/tarantool/schema.py", line 299, in fetch_space_all
    SchemaSpace(row, self.schema)
  File "/Users/user/.virtualenvs/test1/lib/python3.11/site-packages/tarantool/schema.py", line 166, in __init__
    raise SchemaError(errmsg)
tarantool.error.SchemaError: Unexpected space format structure: Max recursion depth is reached

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/user/.virtualenvs/test1/lib/python3.11/site-packages/tarantool/connection.py", line 812, in __init__
    self.connect()
  File "/Users/user/.virtualenvs/test1/lib/python3.11/site-packages/tarantool/connection.py", line 1049, in connect
    raise NetworkError(e)
tarantool.error.NetworkError: Unexpected space format structure: Max recursion depth is reached
>>>

When I comment the line with foreign_key my code can connect without problem.
Please help.

@DifferentialOrange DifferentialOrange added bug Something isn't working teamE labels Feb 27, 2023
@DifferentialOrange DifferentialOrange self-assigned this Feb 27, 2023
@DifferentialOrange
Copy link
Member

DifferentialOrange commented Feb 27, 2023

Thank you for the issue. It seems like a bug, I'll dig deeper a bit later.

@Totktonada
Copy link
Member

Totktonada commented Feb 27, 2023

Seems like this tight recursion limit (my bad idea) plays poor in terms of compatibility with future tarantool versions. I think there should be some limit, but not a such tight one.

DifferentialOrange added a commit that referenced this issue Feb 27, 2023
Before this patch, only schemas with 3-level nesting were expected.
Simple foreign keys schema has 4-level nesting. After this patch,
nesting depth up to 32 is supported. (There are no known schemas with
such nesting, but this should be enough for any future extensions.)

Closes #282
DifferentialOrange added a commit that referenced this issue Feb 27, 2023
Before this patch, only schemas with 3-level nesting were expected.
Simple foreign keys schema has 4-level nesting. After this patch,
nesting depth up to 32 is supported. (There are no known schemas with
such nesting, but this should be enough for any future extensions.)

Closes #282
DifferentialOrange added a commit that referenced this issue Feb 27, 2023
Before this patch, only schemas with 3-level nesting were expected.
Simple foreign keys schema has 4-level nesting. After this patch,
nesting depth up to 32 is supported. (There are no known schemas with
such nesting, but this should be enough for any future extensions.)

Closes #282
DifferentialOrange added a commit that referenced this issue Feb 27, 2023
Before this patch, only schemas with 3-level nesting were expected.
Simple foreign keys schema has 4-level nesting. After this patch,
nesting depth up to 32 is supported. (There are no known schemas with
such nesting, but this should be enough for any future extensions.)

Closes #282
DifferentialOrange added a commit that referenced this issue Feb 28, 2023
Before this patch, only schemas with 3-level nesting were expected.
Simple foreign keys schema has 4-level nesting. After this patch,
nesting depth up to 32 is supported. (There are no known schemas with
such nesting, but this should be enough for any future extensions.)

Closes #282
DifferentialOrange added a commit that referenced this issue Feb 28, 2023
Overview

  This release introduces several bug fixes and behavior improvements.

Breaking changes

  This release should not break any existing behavior.

Bugfixes
  - Discovery iproto features only for Tarantools since version
    2.10.0 (#283).
  - Schema fetch for spaces with foreign keys (#282).
DifferentialOrange added a commit that referenced this issue Feb 28, 2023
Overview

  This release introduces several bug fixes and behavior improvements.

Breaking changes

  This release should not break any existing behavior.

Bugfixes
  - Discovery iproto features only for Tarantools since version
    2.10.0 (#283).
  - Schema fetch for spaces with foreign keys (#282).
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