Skip to content

Commit

Permalink
Take in account stripe size when calculating shard hash number
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Knizhnik committed Nov 9, 2023
1 parent 6e0055b commit 0aeba9f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pgxn/neon/control_plane_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
10 changes: 7 additions & 3 deletions pgxn/neon/libpagestore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pgxn/neon/pagestore_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0aeba9f

Please sign in to comment.