dolt icon indicating copy to clipboard operation
dolt copied to clipboard

dolt panic when using cli from dbs directory

Open dphil opened this issue 1 year ago • 1 comments

I have a directory (~/dolt) containing one db (~/dolt/mydb), which was created using the new format (DOLT_DEFAULT_BIN_FORMAT=__DOLT_1__ dolt init). I was using dolt 0.40.19 for creation of that db. I just upgraded to 0.40.20, by running the installation script from the ~/dolt dir. I then found that running any dolt (0.40.20) cli commands from ~/dolt results in:

panic: runtime error: slice bounds out of range [:96276] with capacity 379

goroutine 1 [running]:
github.com/dolthub/dolt/go/store/types.(*binaryNomsReader).readSerialMessage(...)
	/src/store/types/codec.go:338
github.com/dolthub/dolt/go/store/types.SerialMessage.readFrom(...)
	/src/store/types/serial_message.go:403
github.com/dolthub/dolt/go/store/types.(*valueDecoder).readValue(0xc0004f32c0, 0xc0004f32c0?)
	/src/store/types/value_decoder.go:430 +0xc2c
github.com/dolthub/dolt/go/store/types.decodeFromBytes({0xc0008be600, 0x17b, 0x17b}, {0x21904d0, 0xc00002a280})
	/src/store/types/codec.go:57 +0x105
github.com/dolthub/dolt/go/store/types.DecodeValue({{0xff, 0x48, 0xc1, 0xc4, 0x4f, 0x5e, 0x6, 0xe4, 0xb3, 0x94, ...}, ...}, ...)
	/src/store/types/codec.go:83 +0xac
github.com/dolthub/dolt/go/store/types.(*ValueStore).ReadValue(0xc00002a280, {0x218fe40, 0xc000126000}, {0xff, 0x48, 0xc1, 0xc4, 0x4f, 0x5e, 0x6, ...})
	/src/store/types/value_store.go:216 +0x388
github.com/dolthub/dolt/go/store/datas.(*database).loadDatasetsRefmap(0xc0002d55c0, {0x218fe40, 0xc000126000}, {0xff, 0x48, 0xc1, 0xc4, 0x4f, 0x5e, 0x6, ...})
	/src/store/datas/database_common.go:107 +0x105
github.com/dolthub/dolt/go/store/datas.(*database).Datasets(0xc0002d55c0, {0x218fe40, 0xc000126000})
	/src/store/datas/database_common.go:156 +0x165
github.com/dolthub/dolt/go/store/datas.(*database).GetDataset(0xc0006dd560?, {0x218fe40, 0xc000126000}, {0xc0005aa540, 0x16})
	/src/store/datas/database_common.go:179 +0x192
github.com/dolthub/dolt/go/libraries/doltcore/doltdb.(*DoltDB).ResolveWorkingSet(0xc000502c30, {0x218fe40, 0xc000126000}, {{0xc0005a9760?, 0x8?}})
	/src/libraries/doltcore/doltdb/doltdb.go:361 +0xd4
github.com/dolthub/dolt/go/libraries/doltcore/env.WorkingSet({0x218fe40, 0xc000126000}, 0xc00013a4c0?, {0x2192220?, 0xc00000e770?})
	/src/libraries/doltcore/env/environment.go:561 +0x5f
github.com/dolthub/dolt/go/libraries/doltcore/env.(*DoltEnv).WorkingSet(0xc000606d80, {0x218fe40, 0xc000126000})
	/src/libraries/doltcore/env/environment.go:552 +0x6c
github.com/dolthub/dolt/go/libraries/doltcore/env.Load({0x218fe40, 0xc000126000}, 0x1ea9560, {0x21a7e58?, 0xc00051f7e0?}, {0xc0000567f8, 0x13}, {0x1def224, 0x7})
	/src/libraries/doltcore/env/environment.go:164 +0x51e
github.com/dolthub/dolt/go/libraries/doltcore/env.MultiEnvForDirectory.func1({0xc0001245d0?, 0x1de956d?}, 0x40?, 0x0?)
	/src/libraries/doltcore/env/multi_repo_env.go:288 +0xe9
github.com/dolthub/dolt/go/libraries/utils/filesys.(*localFS).Iter(0xc0005aa324?, {0x1de956d?, 0x217040c?}, 0x0, 0xc0004f2a80)
	/src/libraries/utils/filesys/localfs.go:110 +0x1ba
github.com/dolthub/dolt/go/libraries/doltcore/env.MultiEnvForDirectory({0x218fe40?, 0xc000126000}, {0x2197f98?, 0xc0002d4810}, {0x21a7e58?, 0x3521fb0}, {0x1ea97b8?, 0x7?}, 0x0, 0xc000606120)
	/src/libraries/doltcore/env/multi_repo_env.go:276 +0x305
main.runMain()
	/src/cmd/dolt/dolt.go:375 +0x5dd
main.main()
	/src/cmd/dolt/dolt.go:138 +0x19

Even simply dolt version.

Running these commands from other directories does not appear to be an issue. The problem appears to be the presence of the db (~/dolt/mydb). Removing the "mydb" folder allows the cli commands to work normally from the ~/dolt directory.

dphil avatar Jul 27 '22 14:07 dphil

I deleted the db ("mydb") folder, recreated it, reinitialized a new db inside it with: DOLT_DEFAULT_BIN_FORMAT=__DOLT_1__ dolt init and the cli appears to be working normally again from ~/dolt.

So my best guess is that when a cli command is run, it is reading data from any local dbs it finds, and 0.40.20 has some incompatibility with db's created with dolt <0.40.20.

dphil avatar Jul 27 '22 14:07 dphil

This will error not panic now.

We'll track mixing formats in #4077

timsehn avatar Aug 23 '22 23:08 timsehn