Fix shard hash caclulation

This commit is contained in:
Konstantin Knizhnik
2023-11-11 08:53:52 +02:00
parent d3221243f8
commit 93c75c97e1
2 changed files with 16 additions and 6 deletions

View File

@@ -213,14 +213,14 @@ get_shard_number(BufferTag* tag)
#if PG_MAJORVERSION_NUM < 16
hash = murmurhash32(tag->rnode.spcNode);
hash_combine(hash, murmurhash32(tag->rnode.dbNode));
hash_combine(hash, murmurhash32(tag->rnode.relNode));
hash_combine(hash, murmurhash32(tag->blockNum/(MB/BLCKSZ)/stripe_size));
hash = hash_combine(hash, murmurhash32(tag->rnode.dbNode));
hash = hash_combine(hash, murmurhash32(tag->rnode.relNode));
hash = hash_combine(hash, murmurhash32(tag->blockNum/(MB/BLCKSZ)/stripe_size));
#else
hash = murmurhash32(tag->spcOid);
hash_combine(hash, murmurhash32(tag->dbOid));
hash_combine(hash, murmurhash32(tag->relNumber));
hash_combine(hash, murmurhash32(tag->blockNum/(MB/BLCKSZ)/stripe_size));
hash = hash_combine(hash, murmurhash32(tag->dbOid));
hash = hash_combine(hash, murmurhash32(tag->relNumber));
hash = hash_combine(hash, murmurhash32(tag->blockNum/(MB/BLCKSZ)/stripe_size));
#endif
return hash % n_shards;

View File

@@ -951,6 +951,16 @@ page_server_request(void const *req)
}
shard_no = get_shard_number(&tag);
/*
* TODO: temporary workarround - we stream all WAL only to shard 0 so metadata and forks other than main
* should be requested from shard 0. We still need to call get_shard_no() to check if shard map is up-to-date
*/
if (((NeonRequest *) req)->tag != T_NeonGetPageRequest || ((NeonGetPageRequest *) req)->forknum != MAIN_FORKNUM)
{
shard_no = 0;
}
do
{
while (!page_server->send(shard_no, (NeonRequest *) req) || !page_server->flush(shard_no));