cmu-db / peloton

The Self-Driving Database Management System
http://pelotondb.io
Apache License 2.0
2.03k stars 623 forks source link

System crash when creating invalid index on populated table #601

Open AngLi-Leon opened 7 years ago

AngLi-Leon commented 7 years ago

Only if we create an invalid index on a populated table the system will crash. If the table is empty, it handles correctly.

Client:

postgres=# create table foo(a int);
create table foo(a int) 0
postgres=# insert into foo values(1);
insert into foo values(1) 1
postgres=# create index idx on foo(a,b);
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> \q
postgres@vagrant-ubuntu-trusty-64:~$ psql "sslmode=disable" -U postgres -h localhost -p 15721
psql (9.6.2, server 9.5devel)
Type "help" for help.

postgres=# create table foo(a int);
create table foo(a int) 0
postgres=# create index idx on foo(a,b);
create index idx on foo(a,b) 0

Server:

➜  build git:(master) ./bin/peloton
2017-04-02 15:41:33 [src/wire/libevent_server.cpp:49:CreateNewConn] INFO  - create new connection: id = 26
2017-04-02 15:41:33 [src/wire/packet_manager.cpp:65:PacketManager] DEBUG - Registered new PacketManager [count=1]
2017-04-02 15:41:33 [src/wire/libevent_server.cpp:127:LibeventServer] INFO  - Listening on port 15721
2017-04-02 15:41:37 [src/wire/libevent_thread.cpp:117:DispatchConnection] DEBUG - Dispatching connection to worker 0
2017-04-02 15:41:37 [src/wire/libevent_callbacks.cpp:46:WorkerHandleNewConn] DEBUG - Creating new socket fd:27
2017-04-02 15:41:37 [src/wire/libevent_server.cpp:49:CreateNewConn] INFO  - create new connection: id = 27
2017-04-02 15:41:37 [src/wire/packet_manager.cpp:65:PacketManager] DEBUG - Registered new PacketManager [count=2]
2017-04-02 15:41:50 [src/tcop/tcop.cpp:310:PrepareStatement] DEBUG - Statement Prepared: Statement[unnamed] -> create table foo(a int) (TablesRef={}, ReplanNeeded=0, QueryType=create)
Exception Type :: Catalog
Message :: Table 'foo' does not exist
2017-04-02 15:42:08 [src/tcop/tcop.cpp:310:PrepareStatement] DEBUG - Statement Prepared: Statement[unnamed] -> insert into foo values(1) (TablesRef={8}, ReplanNeeded=0, QueryType=insert)
2017-04-02 15:42:19 [src/optimizer/simple_optimizer.cpp:797:CheckIndexSearchable] DEBUG - No suitable index for table 'foo' exists. Skipping...
2017-04-02 15:42:19 [src/tcop/tcop.cpp:310:PrepareStatement] DEBUG - Statement Prepared: Statement[unnamed] -> create index idx on foo(a,b) (TablesRef={8}, ReplanNeeded=0, QueryType=create)
peloton: /vagrant/peloton_upstream/peloton/src/include/storage/tile_group.h:168: void peloton::storage::TileGroup::LocateTileAndColumn(peloton::oid_t, peloton::oid_t&, peloton::oid_t&): Assertion `(column_map.count(column_offset) != 0)' failed.
[1]    2355 abort (core dumped)  ./bin/peloton
➜  build git:(master) ./bin/peloton
2017-04-02 15:42:35 [src/wire/libevent_server.cpp:49:CreateNewConn] INFO  - create new connection: id = 26
2017-04-02 15:42:35 [src/wire/packet_manager.cpp:65:PacketManager] DEBUG - Registered new PacketManager [count=1]
2017-04-02 15:42:35 [src/wire/libevent_server.cpp:127:LibeventServer] INFO  - Listening on port 15721
2017-04-02 15:42:38 [src/wire/libevent_thread.cpp:117:DispatchConnection] DEBUG - Dispatching connection to worker 0
2017-04-02 15:42:38 [src/wire/libevent_callbacks.cpp:46:WorkerHandleNewConn] DEBUG - Creating new socket fd:27
2017-04-02 15:42:38 [src/wire/libevent_server.cpp:49:CreateNewConn] INFO  - create new connection: id = 27
2017-04-02 15:42:38 [src/wire/packet_manager.cpp:65:PacketManager] DEBUG - Registered new PacketManager [count=2]
2017-04-02 15:42:40 [src/tcop/tcop.cpp:310:PrepareStatement] DEBUG - Statement Prepared: Statement[unnamed] -> create table foo(a int) (TablesRef={}, ReplanNeeded=0, QueryType=create)
Exception Type :: Catalog
Message :: Table 'foo' does not exist
2017-04-02 15:42:43 [src/optimizer/simple_optimizer.cpp:797:CheckIndexSearchable] DEBUG - No suitable index for table 'foo' exists. Skipping...
2017-04-02 15:42:43 [src/tcop/tcop.cpp:310:PrepareStatement] DEBUG - Statement Prepared: Statement[unnamed] -> create index idx on foo(a,b) (TablesRef={8}, ReplanNeeded=0, QueryType=create)
apavlo commented 7 years ago

This brings up a larger discussion that we need to have about error messages and throwing exceptions. Let's talk about this at the next team meeting.