-
Notifications
You must be signed in to change notification settings - Fork 5
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
Introduce "use database" and update gaiac usage #633
Conversation
|
||
# | ||
# Generate stand alone incubator. | ||
# | ||
add_custom_command( | ||
COMMENT "Compiling incubator.ddl..." | ||
OUTPUT ${GAIA_GENERATED_SCHEMAS}/gaia_barn_storage.h | ||
COMMAND ${GAIA_GENERATE} --destroy-db -t ${GAIA_PROD_BUILD}/db/core -o ${GAIA_GENERATED_SCHEMAS} -g ${INCUBATOR_DDL} | ||
COMMAND ${GAIA_GENERATE} --destroy-db -t ${GAIA_PROD_BUILD}/db/core -o ${GAIA_GENERATED_SCHEMAS} -d barn_storage -g ${INCUBATOR_DDL} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the folder called "barn_storage" when the command says "incubator"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so the database for "incubator" is called "barn_storage". Using two names for this test is rather confusing. Why not have the database called incubator
as well? Or just stick to barn_storage
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For prerequisites
, the ddl and the database use the same name. It would be nice to come up with some consistent naming scheme to eliminate surprises about what is called which way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. But this is how this script/schema is currently written and used by many tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good, but I'm not sure about some file/database renames - the naming of files and databases seems inconsistent across tests/demos. We should come up with a more consistent naming scheme.
@@ -21,6 +21,11 @@ void initialize_catalog() | |||
ddl_executor_t::get(); | |||
} | |||
|
|||
void use_database(const string& name) | |||
{ | |||
ddl_executor_t::get().switch_db_context(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there will be a problem if you have multiple threads using this (eg. multiple sessions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a problem for multiple threads because ddl_executor_t
is a singleton and we use unique lock when switching context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what you mean by multiple sessions. DB sessions are irrelevant here.
If you mean multiple processes, we always have the issue that the data structures in ddl_executor_t
are not consistent across multiple processes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have multiple threads, within the same process, each running their own session.
What happens if each of these threads to something that causes switch_db_context
to be called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They will be executed in sequence due to the use of unique lock. The db context a statement see will be the last use statement
before it. Remember DDLs are not subject to txn semantics. So we don't need to guarantee a consistent view for DDLs executed in parallel. More practically speaking, gaiac
will not execute DDLs in parallel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
use database
statement. With this, users can switch DB context in the DDL. Tables without a database name will be assumed in the current database context.gaiac
command line usage in the following ways.create database
DDL statement.create database
in the same DDL file.-d database
in the command line.For example,
gaiac -d barn_storage -d lab -g incubator.ddl
will generatebarn_storage
andlab
headers underincubator
directory.