MXS-2972: Store servers in the cache key
This allows the set of servers used by the service to also participate in the cache value resolution. This will prevent the most obvious of problems but any abstractions of the servers will prevent this from working.
This commit is contained in:
parent
e87ad4abb9
commit
25b8eeb415
@ -45,7 +45,7 @@ SchemaRouterSession::SchemaRouterSession(MXS_SESSION* session,
|
||||
, m_backends(backends)
|
||||
, m_config(router->m_config)
|
||||
, m_router(router)
|
||||
, m_shard(m_router->m_shard_manager.get_shard(m_client->user, m_config->refresh_min_interval))
|
||||
, m_shard(m_router->m_shard_manager.get_shard(get_cache_key(), m_config->refresh_min_interval))
|
||||
, m_state(0)
|
||||
, m_sent_sescmd(0)
|
||||
, m_replied_sescmd(0)
|
||||
@ -665,7 +665,7 @@ void SchemaRouterSession::handleError(GWBUF* pMessage,
|
||||
void SchemaRouterSession::synchronize_shards()
|
||||
{
|
||||
m_router->m_stats.shmap_cache_miss++;
|
||||
m_router->m_shard_manager.update_shard(m_shard, m_client->user);
|
||||
m_router->m_shard_manager.update_shard(m_shard, get_cache_key());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1784,4 +1784,19 @@ SERVER* SchemaRouterSession::get_ps_target(GWBUF* buffer, uint32_t qtype, qc_que
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
std::string SchemaRouterSession::get_cache_key() const
|
||||
{
|
||||
std::string key = m_client->user;
|
||||
|
||||
for (const auto& b : m_backends)
|
||||
{
|
||||
if (b->in_use())
|
||||
{
|
||||
key += b->name();
|
||||
}
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
@ -151,6 +151,7 @@ private:
|
||||
void synchronize_shards();
|
||||
void handle_mapping_reply(SSRBackend& bref, GWBUF** pPacket);
|
||||
bool handle_statement(GWBUF* querybuf, SSRBackend& bref, uint8_t command, uint32_t type);
|
||||
std::string get_cache_key() const;
|
||||
|
||||
/** Member variables */
|
||||
bool m_closed; /**< True if session closed */
|
||||
|
Loading…
x
Reference in New Issue
Block a user