Take in account stripe size when calculating shard hash number

This commit is contained in:
Konstantin Knizhnik
2023-11-09 10:14:55 +02:00
parent 6e0055b9f6
commit 0aeba9fc4c
3 changed files with 9 additions and 4 deletions

View File

@@ -307,7 +307,7 @@ RequestShardMapFromControlPlane(ShardMap* shard_map)
continue;
if (shard_map->n_shards >= MAX_SHARDS)
elog(ERROR, "Too manuy shards");
elog(ERROR, "Too many shards");
if (v.type != jbvString)
elog(ERROR, "Connection string expected");

View File

@@ -143,12 +143,12 @@ get_shard_number(BufferTag* tag)
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));
hash_combine(hash, murmurhash32(tag->blockNum/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));
hash_combine(hash, murmurhash32(tag->blockNum/STRIPE_SIZE));
#endif
LWLockAcquire(shard_map_lock, LW_SHARED);
@@ -193,7 +193,11 @@ pageserver_sighup_handler(SIGNAL_ARGS)
prev_signal_handler(postgres_signal_arg);
}
neon_log(LOG, "Received SIGHUP, disconnecting pageserver. New pageserver connstring is %s", page_server_connstring);
shard_map->n_shards = 0; /* force refetching shard map from control plane */
/* force refetching shard map from control plane */
LWLockAcquire(shard_map_lock, LW_EXCLUSIVE);
shard_map->n_shards = 0;
LWLockRelease(shard_map_lock);
}
static bool

View File

@@ -28,6 +28,7 @@
#include "pg_config.h"
#define MAX_SHARDS 128
#define STRIPE_SIZE (256 * 1024 / 8) /* TODO: should in betaken from control plane? */
#define MAX_PS_CONNSTR_LEN 128
typedef struct