diff --git a/contrib/Makefile b/contrib/Makefile
index 2f0a88d3f77..b4ff1391387 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -21,6 +21,7 @@ SUBDIRS = \
 		earthdistance	\
 		file_fdw	\
 		fuzzystrmatch	\
+		hash_test	\
 		hstore		\
 		intagg		\
 		intarray	\
diff --git a/contrib/hash_test/Makefile b/contrib/hash_test/Makefile
new file mode 100644
index 00000000000..a4ce6692127
--- /dev/null
+++ b/contrib/hash_test/Makefile
@@ -0,0 +1,18 @@
+# contrib/hash_test/Makefile
+
+MODULE_big = hash_test
+OBJS = \
+	hash_test.o
+
+PGFILEDESC = "hash_test - demostrate hash_seq_search and transaction issue"
+
+ifdef USE_PGXS
+PG_CONFIG = pg_config
+PGXS := $(shell $(PG_CONFIG) --pgxs)
+include $(PGXS)
+else
+subdir = contrib/hash_test
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+include $(top_srcdir)/contrib/contrib-global.mk
+endif
diff --git a/contrib/hash_test/hash_test.c b/contrib/hash_test/hash_test.c
new file mode 100644
index 00000000000..7c9e24f40cc
--- /dev/null
+++ b/contrib/hash_test/hash_test.c
@@ -0,0 +1,73 @@
+
+#include "postgres.h"
+
+#include "access/xact.h"
+#include "fmgr.h"
+#include "miscadmin.h"
+#include "postmaster/bgworker.h"
+#include "utils/hsearch.h"
+
+#define HASH_TEST_TABLE_NELEMS 2
+
+PG_MODULE_MAGIC;
+
+PGDLLEXPORT void hash_test_workhorse(Datum main_arg);
+
+static HTAB *hash_test_table;
+
+typedef struct
+{
+	/* key */
+	int			num_key;
+} hash_test_table_entry;
+
+void
+_PG_init(void)
+{
+	BackgroundWorker worker;
+
+	if (!process_shared_preload_libraries_in_progress)
+		return;
+
+	MemSet(&worker, 0, sizeof(BackgroundWorker));
+	worker.bgw_flags = BGWORKER_SHMEM_ACCESS |
+		BGWORKER_BACKEND_DATABASE_CONNECTION;
+	worker.bgw_start_time = BgWorkerStart_ConsistentState;
+	worker.bgw_restart_time = BGW_NEVER_RESTART;
+	sprintf(worker.bgw_library_name, "hash_test");
+	sprintf(worker.bgw_function_name, "hash_test_workhorse");
+	sprintf(worker.bgw_name, "hash_test proccess");
+
+	RegisterBackgroundWorker(&worker);
+}
+
+void
+hash_test_workhorse(Datum main_arg)
+{
+	hash_test_table_entry *h_entry;
+	HASHCTL		ctl;
+	HASH_SEQ_STATUS hs;
+
+	BackgroundWorkerInitializeConnection(NULL, NULL, 0);
+
+	ctl.keysize = sizeof(int);
+	ctl.entrysize = sizeof(hash_test_table_entry);
+
+	hash_test_table = hash_create("hash_test_table",
+								  HASH_TEST_TABLE_NELEMS,
+								  &ctl,
+								  HASH_ELEM | HASH_BLOBS);
+
+	/* insert elements */
+	for (int i = 0; i < HASH_TEST_TABLE_NELEMS; i++)
+		hash_search(hash_test_table, &i, HASH_ENTER, NULL);
+
+	/* go through hash table */
+	hash_seq_init(&hs, hash_test_table);
+	while ((h_entry = hash_seq_search(&hs)) != NULL)
+	{
+		StartTransactionCommand();
+		/* do some stuff */
+		CommitTransactionCommand();
+	}
+}
diff --git a/contrib/hash_test/meson.build b/contrib/hash_test/meson.build
new file mode 100644
index 00000000000..bc3aac4e66d
--- /dev/null
+++ b/contrib/hash_test/meson.build
@@ -0,0 +1,10 @@
+
+hash_test_sources = files(
+  'hash_test.c',
+)
+
+hash_test = shared_module('hash_test',
+  hash_test_sources,
+  kwargs: contrib_mod_args,
+)
+contrib_targets += hash_test
diff --git a/contrib/meson.build b/contrib/meson.build
index ed30ee7d639..a2a67b1b3fd 100644
--- a/contrib/meson.build
+++ b/contrib/meson.build
@@ -29,6 +29,7 @@ subdir('dict_xsyn')
 subdir('earthdistance')
 subdir('file_fdw')
 subdir('fuzzystrmatch')
+subdir('hash_test')
 subdir('hstore')
 subdir('hstore_plperl')
 subdir('hstore_plpython')
