alex-dukhno / isomorphicdb Goto Github PK
View Code? Open in Web Editor NEWThe core repository of implementing PostgreSQL compatible distributed database in Rust
Home Page: http://isomorphicdb.io/
License: Apache License 2.0
The core repository of implementing PostgreSQL compatible distributed database in Rust
Home Page: http://isomorphicdb.io/
License: Apache License 2.0
Currently, database supports only type constraints (implemented list see #17).
SQL to reproduce:
create schema SMOKE_QUERIES;
create table SMOKE_QUERIES.NOT_NULLABLE_TABLE (
column_1 smallint constraint column_1_is_never_null not null
);
insert into SMOKE_QUERIES.NOT_NULLABLE_TABLE values (null);
Expected result:
ERROR: constraint 'column_1_is_never_null' is violated
When implementing the task see #124 (comment) conversation to support null values in the storage
Optionally database should support violation of multiple constraints
Under Epic #29
It should send non hardcoded value when client Simple Query
type request is coming
Some PoC is required to investigate is there any parts that should be extracted into protocol API and implemented by database backend.
As a code reference we can take a look at https://github.com/MaterializeInc/materialize/blob/master/src/pgwire/src/server.rs#L49
Server fails on empty SQL query
steps to reproduce:
help
and hit enter in client appclient trace with the command RUST_LOG=trace cargo run --bin client
INFO client > Starting client
help
DEBUG client > typed command "help\n"
DEBUG client > command send to server
DEBUG client > 255 server result code
Ok("")
DEBUG client > typed command "\n"
DEBUG client > command send to server
DEBUG client > 69 server result code
Unknown server code 69. Exiting!
server trace with the command RUST_LOG=trace cargo run --bin server
INFO server > Starting server on port 7000
INFO server > SQL engine has been created
INFO server > Network buffer of 256 size created
DEBUG server > Connection 127.0.0.1:58240 is accepted
TRACE server > 4 bytes read from network connection
DEBUG server > help
DEBUG server > Received from 127.0.0.1:58240 client
DEBUG sqlparser::parser > Parsing sql 'help'...
DEBUG server > Query execution result
DEBUG server > Err(UnimplementedBranch("ParserError(\"Expected a keyword at the beginning of a statement, found: help\")"))
TRACE server > 0 bytes read from network connection
DEBUG server >
DEBUG server > Received from 127.0.0.1:58240 client
DEBUG sqlparser::parser > Parsing sql ''...
DEBUG server > Query execution result
DEBUG server > Err(UnimplementedBranch("UNIMPLEMENTED HANDLING OF \nNone\n STATEMENT!"))
TRACE server > 0 bytes read from network connection
DEBUG server >
DEBUG server > Received from 127.0.0.1:58240 client
DEBUG sqlparser::parser > Parsing sql ''...
DEBUG server > Query execution result
DEBUG server > Err(UnimplementedBranch("UNIMPLEMENTED HANDLING OF \nNone\n STATEMENT!"))
Error: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }
smallint
, integer
and bigint
#77char(n)
and varchar(n)
#89boolean
type #107decimal(p, s)
and its alias numeric(p, s)
#90real
and double precision
#91time [without timezone]
, time with timezone
, timestamp [without timezone]
, timestamp with timezone
and date
Currently, database is developed as to store all metadata about schema
s and table
s in-memory only. If restart process all data would be lost. Technically it is saved on disk with sled
, but storage wouldn't find it on disk so will be thinking that there is nothing exists.
Test cases:
Currently server can work with single client - even worse it shuts down when client disconnects
Storage frontend does not handle situations when Backend stores less records than requested. (e.g. does not try to roll back writes by removing them or writing old values in case of update
)
#67 Saving column names in system
namespace
Things to consider:
Primary Key
indexescreate_schema
- what if sled
won't be able to create Db
create_table
- what if sled
won't be able to open_tree
normallydrop_table
- what if sled
won't be able to drop_tree
normallyinsert_into
-
sled
won't be able to open_tree
normallysled
won't be able to insert
normallyselect_all_from
-
sled
won't be able to open_tree
normallysled
won't be able to read data in iter
normallyupdate_all
-
open_tree
iter().keys()
delete_all_from
-
open_tree
iter().keys()
Initial source is "Design Data Intensive Application"
options like ssl
, gssenc
and sspi
encryptions has to be extendable and configurable by implementations
Currently, database supports only type constraints (implemented list see #17).
SQL to reproduce:
create schema SMOKE_QUERIES;
create table SMOKE_QUERIES.NOT_NULLABLE_TABLE (
column_1 smallint not null
);
insert into SMOKE_QUERIES.NOT_NULLABLE_TABLE values (null);
Expected result:
ERROR: not null constraint for column_1 is violated
When implementing the task see #124 (comment) conversation to support null values in the storage
Optionally database should support violation of multiple constraints
Initial question is: what the hell is it? - Protocol, Strategy
Initial source "Design Data Intensive Application" Chapter 5 "Replication"
Paragraphs:
Currently, sql_handler::Handler
uses unimplemented!
macro. It is not user friendly and better to send ErrorResponse
with Currently "your sql query" is not supported
message
SQL to reproduce:
create schema SMOKE_QUERIES;
create table SMOKE_QUERIES.NOT_NULLABLE_TABLE (
column_1 smallint check (column_1 > 100)
);
insert into SMOKE_QUERIES.NOT_NULLABLE_TABLE values (99);
Expected result:
ERROR: check 'column value > 100' constraint is violated
The problem with this is that check
constraint should use predicate evaluation logic and should be persisted to system.columns
table
Blocked by #194
Currently, database does not handle authentication at all. For now we can:
users
table in system
namespace
during FrontendStore
initialisationadmin
user and simple password like 123
protocol
- here be dragons.Authenticator
trait
to protocol
and impl
in node
module that glue PG wire protocol with other part of backendSQL to reproduce:
create schema SMOKE_QUERIES;
create table SMOKE_QUERIES.NOT_NULLABLE_TABLE (
column_1 smallint constraint column_1_greater_than_100 check (column_1 > 100)
);
insert into SMOKE_QUERIES.NOT_NULLABLE_TABLE values (99);
Expected result:
ERROR: 'constraint column_1_greater_than_100' is violated
The problem with this is that check
constraint should use predicate evaluation logic and should be persisted to system.columns
table
It could be travis-ci or GitHub actions
Depends on #24
Setup and describe integration compatibility tests with psql
from docker container, instead of locally installed
First part of WA is in tests itself - test client send query that can't be parsed and then second client opens up a connection to server Node
Second part of WA is in sql engine - it returns QueryResult::Terminate
if query is not parsable.
Third part is in Node
- it sets state
into STOPPED
when gets QueryResult::Terminate
from sql engine
Possible ways to fix it are:
tokio-postgres
if it doesn't have same problem as synchronous sfackler/rust-postgres#613java
, python
or ruby
)Initial source is "Design Data Intensive Application"
How to reproduce:
^C
thread 'main' panicked at 'Unexpected error: Connection reset by peer (os error 54)', src/bin/server.rs:124:25
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1063
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1426
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:204
9: std::panicking::default_hook
at src/libstd/panicking.rs:224
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:470
11: rust_begin_unwind
at src/libstd/panicking.rs:378
12: std::thread::local::fast::Key<T>::try_initialize
13: server::main
at src/bin/server.rs:124
14: std::rt::lang_start::{{closure}}
at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/rt.rs:67
15: std::rt::lang_start_internal::{{closure}}
at src/libstd/rt.rs:52
16: std::panicking::try::do_call
at src/libstd/panicking.rs:303
17: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:86
18: std::panicking::try
at src/libstd/panicking.rs:281
19: std::panic::catch_unwind
at src/libstd/panic.rs:394
20: std::rt::lang_start_internal
at src/libstd/rt.rs:51
21: std::rt::lang_start
at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/rt.rs:67
22: server::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Process finished with exit code 101
How to reproduce:
^C
in client appToken(n)
blocked by #34
to run automation tests server has to implement PostgreSQL Wire Protocol just enough to communicate with psql
and rust-postgres
driver
Documentations:
Books:
Papers:
Video courses:
Repositories:
Blogs:
Blog Posts:
Conferences:
Slides:
Research Groups:
psql
clientCurrently client dumps data from server as UTF8
string.
If select
query was sent client has to print selected data in human readable format like
+------+------+
| col1 | col2 |
+------+------+
| 1| 2|
+------+------+
Initial source is "Design Data Intensive Application"
The primary reason for this is to have more convenient and readable unit tests for client server communication
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.