神刀安全网

BDR 0.9.3 and Index on Expression (Part 3 – Solved)

Go deeper into BDR and patched-PostgreSQL 9.4.5, eventually I find out the root cause. When new record INSERT-ed, BDR replicates it to other nodes. After simple_heap_insert , BDR calls UserTableUpdateOpenIndexes . For index on epression written in SQL, BDR code routes to GetActiveSnapshot() which fires Segmentation fault because ActiveSnapShot is invalid.

Snapshot<br /> GetActiveSnapshot(void)<br /> {<br /> …<br /> return ActiveSnapshot-&gt;as_snap;<span>//invalid ActiveSnapshot fires Segmentation fault</span><br /> }<br />

Goes to bdr_apply.c in BDR package, I found out that ActiveSnapshot is set and cleared with PushActiveSnapshot and PopActiveSnapshot calls respectively in process_remote_update and process_remote_delete functions but not in process_remote_insert .

Then, I apply the function pair in process_remote_insert at the point before and after UserTableUpdateOpenIndexes calls :


...
PushActiveSnapshot(GetTransactionSnapshot());
if (conflict)
{

if (apply_update)

{

UserTableUpdateOpenIndexes(estate, newslot);

}

}

else

{

simple_heap_insert(rel->rel, newslot->tts_tuple);

UserTableUpdateOpenIndexes(estate, newslot);

}

PopActiveSnapshot();

Rebuild and reinstall the BDR package. Now no more replication crashes caused by updating index on expression written in SQL language. Case closed.

原文  https://abdulyadi.wordpress.com/2015/12/29/bdr-0-9-3-and-index-on-expression-part-3-solved/

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » BDR 0.9.3 and Index on Expression (Part 3 – Solved)

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
分享按钮