Hi Daniel,

thank you for your response.
As you can see in the provided debug output:

kamailio[]: DEBUG: htable [ht_api.c:1046]: ht_table_spec(): htable
[callpush] - dbmode [1]
kamailio[]: DEBUG: htable [ht_api.c:1027]: ht_table_spec(): htable
[callpush] - dbtable [userpush]
kamailio[]: DEBUG: htable [ht_api.c:1036]: ht_table_spec(): htable
[callpush] - expire [86400]
kamailio[]: DEBUG: htable [ht_api.c:1041]: ht_table_spec(): htable
[callpush] - size [10]

dbmode is set to 1 in the config:

modparam("htable", "db_url", "sqlite:////etc/kamailio/htable.sqlite")
...
modparam("htable", "htable", "userpush=>size=3;autoexpire=600;dbtable=userpush;dbmode=1")


If I execute
kamcmd htable.store userpush

I get
Ok. Htable successfully stored to DB.

But the table is still empty!!!

In the log I found:
ERROR: db_sqlite [dbase.c:528]: db_sqlite_commit(): sqlite commit failed: attempt to write a readonly database
ERROR: db_sqlite [dbase.c:177]: db_sqlite_cleanup_query(): finalize failed: attempt to write a readonly database
ERROR: htable [ht_db.c:668]: ht_db_delete_records(): failed to delete db records in [userpush]
ERROR: db_sqlite [dbase.c:528]: db_sqlite_commit(): sqlite commit failed: attempt to write a readonly database

Ok.
But I can not see this entries if I shutdown kamailio.

And:
-rw-rw-rw-  1 kamailio root 16384 Jul 13 16:14 htable.sqlite


I never used:
modparam("db_sqlite","db_set_readonly" ...

I also restarted kamailio. no difference.

Now more errors then before:
It is not written at shutdown. (no messages)
It is not written (live) (with error messages, but why it is readonly?)
The message of kamcmd is wrong (says Ok but it failed)

Best regards,

Bernd



Am 17.07.2023 um 08:48 schrieb Daniel-Constantin Mierla:
Hello,

is dbmode=1 in htable definition?

If you run rpc command htable.store for the htable, are the records
saved to database?

Cheers,
Daniel

On 13.07.23 17:45, Bernd Krueger-Knauber wrote:
Hi,

I just tried to use sqlite and htable to load and save the values.
At start I can see in the log, that all parameters are correct and
that htable want to load the values from the table.
No errors.

But if I stop kamailio, nothing is written to the tables.

At start I can see:

kamailio[]: DEBUG: <core> [core/modparam.c:112]:
set_mod_param_regex(): 'htable' matches module 'htable'
kamailio[]: DEBUG: <core> [core/sr_module.c:814]: find_param_export():
found <htable> in module htable
[/usr/lib/x86_64-linux-gnu/kamailio/modules/htable.so]
kamailio[]: DEBUG: <core> [core/modparam.c:128]:
set_mod_param_regex(): found <htable> in module htable
[/usr/lib/x86_64-linux-gnu/kamailio/modules/htable.so]
kamailio[]: DEBUG: htable [ht_api.c:1046]: ht_table_spec(): htable
[callpush] - dbmode [1]
kamailio[]: DEBUG: htable [ht_api.c:1027]: ht_table_spec(): htable
[callpush] - dbtable [userpush]
kamailio[]: DEBUG: htable [ht_api.c:1036]: ht_table_spec(): htable
[callpush] - expire [86400]
kamailio[]: DEBUG: htable [ht_api.c:1041]: ht_table_spec(): htable
[callpush] - size [10]



kamailio[]: DEBUG: htable [ht_api.c:1084]: ht_db_load_tables():
loading db table [userpush] in ht [userpush]
kamailio[]: DEBUG: htable [ht_db.c:232]: ht_db_load_table():
=============== loading hash table [userpush] from database [userpush]
kamailio[]: DEBUG: db_sqlite [dbase.c:223]: db_sqlite_submit_query():
submit_query: select key_name,key_type,value_type,key_value from
userpush  order by key_name
kamailio[]: DEBUG: <core> [db_query.c:72]: db_do_submit_query():
submitted query: select key_name,key_type,value_type,key_value from
userpush  order by key_name, result 0
kamailio[]: DEBUG: <core> [db_res.c:119]: db_new_result(): allocate 56
bytes for result set at 0x7f4882107938
kamailio[]: DEBUG: <core> [db_res.c:79]: db_free_columns(): freeing 0
columns
kamailio[]: DEBUG: <core> [db_res.c:138]: db_free_result(): freeing
result set at 0x7f4882107938

Ok, the file is empty, but it tries to load the data from the table.

The table looks like:

sqlite> .schema userpush
CREATE TABLE userpush (
        key_name TEXT,
        "key_type" INTEGER,
        value_type INTEGER,
        key_value TEXT
);


I checked the source code and I saw that destroy() should be called.
Inside is ht_db_open_con() called before ht_db_sync_tables(), were it
happens.
But I can even not see the debug message from ht_db_open_con() :

LM_DBG("database connection opened successfully\n")
and also not
LM_ERR("failed to connect to the database\n");

For me it looks like, that the destroy() function is not called.

Even with debug=3, I can only see:


systemd[]: Stopping kamailio.service - Kamailio - the Open Source SIP
Server...
kamailio[]: INFO: <core> [main.c:854]: sig_usr(): signal 15 received
systemd[]: kamailio.service: Deactivated successfully.
systemd[]: Stopped kamailio.service - Kamailio - the Open Source SIP
Server.

I stopped kamailio with

systemctl stop kamailio

I'm sure that something was inside the htable before I stoped kamailio:

{
        entry: 0
        size: 1
        slot: {
                {
                        name:
07db580a6c13e798a5acc0d123d6e957897c8650b43f99d6d5cb9c2cb5ba4fa4
                        value:
3a28dcb73eb65722df5a261983b7692cecdca482bf8725032e46a0c6b89fb355
                        type: str
                }
        }
}

Any further ideas?

Best regards,

Bernd



__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only
to the sender!
Edit mailing list options or unsubscribe:


-- 
EDNT GmbH
Werner-von-Siemens-Strasse 7
64625 Bensheim
www.ednt.de

Registergericht: Darmstadt
Registernummer: 24972

Geschäftsführer: Karlheinz Knapp