edgedb-cli icon indicating copy to clipboard operation
edgedb-cli copied to clipboard

Edgedb dump -> restore onto non-empty database with only extensions isn't rejected

Open quinchs opened this issue 3 years ago • 5 comments

  • EdgeDB Version: 1.3+5d0197d
  • OS Version: Windows 10

When dumping a database whos schema uses an extension, the returned binary file cannot be used to restore.

Steps to Reproduce:

  1. create a new empty instance

  2. run edgedb dump ./dump.bin

  3. run edgedb restore dump.bin above steps should work as expected

  4. add a using extension .. to the schema and migrate the database

  5. run step 2 and 3

with testing this im using the edgeql_http extension

Retuned error
edgedb error: SchemaError: error initiating restore protocol: Extension ('cb78b832-d624-11ec-b010-f3789a0548ba') is already present in the schema <FlatSchema gen:2 at 0x7f7c9395ff40>
Server traceback:
    Traceback (most recent call last):
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/server/compiler_pool/worker.py", line 309, in worker
        res = meth(*args)
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 2450, in describe_database_restore
        units = self._compile(ctx=ctx, source=ddl_source)
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 1667, in _compile
        return self._try_compile(ctx=ctx, source=source)
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 1720, in _try_compile
        comp, capabilities = self._compile_dispatch_ql(
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 1614, in _compile_dispatch_ql
        self._compile_and_apply_ddl_stmt(ctx, ql, source=source),
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 793, in _compile_and_apply_ddl_stmt
        delta = s_ddl.delta_from_ddl(
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/schema/ddl.py", line 581, in delta_from_ddl
        _, cmd = _delta_from_ddl(
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/schema/ddl.py", line 628, in _delta_from_ddl
        schema = cmd.apply(schema, context)
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/schema/delta.py", line 2977, in apply
        schema = self._create_begin(schema, context)
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/schema/delta.py", line 2878, in _create_begin
        schema, self.scls = metaclass.create_in_schema(schema, **props)
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/schema/objects.py", line 1131, in create_in_schema
        schema = schema.add(id, cls, tuple(obj_data))
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/schema/schema.py", line 1558, in add
        self._top_schema.add(id, sclass, data),
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/schema/schema.py", line 963, in add
        return self.add_raw(id, sclass, data)
      File "/home/edgedb/.local/share/edgedb/portable/1.4/lib/python3.10/site-packages/edb/schema/schema.py", line 910, in add_raw
        raise errors.SchemaError(
    edb.errors.SchemaError: Extension ('cb78b832-d624-11ec-b010-f3789a0548ba') is already present in the schema <FlatSchema gen:2 at 0x7f7c9395ff40>

Schema:

using extension edgeql_http;

module default {

}

quinchs avatar May 17 '22 21:05 quinchs

Hmm. Is there a chance you're restoring into a non-empty database? The bug seems to be that the CLI fails to recognize that the schema is non-empty.

elprans avatar May 17 '22 21:05 elprans

running the above steps on a clean empty database causes the error so I don't think so

quinchs avatar May 18 '22 07:05 quinchs

I couldn't reproduce. Steps (as written) attempt restore twice into the same db, no?

elprans avatar May 18 '22 16:05 elprans

yes

quinchs avatar May 18 '22 20:05 quinchs

I think that Elvis is correct here: the second restore is trying to restore onto a non-empty database, which I think we typically try to reject in the CLI.

msullivan avatar Apr 30 '24 00:04 msullivan