Postgresql Transaction ID Not Found - postgresql

Whenever I am executing a query in postgresql, this is the error message I receive
Transaction ID not found in the session.
Does anyone have any idea how to resolve this? I recently created a new user, but I was unable to find documentation that even shows this as a valid error.
Additional Details:
I've managed to resolve the error by re-connecting with admin credentials.
I was using PG Admin V4 with Postgres V9.6, and that was the only message appearing in any query I executed, even if it was a basic query like 'SELECT NOW()'.
At the same time, this was the error message being received by the client device (an iOS device with a AWS Lambda / NodeJS backend) :
'message' : {
'name' : 'error',
'length' : 114,
'severity' : 'fatal',
'code' : '28000',
'file' : 'miscinit.c',
'line' : '587',
'routine' : 'InitializeSessionUserId'
}

I assume you found a solution, but for anyone else that finds this post, I had the same issue and I just closed PG Admin 4 and restarted it and it cleared up.

To anyone who has this problem, all you have to do is:
1) Reconnect to the database
2) Open a new Query Tab. (Run your query here)
You're welcome.

For me helped changing 'localhost' in connection settings to '127.0.0.1', as mentioned here: https://stackoverflow.com/a/59747781/2590805

Disconnecting and reconnecting to the database solved this issue for me; it wasn't necessary to exit/open PGAdmin 4 completely.

Create a new Query editor tab, that works for me

This is not a PostgreSQL error message. It must come from something else in the stack you are using - a client driver, ORM, etc.
Please post a more detailed question with full information on the stack you're using.

So I don't know the exact specifics of my solution, but I found this issue in the following circumstance:
Database user was created.
Role was assigned for the user.
A transaction was used
I'm still not entirely sure I discovered the solution of the root problem, but if others have the same scenario, it might help troubleshoot it further. If any of those three are not used, then I never encountered the issue.

Has anyone found an explanation for this problem? I am also getting a "Transaction ID not found in the session.". It's for a long running (several days) query. I ran it on a 10% sample of my data and had no trouble, but now need to repeat the process for the full dataset. I reconnect to the database and the query appears as still active. A new idle query appears as follows:
SELECT rel.oid, rel.relname AS name,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount,
(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE AND tgenabled = 'O') AS has_enable_triggers,
(CASE WHEN rel.relkind = 'p' THEN true ELSE false END) AS is_partitioned
FROM pg_class rel
WHERE rel.relkind IN ('r','s','t','p') AND rel.relnamespace = 2200::oid
AND NOT rel.relispartition
ORDER BY rel.relname;

Related

Is there a way to stop this error "select * from "client_api_key" where "api_key" = $1 limit $2 - Connection terminated unexpectedly"

Im using adonis.js , I have the following query... When I make a request to my API this is the first database query. I get the above error only once every hour or so. Im using render.com to host my API and postgres database. I believe adonis.js uses knex and this maybe the problem but I am not sure.
const api_key_check = await database
.table('client_api_key')
.where('api_key', api_key_encoded)
.first()
It looks like knex have an open issue since node's 12 release.
Follow this thread and see if some proposed solution works for you:
https://github.com/knex/knex/issues/3523#issuecomment-722574083

SQL Developer and DB2 errors

I'd like to use SQL Developer with DB2, I was able to connect and I canned execute my queries, but when I have an error, I cannot know witch error is. SQL Developer shown me only the error code, not the message. There is the way to know the error I have?
EDIT:
For example, launching this query:
Select * from WrongTable
other programs says:
ERROR[42704][IBM][DB2/NT64] SQL0204N "USERNAME.WRONGTABLE" รจ un nome non definito
sqldeveloper limits its report to the error nr only:
Errore alla riga del comando : 1 colonna : 1
Report errori -
Errore SQL: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=USERNAME.WRONGTABLE, DRIVER=4.19.49
Thank you.
The URL syntax for connecting to Db2 with type-4 jdbc drivers is documented here.
The property that controls how much information is returned with getMessage() is called retrieveMessagesFromServerOnGetMessage, and its default value is disabled ( false , 0 ). Set it to value 1 (or YES, or true )to enable more details on errors.
You can append many properties after the database name in the Database field, on the Oracle SQL-Developer connection properties. Express each property in the form x=y , each x=y pair is separated by a semi-colon and the final one is terminated by a semi-colon, and the first property is prefixed by colon immediately after the database name.
For example, suppose the database name is sample and I wanted three additional properties, the I would put this in the Database field in Oracle-SQL-developer:
sample:useJDBC4ColumnNameAndLabelSemantics=No;securityMechanism=11;retrieveMessagesFromServerOnGetMessage=1;
If value 1 does not give the expected result, use value YES although they should be equivalent. Remember to SAVE the setting change, disconnect from the database, reconnect , before retrying your queries to assess the change.
Many other properties are available, see many related pages in the documentation , some properties are common to all target Db2 platforms, other properties are specific to Db2-LUW, or Db2-Z/OS, or Informix etc, so read the docs carefully. Some properties can be set by code after the connection is already established.

IBM DB2 Textsearch SQLSTATE 38H13 / Conflicting process on text search admin function

Im a using the IBM DB2 Text Search Index (DB2TS) on LUW, latest version. The statements are executed in the IBM Data Studio, latest Version as DB2ADMIN.
From time to time I execute
CALL SYSPROC.SYSTS_UPDATE('M2F', 'IX_X3_2DEDEMSJ', '', 'en_US', ?)
to update the index.
One Index (of 10) is not updateable. The error codes are SQLCODE=-20426, SQLSTATE=38H13.
It says: A text search management function is in conflict with a pending/running function.
CALL SYSPROC.SYSTS_DROP('M2F', 'IX_X3_2DEDEMSJ', '', 'en_US', ?)
I tried to DROP the Index -> Same error
I tried to CLEAR the messages events -> Same error
I restartet the database, the DB2TS-service and at least the whole server.
Still the same message. Is there anybody out there who has an idea?
How can I see the pending tasks on an index? Is it possible to cancel tasks by command?
Many thanks :-)
Oliver
I found the solution by myself:
CALL SYSPROC.SYSTS_CLEAR_COMMANDLOCKS('M2F', 'IX_X3_2DEDEMSJ', 'en_US', ?)
Link to IBM documentation

