From a93a7fc66d6c99b594e8b0d7b2cd78229b306b87 Mon Sep 17 00:00:00 2001
From: Alexandr Lyapunov <a.lyapunov@corp.mail.ru>
Date: Wed, 26 Aug 2015 11:58:19 +0300
Subject: [PATCH] Added test for gh-962 : index:delete() failed

---
 test/wal_off/oom.result   | 60 +++++++++++++++++++++++++++++++++++++++
 test/wal_off/oom.test.lua | 26 +++++++++++++++++
 2 files changed, 86 insertions(+)

diff --git a/test/wal_off/oom.result b/test/wal_off/oom.result
index 2098f27257..c629d46623 100644
--- a/test/wal_off/oom.result
+++ b/test/wal_off/oom.result
@@ -203,3 +203,63 @@ space:drop()
 t = nil
 ---
 ...
+-- https://github.com/tarantool/tarantool/issues/962 index:delete() failed
+--# stop server default
+--# start server default
+arena_bytes = box.cfg.slab_alloc_arena * 1024 * 1024 * 1024
+---
+...
+str = string.rep('a', 15000) -- about size of index memory block
+---
+...
+space = box.schema.space.create('tweedledum')
+---
+...
+index = space:create_index('primary', { type = 'hash' })
+---
+...
+for i=1,10000 do space:insert{i, str} end
+---
+- error: Failed to allocate 15019 bytes in slab allocator for tuple
+...
+definatelly_used = index:count() * 16 * 1024
+---
+...
+2 * definatelly_used > arena_bytes -- at least half memory used
+---
+- true
+...
+to_del = index:count()
+---
+...
+for i=1,to_del do space:delete{i} end
+---
+...
+index:count()
+---
+- 0
+...
+for i=1,10000 do space:insert{i, str} end
+---
+- error: Failed to allocate 15019 bytes in slab allocator for tuple
+...
+definatelly_used = index:count() * 16 * 1024
+---
+...
+2 * definatelly_used > arena_bytes -- at least half memory used
+---
+- true
+...
+space:truncate()
+---
+...
+index:count()
+---
+- 0
+...
+space:drop()
+---
+...
+str = nil
+---
+...
diff --git a/test/wal_off/oom.test.lua b/test/wal_off/oom.test.lua
index f269c68a68..2ebdf96f81 100644
--- a/test/wal_off/oom.test.lua
+++ b/test/wal_off/oom.test.lua
@@ -75,3 +75,29 @@ space:select{}
 --
 space:drop()
 t = nil
+
+-- https://github.com/tarantool/tarantool/issues/962 index:delete() failed
+--# stop server default
+--# start server default
+arena_bytes = box.cfg.slab_alloc_arena * 1024 * 1024 * 1024
+str = string.rep('a', 15000) -- about size of index memory block
+
+space = box.schema.space.create('tweedledum')
+index = space:create_index('primary', { type = 'hash' })
+
+for i=1,10000 do space:insert{i, str} end
+definatelly_used = index:count() * 16 * 1024
+2 * definatelly_used > arena_bytes -- at least half memory used
+to_del = index:count()
+for i=1,to_del do space:delete{i} end
+index:count()
+
+for i=1,10000 do space:insert{i, str} end
+definatelly_used = index:count() * 16 * 1024
+2 * definatelly_used > arena_bytes -- at least half memory used
+space:truncate()
+index:count()
+
+space:drop()
+str = nil
+
-- 
GitLab