Skip to content

Commit

Permalink
Invalidate descrs on relation truncate in recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
akorotkov committed May 6, 2023
1 parent 4ab2685 commit 6768130
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/recovery/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "tableam/descr.h"
#include "tableam/operations.h"
#include "transam/undo.h"
#include "utils/inval.h"
#include "utils/stopevent.h"
#include "utils/syscache.h"

Expand Down Expand Up @@ -1864,6 +1865,22 @@ o_indices_get_oids(Pointer tuple, ORelOids *tableOids)
return treeOids;
}

static void
clean_workers_oids(void)
{
int i;

for (i = 0; i < recovery_pool_size_guc; i++)
{
RecoveryWorkerState *state = &workers_pool[i];

state->oids.datoid = InvalidOid;
state->oids.reloid = InvalidOid;
state->oids.relnode = InvalidOid;
state->type = oIndexInvalid;
}
}

/*
* Replays a single orioledb WAL container.
*/
Expand Down Expand Up @@ -2075,6 +2092,8 @@ replay_container(Pointer startPtr, Pointer endPtr,
pfree(old_o_table);
pfree(new_o_table);
}
if (!single)
clean_workers_oids();

}
else if (rec_type == WAL_REC_TRUNCATE)
Expand All @@ -2092,6 +2111,10 @@ replay_container(Pointer startPtr, Pointer endPtr,
workers_synchronize(xlogPtr, true);

o_truncate_table(oids);

AcceptInvalidationMessages();
if (!single)
clean_workers_oids();
}
else if (rec_type == WAL_REC_SAVEPOINT)
{
Expand Down
7 changes: 7 additions & 0 deletions src/tableam/operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -1655,14 +1655,21 @@ o_truncate_table(ORelOids oids)
o_tables_rel_lock_extended(&treeOids[i], AccessExclusiveLock, true);
cleanup_btree(treeOids[i].datoid, treeOids[i].relnode, true);
o_invalidate_oids(treeOids[i]);
/* if (is_recovery_process())
o_invalidate_descrs(treeOids[i].datoid, treeOids[i].reloid,
treeOids[i].relnode);*/
if (ORelOidsIsEqual(oids, treeOids[i]))
invalidatedTable = true;
o_tables_rel_unlock_extended(&treeOids[i], AccessExclusiveLock, false);
o_tables_rel_unlock_extended(&treeOids[i], AccessExclusiveLock, true);
}

if (!invalidatedTable)
{
o_invalidate_oids(oids);
/* if (is_recovery_process())
o_invalidate_descrs(oids.datoid, oids.reloid, oids.relnode);*/
}

o_tables_rel_unlock(&oids, AccessExclusiveLock);

Expand Down

0 comments on commit 6768130

Please sign in to comment.