Crashes with postgresql backend when creating tables
I have been using the sqlite backend of libgda 6, but want to make it configurable to also use a postgresql backend. However, during the initialization, when trying to create database tables, I get random crashes with the postgresql backend. It seems to me, it might be a threading issue.
Basically the process is:
- Create the Base Tables
- Insert the schema migration
- Run through each migration, inserting new tables
With the first, run, it usually crashes after the first two steps. If I manually set the schema, and run it again, it starts on the migrations, runs the first (and only migration), then crashes again.
Here is the first backtrace:
malloc(): unaligned tcache chunk detected
Thread 27 "gdaWrkrTh0" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fff7b7fe6c0 (LWP 51606)]
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44 return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;
(gdb) bt
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1 0x00007ffff6d188b3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2 0x00007ffff6cc7abe in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x00007ffff6cb087f in __GI_abort () at abort.c:79
#4 0x00007ffff6cb160f in __libc_message (fmt=fmt@entry=0x7ffff6e2b52f "%s\n") at ../sysdeps/posix/libc_fatal.c:150
#5 0x00007ffff6d22775 in malloc_printerr (str=str@entry=0x7ffff6e2e898 "malloc(): unaligned tcache chunk detected") at malloc.c:5651
#6 0x00007ffff6d26e8c in tcache_get (tc_idx=<optimized out>) at malloc.c:3171
#7 __GI___libc_malloc (bytes=96) at malloc.c:3289
#8 0x00007ffff6ec5ec6 in xmlNewPropInternal (node=0x7fff680bcca0, ns=0x0, name=0x7fff68095644 "nullok", value=0x0, eatname=0)
at /usr/src/debug/libxml2-2.10.4-1.fc38.x86_64/tree.c:1875
#9 0x00007ffff6f69845 in xmlSAX2AttributeNs
(ctxt=0x7fff68067420, localname=0x7fff68095644 "nullok", prefix=0x0, value=0x7fff6808a5b1 "FALSE\" name=\"Name\" descr=\"Table's name\">\n <gda_value>table_name</gda_value>\n
</parameter>\n <parameter id=\"TABLE_TABLESPACE\" gdatype=\"gchararray\" nullok=\"TRUE\" name=\"Tablespace\" />\n <para"..., valueend=0x7fff6808a5b6 "\" name=\"Name\" descr=\"Ta
ble's name\">\n <gda_value>table_name</gda_value>\n </parameter>\n <parameter id=\"TABLE_TABLESPACE\" gdatype=\"gchararray\" nullok=\"TRUE\" name=\"Tablespace\" />\n <para
meter"...) at /usr/src/debug/libxml2-2.10.4-1.fc38.x86_64/SAX2.c:2023
#10 0x00007ffff6f6bd26 in xmlSAX2StartElementNs
(ctx=0x7fff68067420, localname=<optimized out>, prefix=<optimized out>, URI=<optimized out>, nb_namespaces=<optimized out>, namespaces=<optimized out>, nb_attributes=5, nb_defaulted
=<optimized out>, attributes=<optimized out>) at /usr/src/debug/libxml2-2.10.4-1.fc38.x86_64/SAX2.c:2415
#11 0x00007ffff6f8918b in xmlParseStartTag2.constprop.0 (ctxt=<optimized out>, pref=0x7fff7b7fd468, URI=0x7fff7b7fd460, tlen=<optimized out>)
at /usr/src/debug/libxml2-2.10.4-1.fc38.x86_64/parser.c:9664
#12 0x00007ffff6ebf9d4 in xmlParseElementStart (ctxt=ctxt@entry=0x7fff68067420) at /usr/src/debug/libxml2-2.10.4-1.fc38.x86_64/parser.c:10051
#13 0x00007ffff6ebff58 in xmlParseContentInternal (ctxt=0x7fff68067420) at /usr/src/debug/libxml2-2.10.4-1.fc38.x86_64/parser.c:9916
#14 0x00007ffff6ec00d8 in xmlParseElement (ctxt=0x7fff68067420) at /usr/src/debug/libxml2-2.10.4-1.fc38.x86_64/parser.c:9991
#15 0x00007ffff6ec6c72 in xmlParseDocument (ctxt=ctxt@entry=0x7fff68067420) at /usr/src/debug/libxml2-2.10.4-1.fc38.x86_64/parser.c:10828
#16 0x00007ffff6ec783c in xmlSAXParseMemoryWithData
(sax=sax@entry=0x0, buffer=buffer@entry=0x7fff68098830 "<serv_op>\n <parameters id=\"TABLE_DEF_P\" name=\"Table's description\">\n <parameter id=\"TABLE_NAME\" gdatype=\"gcharar
ray\" nullok=\"FALSE\" name=\"Name\" descr=\"Table's name\">\n <gda_value>table_name</g"..., size=6283, recovery=recovery@entry=0, data=data@entry=0x0)
at /usr/src/debug/libxml2-2.10.4-1.fc38.x86_64/parser.c:14417
#17 0x00007ffff6ec78ac in xmlSAXParseMemory
(sax=sax@entry=0x0, buffer=buffer@entry=0x7fff68098830 "<serv_op>\n <parameters id=\"TABLE_DEF_P\" name=\"Table's description\">\n <parameter id=\"TABLE_NAME\" gdatype=\"gcharar
ray\" nullok=\"FALSE\" name=\"Name\" descr=\"Table's name\">\n <gda_value>table_name</g"..., size=<optimized out>, recovery=recovery@entry=0)
at /usr/src/debug/libxml2-2.10.4-1.fc38.x86_64/parser.c:14449
#18 0x00007ffff6ec78c2 in xmlParseMemory
(buffer=buffer@entry=0x7fff68098830 "<serv_op>\n <parameters id=\"TABLE_DEF_P\" name=\"Table's description\">\n <parameter id=\"TABLE_NAME\" gdatype=\"gchararray\" nullok=\"FALS
E\" name=\"Name\" descr=\"Table's name\">\n <gda_value>table_name</g"..., size=<optimized out>) at /usr/src/debug/libxml2-2.10.4-1.fc38.x86_64/parser.c:14463
#19 0x00007ffff70943bf in gda_server_operation_set_property (object=<optimized out>, param_id=<optimized out>, value=<optimized out>, pspec=0x7fff6805f8c0)
at ../libgda/gda-server-operation.c:629
#20 0x00007ffff7e1b71a in object_set_property (object=object@entry=0x7fff680adf10, pspec=0x7fff6805f8c0, value=0x7fff7b7fd918, nqueue=nqueue@entry=0x0, user_specified=<optimized out>)
at ../gobject/gobject.c:1812
#21 0x00007ffff7e1c028 in g_object_new_internal (class=0x7fff6806d5e0, params=0x7fff7b7fd800, n_params=4) at ../gobject/gobject.c:2291
#22 0x00007ffff7e1e163 in g_object_new_internal (n_params=4, params=0x7fff7b7fd800, class=0x7fff6806d5e0) at ../gobject/gobject.c:2563
#23 g_object_new_valist (object_type=<optimized out>, first_property_name=first_property_name@entry=0x7fffcc3b3295 "op-type", var_args=var_args@entry=0x7fff7b7fdad0)
at ../gobject/gobject.c:2585
#24 0x00007ffff7e1e51f in g_object_new (object_type=<optimized out>, first_property_name=first_property_name@entry=0x7fffcc3b3295 "op-type") at ../gobject/gobject.c:2058
#25 0x00007fffcc3a0abc in gda_postgres_provider_create_operation
(provider=0x2a60a40, cnc=0x2c87630, type=GDA_SERVER_OPERATION_CREATE_TABLE, options=<optimized out>, error=<optimized out>) at ../providers/postgres/gda-postgres-provider.c:840
#26 0x00007ffff70f0f41 in worker_thread_main (worker=0x4998f0) at ../libgda/thread-wrapper/gda-worker.c:213
--Type <RET> for more, q to quit, c to continue without paging--
#27 0x00007ffff7ee1983 in g_thread_proxy (data=0x29d2e50) at ../glib/gthread.c:831
#28 0x00007ffff6d16907 in start_thread (arg=<optimized out>) at pthread_create.c:444
#29 0x00007ffff6d9c870 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
If I then manually set the schema to 1
in the schema_migrations table, and run it again (so it starts at step 3), then it creates the new config table, then crashes again:
malloc_consolidate(): unaligned fastbin chunk detected
Thread 27 "gdaWrkrTh0" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fff937fe6c0 (LWP 52708)]
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44 return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;
(gdb) bt
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1 0x00007ffff6d188b3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2 0x00007ffff6cc7abe in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x00007ffff6cb087f in __GI_abort () at abort.c:79
#4 0x00007ffff6cb160f in __libc_message (fmt=fmt@entry=0x7ffff6e2b52f "%s\n") at ../sysdeps/posix/libc_fatal.c:150
#5 0x00007ffff6d22775 in malloc_printerr (str=str@entry=0x7ffff6e2e130 "malloc_consolidate(): unaligned fastbin chunk detected") at malloc.c:5651
#6 0x00007ffff6d2330c in malloc_consolidate (av=av@entry=0x7fff70000030) at malloc.c:4736
#7 0x00007ffff6d25958 in _int_malloc (av=av@entry=0x7fff70000030, bytes=bytes@entry=2048) at malloc.c:3951
#8 0x00007ffff6d26c34 in __GI___libc_malloc (bytes=bytes@entry=2048) at malloc.c:3305
#9 0x00007fffcc32c99a in pqResultAlloc (res=res@entry=0x7fff700700f0, nBytes=nBytes@entry=416, isBinary=isBinary@entry=true)
at /usr/src/debug/libpq-15.3-1.fc38.x86_64/src/interfaces/libpq/fe-exec.c:630
#10 0x00007fffcc3378cd in getRowDescriptions (msgLength=<optimized out>, conn=<optimized out>) at /usr/src/debug/libpq-15.3-1.fc38.x86_64/src/interfaces/libpq/fe-protocol3.c:542
#11 pqParseInput3 (conn=conn@entry=0x7fff700034f0) at /usr/src/debug/libpq-15.3-1.fc38.x86_64/src/interfaces/libpq/fe-protocol3.c:322
#12 0x00007fffcc338086 in parseInput (conn=0x7fff700034f0) at /usr/src/debug/libpq-15.3-1.fc38.x86_64/src/interfaces/libpq/fe-exec.c:2011
#13 PQgetResult (conn=conn@entry=0x7fff700034f0) at /usr/src/debug/libpq-15.3-1.fc38.x86_64/src/interfaces/libpq/fe-exec.c:2097
#14 0x00007fffcc338505 in PQexecFinish (conn=0x7fff700034f0) at /usr/src/debug/libpq-15.3-1.fc38.x86_64/src/interfaces/libpq/fe-exec.c:2414
#15 0x00007fffcc339c6f in PQexecPrepared (conn=<optimized out>, stmtName=0x7fff937fdaa0 "\300\333\177\223\377\177", nParams=32767,
nParams@entry=0, paramValues=paramValues@entry=0x0, paramLengths=paramLengths@entry=0x0, paramFormats=paramFormats@entry=0x0, resultFormat=0)
at /usr/src/debug/libpq-15.3-1.fc38.x86_64/src/interfaces/libpq/fe-exec.c:2322
#16 0x00007fffcc3affd0 in gda_postgres_provider_statement_execute
(provider=0x2a4df80, cnc=0x2c0d540, stmt=0x2b904d0, params=0x0, model_usage=<optimized out>, col_types=0x0, last_inserted_row=0x0, error=0x2ca9208)
at ../providers/postgres/gda-postgres-provider.c:2293
#17 0x00007ffff709f2cb in worker_statement_execute (data=0x7fffffffc750, error=0x2ca9208) at ../libgda/gda-server-provider.c:2526
#18 0x00007ffff70f0f41 in worker_thread_main (worker=0x2a41000) at ../libgda/thread-wrapper/gda-worker.c:213
#19 0x00007ffff7ee1983 in g_thread_proxy (data=0x2a603e0) at ../glib/gthread.c:831
#20 0x00007ffff6d16907 in start_thread (arg=<optimized out>) at pthread_create.c:444
#21 0x00007ffff6d9c870 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
However, it does successfully create the table and update the schema version back to 2. If you run a 3rd time, the migrations are done, and there are no issues inserting, querying, and doing other operations on data.
Again, I have no issues with SQLite as the backend.
The code is available here (in the CC-10 branch): https://github.com/line72/campcounselor/blob/CC-10/src/Database.vala
I've also tried wrapping the create_database in a begin/commit_transaction, but I still get a similar crash.