ligurio / molly

Framework for distributed system's verification, with fault injection.
https://ligurio.github.io/molly/
ISC License
11 stars 2 forks source link

Is not parallel postgresql connection. #9

Open akalend opened 1 month ago

akalend commented 1 month ago

The code of postgresql rw-test usingmolly. After first or second call method invoike the connection was closed. It can check parallel sql command:

SELECT client_addr,pid,usename,application_name FROM pg_stat_activity;

So, it can look in output trace:

Run PostgreSQL examples with Tarantool
setup
setup
setup
setup
setup
teardown
class:  table: 0x7f7ef8691d40
close 
teardown
[INFO  2024-06-13 10:50:29:87823 ]: ERROR: test/examples/pgsql-rw-register.lua:90: calling 'execute' on bad self (LuaSQL: connection is closed)
teardown
[INFO  2024-06-13 10:50:29:87871 ]: ERROR: test/examples/pgsql-rw-register.lua:90: calling 'execute' on bad self (LuaSQL: connection is closed)
teardown
[INFO  2024-06-13 10:50:29:87889 ]: ERROR: test/examples/pgsql-rw-register.lua:90: calling 'execute' on bad self (LuaSQL: connection is closed)
teardown
[INFO  2024-06-13 10:50:29:87908 ]: ERROR: test/examples/pgsql-rw-register.lua:90: calling 'execute' on bad self (LuaSQL: connection is closed)
akalend commented 1 month ago

So, see pg_rw_register.teardown () method: assert(self.con:execute("INSERT INTO log_register VALUES(1)"))

For 5 open connections must be 5 records, is only one.

akalend commented 1 month ago

The simple corutine model have 5 connections constantly:

function testdb(n) local luasql = require "luasql.postgres" local env = assert (luasql.postgres()) local con = assert (env:connect('test2', 'postgres', nil, "127.0.0.1", 5432))

coroutine.yield(n)

local query = string.format("SELECT * FROM rw_register where val=%d", n) local cur = assert(con:execute(query)) print(query) coroutine.yield(query)

local row = cur:fetch ({}, "a") local count = 0 while row do print(string.format("%d %d", row.val, row.ver )) row = cur:fetch (row, "a") count = count + 1 end

coroutine.yield(count)

cur:close() con:close() env:close()

end