Created
April 15, 2019 07:21
-
-
Save R-omk/2ed809c0f890fef98882596e82d9f8ba to your computer and use it in GitHub Desktop.
tarantool Segmentation fault transaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
box.cfg { | |
memtx_max_tuple_size = 1048576 + 200; | |
force_recovery = true; | |
} | |
local fiber = require('fiber') | |
local function dd(...) | |
local x = debug.getinfo(2) | |
local dbg = string.format('[%s:%d][%s]', x.source, x.currentline, x.name) | |
local formatter_yaml = require('yaml').new() | |
formatter_yaml.cfg { | |
encode_invalid_numbers = true; | |
encode_load_metatables = true; | |
encode_use_tostring = true; | |
encode_invalid_as_nil = true; | |
} | |
require('log').info('\n ++VAR DUMP++ %s %s \n %s', dbg, | |
require('json').encode({ debug.traceback() }), | |
formatter_yaml.encode({ ... })) | |
end | |
dd('start !!!!') | |
local engine = 'vinyl'; | |
box.internal.sql_create_function('WAITFOR', 'INT', function(n) | |
require('fiber').sleep(n) | |
return n | |
end) | |
box.execute('pragma sql_default_engine=\'' .. engine .. '\'') | |
box.execute("CREATE TABLE INTVIEW (key VARCHAR(100) PRIMARY KEY, data INTEGER);") | |
box.execute("CREATE TABLE STRINGVIEW (key VARCHAR(100) PRIMARY KEY, data VARCHAR(100));") | |
box.execute("CREATE TABLE HISTORY (id INTEGER PRIMARY KEY AUTOINCREMENT, data VARCHAR(100));") | |
local intvalue = 10; | |
local strvalue = intvalue .. '' | |
box.execute("INSERT INTO INTVIEW VALUES ('v1' , ?);", {intvalue}) | |
box.execute("INSERT INTO STRINGVIEW VALUES ('v1' , ?);", {strvalue}) | |
-- view | |
fiber.create(function() | |
for id = 1, 300 do | |
fiber.sleep(0.2) | |
local st, err = pcall(function(id) | |
box.execute('START TRANSACTION;') | |
box.execute("UPDATE INTVIEW SET data = ? WHERE key = 'v1';", {id}) | |
box.execute("UPDATE STRINGVIEW SET data = ? WHERE key = 'v1';", {id..''}) | |
box.commit() | |
end, id) | |
if not st then | |
dd('VIEW transaction', st, err) | |
end | |
end | |
end) | |
-- HISTORY | |
fiber.create(function() | |
for id = 1, 5 do | |
fiber.sleep(1) | |
local st, err = pcall(function(id) | |
box.execute('START TRANSACTION;') | |
-- box.execute("INSERT INTO HISTORY VALUES (NULL , ?);", {'start transaction' .. id}) | |
box.execute('SELECT WAITFOR(1) AS S') | |
local intview = box.execute("SELECT data FROM INTVIEW WHERE key = 'v1'") | |
dd('intview', id, intview) | |
box.execute('SELECT WAITFOR(1) AS S') | |
local stringview = box.execute("SELECT data FROM STRINGVIEW WHERE key = 'v1'") | |
dd('stringview', id, stringview) | |
box.execute('SELECT WAITFOR(1) AS S') | |
local res = intview['rows'][1][1] .. ' is ' .. stringview['rows'][1][1] | |
box.execute("INSERT INTO HISTORY VALUES (NULL , ?);", { res}) | |
box.commit() | |
end, id) | |
dd('HISTORY transaction', st, err) | |
end | |
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
tnt: | |
command: "tarantool /opt/tarantool/app.lua" | |
image: tarantool/tarantool:2 | |
volumes: | |
- "./app.lua:/opt/tarantool/app.lua" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLEAN: | |
docker-compose down -v | |
START: | |
docker-compose up | |
RUN: CLEAN START |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment