Commit b1054277 authored by Jan Lindström's avatar Jan Lindström

MDEV-19660: wsrep_rec_get_foreign_key() is dereferencing a stale pointer to a...

MDEV-19660: wsrep_rec_get_foreign_key() is dereferencing a stale pointer to a page that was previously latched

In row_ins_foreign_check_on_constraint(), clustered index record is being passed to wsrep_append_foreign_key() after releasing the latch. If a record has been changed by other thread in the meantime then it could lead to a crash when
wsrep_rec_get_foreign_key () tries to access the record.

row_ins_foreign_check_on_constraint
	Use cascade->pcur->old_rec instead of clust_rec.

row_ins_check_foreign_constraint
	Add missing error printout.
parent 82bb108e
......@@ -1293,7 +1293,7 @@ row_ins_foreign_check_on_constraint(
err = wsrep_append_foreign_key(
thr_get_trx(thr),
foreign,
clust_rec,
cascade->pcur->old_rec,
clust_index,
FALSE, WSREP_KEY_EXCLUSIVE);
if (err != DB_SUCCESS) {
......@@ -1664,6 +1664,11 @@ row_ins_check_foreign_constraint(
check_index,
check_ref,
key_type);
if (err != DB_SUCCESS) {
fprintf(stderr,
"WSREP: foreign key append failed: %d\n", err);
}
#endif /* WITH_WSREP */
goto end_scan;
} else if (foreign->type != 0) {
......
......@@ -1299,7 +1299,7 @@ row_ins_foreign_check_on_constraint(
err = wsrep_append_foreign_key(
thr_get_trx(thr),
foreign,
clust_rec,
cascade->pcur->old_rec,
clust_index,
FALSE, WSREP_KEY_EXCLUSIVE);
if (err != DB_SUCCESS) {
......@@ -1676,6 +1676,11 @@ row_ins_check_foreign_constraint(
check_index,
check_ref,
key_type);
if (err != DB_SUCCESS) {
fprintf(stderr,
"WSREP: foreign key append failed: %d\n", err);
}
#endif /* WITH_WSREP */
goto end_scan;
} else if (foreign->type != 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment