From c1a91e69fe234c93edbaa12ca68d4356a6b3eca3 Mon Sep 17 00:00:00 2001
From: Zardosht Kasheff <zardosht@tokutek.com>
Date: Wed, 17 Apr 2013 00:02:01 -0400
Subject: [PATCH] [t:2722], have end_bulk_insert call loader->abort if thread
 has been killed

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@21050 c7de825b-a66e-492c-adef-691d508d4ae1
---
 storage/tokudb/ha_tokudb.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc
index cd4c8758a5..8b53b5cce5 100644
--- a/storage/tokudb/ha_tokudb.cc
+++ b/storage/tokudb/ha_tokudb.cc
@@ -2902,6 +2902,7 @@ void ha_tokudb::start_bulk_insert(ha_rows rows) {
 int ha_tokudb::end_bulk_insert() {
     TOKUDB_DBUG_ENTER("ha_tokudb::end_bulk_insert");
     int error = 0;
+    THD* thd = ha_thd();
     if (ai_metadata_update_required) {
         pthread_mutex_lock(&share->mutex);
         error = update_max_auto_inc(share->status_block, share->last_auto_increment);
@@ -2912,7 +2913,7 @@ int ha_tokudb::end_bulk_insert() {
     ai_metadata_update_required = false;
     loader_error = 0;
     if (loader) {
-        if (!abort_loader) {
+        if (!abort_loader && !thd->killed) {
             error = loader->close(loader);
             loader = NULL;
             if (error) { goto cleanup; }
-- 
2.30.9