Comments (19)
I have some problems in adding locks for methods of Transaction
. Here is my understanding:
read
,read_by_index
,append
,delete
,table
,drop_data
should add read lockadd_column
,drop_column
,create_table
should add write lock- how about
add_index
,del_index
andadd_index_meta
? I found both ddl(insert, update) and dml(create index, add column) useadd_index
. Maybeadd_index_meta
should add write lock, others should be read lock. - should meta-related methods be locked? Which lock should be used?(
table_metas
,table_meta_path
,save_table_meta
,meta_load
)
from fncksql.
It's kind of like a hierarchical lock and intention lock, but it is still a table level lock in most case, and multiple ddl on different table can execute concurrently.
session1 session2
select * from t;
alter table t2 add column d int(ok)
alter table t add column d int(block)
+-------------+--------------------+----------------+---------------------+
| OBJECT_TYPE | OBJECT_SCHEMA | OBJECT_NAME | LOCK_TYPE |
+-------------+--------------------+----------------+---------------------+
| TABLE | test | t | SHARED_READ |
| GLOBAL | NULL | NULL | INTENTION_EXCLUSIVE |
| BACKUP LOCK | NULL | NULL | INTENTION_EXCLUSIVE |
| SCHEMA | test | NULL | INTENTION_EXCLUSIVE |
| TABLE | test | t | SHARED_UPGRADABLE |
| TABLESPACE | NULL | test/t | INTENTION_EXCLUSIVE |
| TABLE | test | #sql-790d_b | EXCLUSIVE |
| TABLE | test | t | EXCLUSIVE |
| TABLE | performance_schema | metadata_locks | SHARED_READ |
+-------------+--------------------+----------------+---------------------+
I don't think implicitly submiting is a good thing, you can't even rollback(even when you kill it, it is crazy).
from fncksql.
@crwen do you have any ideas for implementing table level locks? I don't have any good ideas now
I have no idea. But tables are known only when binding or after, maybe lock can be added when executing or acessing the storage.
from fncksql.
I think we can first make mdl a global lock, restrict DDL to global serialization, and downgrade it to table level lock as a perf issue
So maybe #177 could be merged now.
from fncksql.
maybe some lock manager?
from fncksql.
Yes, it is consistent with the table lock in MySQL. When a DDL operation occurs, no other DDL or DML is allowed.
Tips: I think DML and DDL are operations similar to RWLock, DML can be run by multiple DML transactions simultaneously, but DDL runs a single DDL transaction simultaneously in DML and DDL
Tips 2: If there are duplicates in DML, Storage will detect and throw an exception by itself, This is already implemented so you don't need to worry about this
This may be a relatively big job, so before starting this issue, could you please fix the nestloopjoin pr problem first?
from fncksql.
could you please fix the nestloopjoin pr problem first?
I think the main problem is in the binder layer, or are you referring to the problem of explain?
from fncksql.
from fncksql.
from fncksql.
I tried to implement it today and discovered something. DDL is executed as a separate transaction in MySQL. If a transaction has not yet been submitted after executing DQL or DML, etc., executing DDL at this time will implicitly submit the transaction. And to do a separate transaction for the DDL (which means only using RWLock), my plan is to add a new attribute to the DataBase
pub struct Database<S: Storage> {
pub storage: S,
functions: Arc<Functions>,
mdl: Arc<RwLock<()>>
}
I chose to learn MySQL and do it on the upper layer of the storage engine, and table_cache is based on your PR
from fncksql.
If a transaction has not yet been submitted after executing DQL or DML, etc., executing DDL at this time will implicitly submit the transaction.
I think DDL will be blocked if a DQL or DML does not submit. (MySQL 8.3.0)
my plan is to add a new attribute to the
DataBase
This will lock the whole database.
from fncksql.
yes, I originally meant within the same transaction, but if it is multiple transactions, then it is what you said
from fncksql.
This will lock the whole database.
yes, so it is guaranteed that no other operations are allowed to be performed when DDL is executed
In MySQL, mdl often produces deadlocks
from fncksql.
In MySQL, mdl often produces deadlocks
As far as I know, mdl is table level lock, and it is 2PL that causes deadlocks.
from fncksql.
In MySQL, mdl often produces deadlocks
As far as I know, mdl is table level lock, and it is 2PL that causes deadlocks.
https://stackoverflow.com/questions/76484118/why-mysql-mdlmeta-data-lock-led-to-a-deadlock
from fncksql.
Yes, you are right, so I did not do implicit commit in pr, but refused to execute DDL in transaction
from fncksql.
Oh, I made a mistake, I should have used table level locks
from fncksql.
@crwen do you have any ideas for implementing table level locks? I don't have any good ideas now
from fncksql.
I think we can first make mdl a global lock, restrict DDL to global serialization, and downgrade it to table level lock as a perf issue
from fncksql.
Related Issues (20)
- Perf: Optimize the loading of `StatisticsMetaLoader`
- Bug: In multi-level nested subquery, the field relationships of different tables are wrong. HOT 2
- Bind column incorrectly
- Feat: Support `TopK` on `Order By ... Limit ...` HOT 3
- Perf: Downgrade `MDL` to Table Level Locks
- Feat: TimeZone Info for `LogicalType::Time`
- Feat: Index on Order By
- Feat: Support `View`
- Perf: Optimize the implementation of `IndexIter` HOT 1
- Feat: Support correlated subqueries HOT 4
- Bug: NormalizationRule::PushPredicateThroughJoin is executed incorrectly during correlated subqueries HOT 1
- Feat: cache `RangeDetacher::detach`
- Feat: Support redb as storage engine
- Feat: Support Tikv as storage engine
- Feat: replace `DataValue::binary_op` with generics HOT 1
- Bug: wrong projection when joining the same table
- Fix: the fields output by Using are not determined by JoinType
- Feat; Support Full Join when `HashJoin` cannot be used
- Can this project be compiled on Mac OS(m1) HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fncksql.