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

Attempting to drop a database which was created with dolt_clone fails. #7106

Closed
reltuk opened this issue Dec 6, 2023 · 1 comment · Fixed by #7107
Closed

Attempting to drop a database which was created with dolt_clone fails. #7106

reltuk opened this issue Dec 6, 2023 · 1 comment · Fixed by #7107
Labels
bug Something isn't working customer issue

Comments

@reltuk
Copy link
Contributor

reltuk commented Dec 6, 2023

Running the following script:

mkdir droptest
cd droptest
dolt init
dolt remote add pushed 'file://../pushed'
dolt push pushed main:main
dolt sql -q 'call dolt_clone("file://../pushed", "cloned"); drop database cloned;'

Results in:

error on line 1 for query  drop database cloned: database not found: cloned
WARN[0000] journal writer has already been closed (/Users/aaronson/dolttest/droptest/cloned/.dolt/noms/vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv) 
panic: Close() called and reduced ref count to < 0.

goroutine 1 [running]:
github.com/dolthub/dolt/go/store/nbs.onHeapTableIndex.Close({{0x14000b4c640, 0x18, 0x4c}, {0x14000af0210, 0x8, 0x8}, {0x14000b4c658, 0x8, 0x34}, {0x14000b4c660, ...}, ...})
	/Users/aaronson/src/dolt/go/store/nbs/table_index.go:528 +0xe0
github.com/dolthub/dolt/go/store/nbs.tableReader.close({{0x14000af0220, 0x2, 0x2}, {0x107434390, 0x140008d9130}, {0x1073a81b0, 0x140000a24a0}, 0x1000})
	/Users/aaronson/src/dolt/go/store/nbs/table_reader.go:691 +0x48
github.com/dolthub/dolt/go/store/nbs.tableSet.close({0x0, 0x14000aa3c20, {0x1073b84a8, 0x1400019f140}, {0x1073a0fa0, 0x14000122340}, 0x140000b84e0})
	/Users/aaronson/src/dolt/go/store/nbs/table_set.go:277 +0x100
github.com/dolthub/dolt/go/store/nbs.(*NomsBlockStore).Close(0x1400019c160)
	/Users/aaronson/src/dolt/go/store/nbs/store.go:1307 +0x9c
github.com/dolthub/dolt/go/store/nbs.(*GenerationalNBS).Close(0x14000e6e190)
	/Users/aaronson/src/dolt/go/store/nbs/generational_chunk_store.go:229 +0x40
github.com/dolthub/dolt/go/store/types.(*ValueStore).Close(...)
	/Users/aaronson/src/dolt/go/store/types/value_store.go:799
github.com/dolthub/dolt/go/store/datas.(*database).Close(0x14000a35730?)
	/Users/aaronson/src/dolt/go/store/datas/database_common.go:267 +0x2c
github.com/dolthub/dolt/go/libraries/doltcore/dbfactory.CloseAllLocalDatabases()
	/Users/aaronson/src/dolt/go/libraries/doltcore/dbfactory/file.go:73 +0x138
main.runMain()
	/Users/aaronson/src/dolt/go/cmd/dolt/dolt.go:604 +0x2410
main.main()
	/Users/aaronson/src/dolt/go/cmd/dolt/dolt.go:238 +0x1c

Similarly, the results from the following point to some state in the cloned database being wrong:

mkdir droptest
cd droptest
dolt init
dolt remote add pushed 'file://../pushed'
dolt push pushed main:main
dolt sql-server &
sleep 1
dolt sql -q 'call dolt_clone("file://../pushed", "cloned"); drop database cloned;'
sleep 1
dolt sql -q 'use cloned; drop database cloned;'
sleep 1
kill %1

The first query does returns

error on line 1 for query  drop database cloned: Error 1105 (HY000): database not found: cloned

The second query recovers a panic in *DoltDatabaseProvider.Close()

And then the sql-server itself panics on shutdown, same as the dolt sql invocation.

@reltuk
Copy link
Contributor Author

reltuk commented Dec 6, 2023

Tracked this down to a divergence in create database behavior inside DatabaseProvider for a new database:

https://github.com/dolthub/dolt/blob/main/go/libraries/doltcore/sqle/database_provider.go#L662

vs. a cloned database:

https://github.com/dolthub/dolt/blob/main/go/libraries/doltcore/sqle/database_provider.go#L540

When we drop the database, we end up closing it and then returning an error. Then further attempts to drop the database panic with the invariant violation. I'll have a PR out today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working customer issue
Projects
None yet
2 participants