@@ -1247,14 +1247,12 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
1247
1247
MultiXactOffset offset ;
1248
1248
int length ;
1249
1249
int truelength ;
1250
- int i ;
1251
1250
MultiXactId oldestMXact ;
1252
1251
MultiXactId nextMXact ;
1253
1252
MultiXactId tmpMXact ;
1254
1253
MultiXactOffset nextOffset ;
1255
1254
MultiXactMember * ptr ;
1256
1255
LWLock * lock ;
1257
- LWLock * prevlock = NULL ;
1258
1256
1259
1257
debug_elog3 (DEBUG2 , "GetMembers: asked for %u" , multi );
1260
1258
@@ -1361,18 +1359,9 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
1361
1359
pageno = MultiXactIdToOffsetPage (multi );
1362
1360
entryno = MultiXactIdToOffsetEntry (multi );
1363
1361
1364
- /*
1365
- * If this page falls under a different bank, release the old bank's lock
1366
- * and acquire the lock of the new bank.
1367
- */
1362
+ /* Acquire the bank lock for the page we need. */
1368
1363
lock = SimpleLruGetBankLock (MultiXactOffsetCtl , pageno );
1369
- if (lock != prevlock )
1370
- {
1371
- if (prevlock != NULL )
1372
- LWLockRelease (prevlock );
1373
- LWLockAcquire (lock , LW_EXCLUSIVE );
1374
- prevlock = lock ;
1375
- }
1364
+ LWLockAcquire (lock , LW_EXCLUSIVE );
1376
1365
1377
1366
slotno = SimpleLruReadPage (MultiXactOffsetCtl , pageno , true, multi );
1378
1367
offptr = (MultiXactOffset * ) MultiXactOffsetCtl -> shared -> page_buffer [slotno ];
@@ -1407,17 +1396,19 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
1407
1396
1408
1397
if (pageno != prev_pageno )
1409
1398
{
1399
+ LWLock * newlock ;
1400
+
1410
1401
/*
1411
1402
* Since we're going to access a different SLRU page, if this page
1412
1403
* falls under a different bank, release the old bank's lock and
1413
1404
* acquire the lock of the new bank.
1414
1405
*/
1415
- lock = SimpleLruGetBankLock (MultiXactOffsetCtl , pageno );
1416
- if (prevlock != lock )
1406
+ newlock = SimpleLruGetBankLock (MultiXactOffsetCtl , pageno );
1407
+ if (newlock != lock )
1417
1408
{
1418
- LWLockRelease (prevlock );
1419
- LWLockAcquire (lock , LW_EXCLUSIVE );
1420
- prevlock = lock ;
1409
+ LWLockRelease (lock );
1410
+ LWLockAcquire (newlock , LW_EXCLUSIVE );
1411
+ lock = newlock ;
1421
1412
}
1422
1413
slotno = SimpleLruReadPage (MultiXactOffsetCtl , pageno , true, tmpMXact );
1423
1414
}
@@ -1429,8 +1420,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
1429
1420
if (nextMXOffset == 0 )
1430
1421
{
1431
1422
/* Corner case 2: next multixact is still being filled in */
1432
- LWLockRelease (prevlock );
1433
- prevlock = NULL ;
1423
+ LWLockRelease (lock );
1434
1424
CHECK_FOR_INTERRUPTS ();
1435
1425
pg_usleep (1000L );
1436
1426
goto retry ;
@@ -1439,14 +1429,14 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
1439
1429
length = nextMXOffset - offset ;
1440
1430
}
1441
1431
1442
- LWLockRelease (prevlock );
1443
- prevlock = NULL ;
1432
+ LWLockRelease (lock );
1433
+ lock = NULL ;
1444
1434
1445
1435
ptr = (MultiXactMember * ) palloc (length * sizeof (MultiXactMember ));
1446
1436
1447
1437
truelength = 0 ;
1448
1438
prev_pageno = -1 ;
1449
- for (i = 0 ; i < length ; i ++ , offset ++ )
1439
+ for (int i = 0 ; i < length ; i ++ , offset ++ )
1450
1440
{
1451
1441
TransactionId * xactptr ;
1452
1442
uint32 * flagsptr ;
@@ -1459,18 +1449,20 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
1459
1449
1460
1450
if (pageno != prev_pageno )
1461
1451
{
1452
+ LWLock * newlock ;
1453
+
1462
1454
/*
1463
1455
* Since we're going to access a different SLRU page, if this page
1464
1456
* falls under a different bank, release the old bank's lock and
1465
1457
* acquire the lock of the new bank.
1466
1458
*/
1467
- lock = SimpleLruGetBankLock (MultiXactMemberCtl , pageno );
1468
- if (lock != prevlock )
1459
+ newlock = SimpleLruGetBankLock (MultiXactMemberCtl , pageno );
1460
+ if (newlock != lock )
1469
1461
{
1470
- if (prevlock )
1471
- LWLockRelease (prevlock );
1472
- LWLockAcquire (lock , LW_EXCLUSIVE );
1473
- prevlock = lock ;
1462
+ if (lock )
1463
+ LWLockRelease (lock );
1464
+ LWLockAcquire (newlock , LW_EXCLUSIVE );
1465
+ lock = newlock ;
1474
1466
}
1475
1467
1476
1468
slotno = SimpleLruReadPage (MultiXactMemberCtl , pageno , true, multi );
@@ -1496,8 +1488,7 @@ GetMultiXactIdMembers(MultiXactId multi, MultiXactMember **members,
1496
1488
truelength ++ ;
1497
1489
}
1498
1490
1499
- if (prevlock )
1500
- LWLockRelease (prevlock );
1491
+ LWLockRelease (lock );
1501
1492
1502
1493
/* A multixid with zero members should not happen */
1503
1494
Assert (truelength > 0 );
0 commit comments