Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fb7dec4

Browse files
knizhnikkelvich
authored andcommitted
Remove assert from MtmUnlock
1 parent 0df7c52 commit fb7dec4

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

multimaster.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ void MtmLock(LWLockMode mode)
369369
}
370370
#endif
371371
if (mode == LW_EXCLUSIVE) {
372-
// Assert(MtmLockCount == 0);
373372
Assert(MyProcPid != 0);
374373
Mtm->lastLockHolder = MyProcPid;
375374
Assert(MyProcPid);
@@ -382,12 +381,17 @@ void MtmLock(LWLockMode mode)
382381

383382
void MtmUnlock(void)
384383
{
385-
if (MtmLockCount != 0 && --MtmLockCount != 0) {
386-
Assert(Mtm->lastLockHolder == MyProcPid);
387-
return;
384+
if (Mtm->lastLockHolder == MyProcPid)
385+
{
386+
if (MtmLockCount != 0 && --MtmLockCount != 0) {
387+
return;
388+
}
389+
Mtm->lastLockHolder = 0;
390+
}
391+
else
392+
{
393+
MtmLockCount = 0;
388394
}
389-
390-
Mtm->lastLockHolder = 0;
391395

392396
/* If we have no PGPROC, then lock was not obtained. */
393397
if (MyProc != NULL)

tests/insert.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ char const* connection = "dbname=regression host=localhost port=5432 sslmode=dis
1616
int n_records = 100;
1717
int n_clients = 100;
1818
int first_tid;
19+
int delay = 0;
1920
long inserts[MAX_THREADS];
2021
volatile int termination;
2122

@@ -53,6 +54,7 @@ void* worker(void* arg)
5354
fprintf(stderr, "Insert affect wrong number of tuples: %s\n", PQcmdTuples(res));
5455
exit(1);
5556
}
57+
usleep(delay);
5658
inserts[id] += 1;
5759
PQclear(res);
5860
}
@@ -93,6 +95,9 @@ int main (int argc, char* argv[])
9395
case 'i':
9496
initialize = 1;
9597
continue;
98+
case 'p':
99+
delay = atoi(argv[++i]);
100+
continue;
96101
case 'f':
97102
first_tid = atoi(argv[++i]);
98103
continue;
@@ -101,6 +106,7 @@ int main (int argc, char* argv[])
101106
printf("Options:\n"
102107
"\t-i\tinitialize database\n"
103108
"\t-f\tfirst thread ID (default 0)\n"
109+
"\t-p\tdelay (microseconds)\n"
104110
"\t-c\tnumber of client (default 100)\n"
105111
"\t-t\ttest duration (default 10 sec)\n"
106112
"\t-d\tconnection string ('host=localhost port=5432')\n");

0 commit comments

Comments
 (0)