Firebird update statement freezes

After over one day of finding & trying to solve issue its time to ask here.
We use Firebird over years (around 6) and with current version 2.5.2 updated long time ago we met the problem with unable to UPDATE statement.
SQL statement is OK, even "where" condition is used with primary key.
Problem: update is going to stuck after click on: execute
a) from php script it return Internal server error 500
b) directly from Flamerobin or IBQ its freezes and not responding at all
hint: SQL which wasnt working is working right after clean firebird (stop & start) but after a while its going to stuck again
hint: selects are or, problem is only with UPDATE
hint: I did all described here https://www.ibphoenix.com/resources/documents/how_to/doc_5
(redump of database file which was giving me errors on gfix -v -full)
after redump there was no error but problem occurs
hint: We have more servers running the same configuration with more database files but this happen only for one table in one DB file on one server.
After some investigation I finally got this from fbtrace:
2016-11-28T14:25:28.4410 (9473:0x7f1489cb1f08) PREPARE_STATEMENT
phones.fdb (ATT_273856, VILAS:NONE, UTF8, TCPv4:10.1.1.195)
/usr/bin/flamerobin:10868
(TRA_78838, CONCURRENCY | WAIT | READ_WRITE)
Statement 422749:
-------------------------------------------------------------------------------
UPDATE TELEFONI_CISLA SET DATUM_PRIDANI = '2011-7-3' WHERE ID = '17274'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PLAN (TELEFONI_CISLA INDEX (RDB$PRIMARY4))
0 ms
2016-11-28T14:25:28.4780 (9473:0x7f1489cb1f08) EXECUTE_STATEMENT_START
phones.fdb (ATT_273856, VILAS:NONE, UTF8, TCPv4:10.1.1.195)
/usr/bin/flamerobin:10868
(TRA_78838, CONCURRENCY | WAIT | READ_WRITE)
Statement 422749:
-------------------------------------------------------------------------------
UPDATE TELEFONI_CISLA SET DATUM_PRIDANI = '2011-7-3' WHERE ID = '17274'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PLAN (TELEFONI_CISLA INDEX (RDB$PRIMARY4))
Im out of ideas what to check, almost lost. Just want let you know that we didnt change anything in FB or server configuration.
Thanks for any usefull help.
Everything was caused by one of many script running in background (from cron) taking open transaction without committing for few hours.
Its OK back again.

Error writing to database in moodle

I want to customize some strings into moodle. so when i clicked on open language pack for editing it will run till 69% and thowing an error "Error writing to database"
Error/moodle/dmlwriteexception
This indicates that a general error occurred when Moodle tried to write to the database. If you turn on Debugging you will get more detailed information about what the problem is.
MySQL
If you're using a MySQL database for your Moodle installation, this error can be caused by the server's max_allowed_packet size being configured incorrectly. Increasing this value may resolve the issue.
I have tried to increase the value of max_allowed_packet 1M to 100M but still getting the same error.
Please help me
Try putting the following settings in your config.php:
#ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS!
$CFG->debug = 32767; // NOT FOR PRODUCTION SERVERS! // for Moodle 2.0 - 2.2, use: $CFG->debug = 38911;
$CFG->debugdisplay = true; // NOT FOR PRODUCTION SERVERS!
That should tell you more about the query that is causing the error, and help resolve your problem.
When your'e done with debugging please remove these lines, since they may cause a security risk.
Source: https://docs.moodle.org/23/en/Debugging#In_config.php
Its probably a custom plugin with an incorrect string id in the language file - https://moodle.org/mod/forum/discuss.php?d=222815
Try uninstalling any custom modules then trying again with the language customisation until you can identify which custom plugin is causing the issue.
So I'm not sure if this is related, but since I received the exact same message, I', assuming so.
I am new to Moodle, and tried to install it locally on my machine. Once I was comfortable with that I migrated it to a hosted environment. I am certain I did not execute the process correctly in terms of user permissions, since as soon as I migrated the instance I started getting the "error writing to database" exception.
After a lot of research, and after trying many solutions that did not work, I eventually found something that did. It is dangerous to do this on a database that has records already written to it, however the solution was to drop the 'id' column of the effected table and add it again with auto_increment on:
Step 1: Turn on Debugging in the Page settings of your Moodle site. Any database insert will then likely return en error like this"
Debug info: Field 'id' doesn't have a default value
INSERT INTO mdl_course_sections (course,section,summary,summaryformat,sequence,name,visible,availability,timemodified) VALUES(?,?,?,?,?,?,?,?,?)
[array (
0 => '2',
1 => 10,
2 => '',
3 => '1',
4 => '',
5 => NULL,
6 => 1,
7 => NULL,
8 => 1548419949,
)]
Error code: dmlwriteexception
Step 2: Since this gives you the table name and the effected field, you can then exectue the following SQL statement:
ALTER TABLE {table_name} DROP COLUMN {column_name};
ALTER TABLE {table_name} ADD COLUMN {column_name} INT AUTO_INCREMENT UNIQUE FIRST;
As there are no restrictions here, dropping a column of primary keys, which are likely foreign keys in other tables, I would not advise this unless it is a fresh install. But it worked well for me.