tidb-incubator / weir Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
When I access the api server, there is no verification operation. Therefore, unverified api operations may have unexpected effects on namesapce
When I access the api server, I need to carry the client token or encrypted username and password.
weir-proxy execute client SQLs in backend connection pool, so it is need to handle session variables in frontend.
I think there are two ways to support session variables.
SET
statement before client SQL in a backend connection.Each of the above has its own advantages and disadvantages. Which one should we support, or both?
Problem
Currently max_connections is the service level. If a namespace occupies too many connections, it will cause resource preemption.Resources are not isolated
We would like
Set the namespcae level max_connections. Form resource isolation
SET NAMES utf8mb4
OK
SetNAMES is not a valid sysvar
weir-proxy -V
)?master
Hi,
Is it possible to set connection and querying to pessimistic instead of optimistic? I don't find where to set this option.
regards,
YM
weir在首次建立与底层mysql连接的时候,没有设置字符集,只是把字符集设置成了属性,并没有实际调用set names 指令,可以看代码如下
weir/pkg/proxy/backend/client/conn.go
Line 70 in 89d789c
// Apply configuration functions.
for i := range options {
options[i](c)
}
if err = c.handshake(); err != nil {
return nil, errors.Trace(err)
}
if err = c.SetCharset(constant.DefaultCharset); err != nil {
return nil, errors.Trace(err)
}
为什么这么改呢?
SetCharset这个函数中有判断
if c.charset == charset {
return nil
}
所以如果c.charset = constant.DefaultCharset进行了赋值,也就是这个连接没有调用set names utf8mb4指令,当我们主动调用SetCharset(ctx, "utf8mb4")的时候,因为c.charset已经是utf8mb4了,就不会再往下执行,也就是不会发送 set name utf8mb4指令,从而导致字符集一次都没有设置过。
weir-proxy -V
)?SQL statement is parsed multiple times unnecessarily in QueryCtxImpl::Execute
当我们变更一个namespace的对应的数据库实例列表时,通过管控接口,/reload/prepare/{namespace} 进行重新装载配置信息。通过数据库实例上tcp连接信息,能看到从weir还是会有连接与下掉的实例保持。代码跟踪发现在执行这个prepare管控接口的时候,会去重建连接池。重建之后,直接将原有连接池替换掉。原来的连接池没有销毁。
func (b *BackendImpl) initConnPools() error {
connPools := make(map[string]*ConnPool)
for addr := range b.cfg.Addrs {
poolCfg := &ConnPoolConfig{
Config: Config{Addr: addr, UserName: b.cfg.UserName, Password: b.cfg.Password},
Capacity: b.cfg.Capacity,
IdleTimeout: b.cfg.IdleTimeout,
}
connPool := NewConnPool(b.ns, poolCfg)
connPools[addr] = connPool
}
successfulInitConnPoolAddrs := make(map[string]struct{})
var initConnPoolErr error
for addr, connPool := range connPools {
if err := connPool.Init(); err != nil {
initConnPoolErr = err
break
}
successfulInitConnPoolAddrs[addr] = struct{}{}
}
if initConnPoolErr != nil {
for addr := range successfulInitConnPoolAddrs {
if err := connPools[addr].Close(); err != nil {
logutil.BgLogger().Sugar().Error("close inited conn pool error, addr: %s, err: %v", addr, err)
}
}
return initConnPoolErr
}
**b.connPools = connPools**
return nil
}
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.