Skip to content

Commit 934b406

Browse files
committed
2 parents 5e1ed84 + 9cc8f04 commit 934b406

File tree

4 files changed

+45
-11
lines changed

4 files changed

+45
-11
lines changed

contrib/pg_dtm/dtmd/src/raft.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,13 @@ void raft_handle_message(raft_t *r, raft_msg_t *m) {
662662
}
663663
}
664664

665+
static char buf[1024];
666+
665667
raft_msg_t *raft_recv_message(raft_t *r) {
666668
struct sockaddr_in addr;
667669
unsigned int addrlen = sizeof(addr);
668670

669671
//try to receive some data, this is a blocking call
670-
char buf[1024];
671672
raft_msg_t *m = (raft_msg_t *)buf;
672673
int recved = recvfrom(
673674
r->sock, buf, sizeof(buf), 0,

src/backend/commands/indexcmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ AlterIndex(Oid indexRelationId, IndexStmt *stmt)
310310

311311
/* Open the target index relation */
312312
/* indexRelation = index_open(indexRelationId, RowExclusiveLock); */
313-
//indexRelation = index_open(indexRelationId, ShareUpdateExclusiveLock);
314-
indexRelation = index_open(indexRelationId, AccessShareLock);
313+
indexRelation = index_open(indexRelationId, ShareUpdateExclusiveLock);
314+
/* indexRelation = index_open(indexRelationId, AccessShareLock); */
315315
namespaceId = RelationGetNamespace(indexRelation);
316316

317317
pg_index = heap_open(IndexRelationId, RowExclusiveLock);

src/backend/tcop/utility.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ ProcessUtilitySlow(Node *parsetree,
12441244
* eventually be needed here, so the lockmode calculation
12451245
* needs to match what DefineIndex() does.
12461246
*/
1247-
lockmode = stmt->is_alter ? AccessShareLock : stmt->concurrent ? ShareUpdateExclusiveLock
1247+
lockmode = stmt->is_alter || stmt->concurrent ? ShareUpdateExclusiveLock
12481248
: ShareLock;
12491249
relid =
12501250
RangeVarGetRelidExtended(stmt->relation, lockmode,

src/bin/insbench/insbench.cpp

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ struct config
4141
int nIndexes;
4242
int nIterations;
4343
int transactionSize;
44+
int initialSize;
4445
bool useSystemTime;
4546
bool noPK;
4647
string connection;
4748

4849
config() {
50+
initialSize = 1000000;
4951
indexUpdateInterval = 0;
5052
nInserters = 1;
5153
nIndexes = 8;
@@ -96,7 +98,8 @@ void* inserter(void* arg)
9698
} else {
9799
con.prepare("insert", "insert into t (select generate_series($1::integer,$2::integer),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000))");
98100
}
99-
101+
time_t curr = currTimestamp;
102+
100103
for (int i = 0; i < cfg.nIterations; i++)
101104
{
102105
work txn(con);
@@ -107,8 +110,9 @@ void* inserter(void* arg)
107110
txn.prepared("insert")(getCurrentTime())(random())(random())(random())(random())(random())(random())(random())(random()).exec();
108111
}
109112
} else {
110-
currTimestamp = i*cfg.transactionSize;
111-
txn.prepared("insert")(i*cfg.transactionSize)((i+1)*cfg.transactionSize-1).exec();
113+
txn.prepared("insert")(curr)(curr+cfg.transactionSize-1).exec();
114+
curr += cfg.transactionSize;
115+
currTimestamp = curr;
112116
}
113117
txn.commit();
114118
}
@@ -142,8 +146,8 @@ void* indexUpdater(void* arg)
142146

143147
void initializeDatabase()
144148
{
145-
connection conn(cfg.connection);
146-
work txn(conn);
149+
connection con(cfg.connection);
150+
work txn(con);
147151
time_t now = getCurrentTime();
148152
exec(txn, "drop table if exists t");
149153
exec(txn, "create table t (pk bigint, k1 bigint, k2 bigint, k3 bigint, k4 bigint, k5 bigint, k6 bigint, k7 bigint, k8 bigint)");
@@ -159,6 +163,31 @@ void initializeDatabase()
159163
exec(txn, "create index idx%d on t(k%d) where pk<%ld", i, i+1, 0);
160164
}
161165
}
166+
167+
if (cfg.initialSize)
168+
{
169+
if (cfg.useSystemTime)
170+
{
171+
#if PQXX_VERSION_MAJOR >= 4
172+
con.prepare("insert", "insert into t values ($1,$2,$3,$4,$5,$6,$7,$8,$9)");
173+
#else
174+
con.prepare("insert", "insert into t values ($1,$2,$3,$4,$5,$6,$7,$8,$9)")("bigint")("bigint")("bigint")("bigint")("bigint")("bigint")("bigint")("bigint")("bigint");
175+
#endif
176+
} else {
177+
con.prepare("insert", "insert into t (select generate_series($1::integer,$2::integer),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000),ceil(random()*1000000000))");
178+
}
179+
if (cfg.useSystemTime)
180+
{
181+
for (int i = 0; i < cfg.initialSize; i++)
182+
{
183+
txn.prepared("insert")(getCurrentTime())(random())(random())(random())(random())(random())(random())(random())(random()).exec();
184+
}
185+
} else {
186+
txn.prepared("insert")(cfg.initialSize)(cfg.initialSize-1).exec();
187+
currTimestamp = cfg.initialSize;
188+
}
189+
txn.exec("vacuum analyze");
190+
}
162191
txn.commit();
163192
}
164193

@@ -185,9 +214,12 @@ int main (int argc, char* argv[])
185214
case 'n':
186215
cfg.nIterations = atoi(argv[++i]);
187216
continue;
188-
case 'i':
217+
case 'x':
189218
cfg.nIndexes = atoi(argv[++i]);
190219
continue;
220+
case 'i':
221+
cfg.initialSize = atoi(argv[++i]);
222+
continue;
191223
case 'c':
192224
cfg.connection = string(argv[++i]);
193225
continue;
@@ -204,7 +236,8 @@ int main (int argc, char* argv[])
204236
"\t-w N\tnumber of inserters (1)\n"
205237
"\t-u N\tindex update interval (0)\n"
206238
"\t-n N\tnumber of iterations (10000)\n"
207-
"\t-i N\tnumber of indexes (8)\n"
239+
"\t-x N\tnumber of indexes (8)\n"
240+
"\t-i N\tinitial table size (1000000)\n"
208241
"\t-q\tuse system time and libpq\n"
209242
"\t-p\tno primary key\n"
210243
"\t-c STR\tdatabase connection string\n");

0 commit comments

Comments
 (0)