SOCI/soci

[sqlite] [win10] [x64] soci sqlite 3.6.18 when i use serialized threads mode,sql->prepare competition dblock

stan1334 opened this issue · 5 comments

continue query, 100ms once

soci::details::prepare_temp_type temp(*pSession);
            getTempType(temp, args...);
            temp = (pSession->prepare << strSql, temp);
            soci::rowset<soci::row>rs = temp;

            for (const soci::row& rowData : rs) {

continue insert, single write 1000 ,by orm

				soci::transaction tr(*sql);
				T insertData;
				soci::statement st = (sql->prepare << strSql, SQL_USE(insertData));

				for (auto& data : datas) {
					insertData = data;
					st.execute(true);
					errroIndex++;
				}
				tr.commit();

OS:win10 X64

i see the sqlite doc

https://www.sqlite.org/c3ref/open.html

SQLITE_CONFIG_MULTITHREAD mode ,if session isnot on same thread will sql->prepare competition dblock

but i use serialized mode

soci sourcecode sqlite statement perper use sqlite3_prepare_v2,

soci\src\backends\sqlite3\statement.cpp

void sqlite3_statement_backend::prepare(std::string const & query,
    statement_type /* eType */)
{
    clean_up();

    char const* tail = 0; // unused;
    int const res = sqlite3_prepare_v2(session_.conn_,
                              query.c_str(),
                              static_cast<int>(query.size()),
                              &stmt_,
                              &tail);

@mloskot
@vadz

I hope to get your guidance, tku

vadz commented

Sorry, I don't understand at all what the problem is, you really need to explain it better.

Also, please don't tag people without any good reason, this won't help with getting a response.

sqlite serialized mode,
query and insert in different threads

select * from XXX,error_message:No sqlite statement created

vadz commented

I'm not sure SQLite is MT-safe, but I'm pretty sure that SOCI isn't, so if you're using the same object from different threads, it's not going to work.

No sqlite statement created

https://soci.sourceforge.net/doc/release/4.0/multithreading/
i know soci isnot support MT-safe,
but sqlite serialized mode support MT,so i will change crud 2 sqlite native API,compare with soci in serial mode。

session isnot support MT SAFE。

much thread read write use soci::connection_pool pool
soci::session sql(pool);

fixed