AI Zone Admin Forum Add your forum

NEWS: survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

CS: writing some files to postgres

I thought postgres was working, but I started closing down the log writing and I decoded the postgres bytecode and I noticed it was not updating postrges with the user data. And it was throwing errors to the log file. “Postgres filessys write failed “

Well, i have been stuck trying to get postgres to work.
One file is writing to postgres, but this file is not.
not working: USERS/topic_100125174_harry.txt
working: USERS/topic_100125174_share.txt

BUG: Wed Jun 05 23:46:36 2019: input:1 Postgres filessys write failed for USERS/topic_100125174_harry.txt caller:100125174 callee:harry at in sentence: hey ya
Postgres filessys write failed for USERS/topic_100125174_harry.txt
MinReleaseStackGap 79MB MinHeapAvailable 80MB
MaxBuffers used 7 of 80

However, I am writing to postgres. 
jul2116 Jun05’19-23:46:36 Jun05’19-23:46:36 0 |
1 1 0 DY 0 96 96 0 # start, input#, no rejoinder, #0topics, #1topics, layer2
~introductions ~common_questions_all #pending
#`end topics
#`end variables
0 #set flags
#`end fact sets
#`end user facts 0
hey ya
#`end user
What is new with you?
#`end chatbot

This is a deep mystery to me. I am not sure what could be wrong here. Do you have any thoughts, maybe?


  [ # 1 ]

I do not think this will be a real issue, as it appears to be only server traffic and not the actual user traffic.

I am going to add Noserverlog to the cs-init.txt file,  so I do not store a user-bot log.


  [ # 2 ]

noserver log refers to server log in LOGS. 
nouserlog refers to user logs in USERS except that bugs are still reported to user logs (i will fix that next release)

I dont know what you mean by server traffic


  [ # 3 ]

I guess i am calling this file server traffic
I dont know if this file is essential, because i am not able to write it to postgres.
I am writing the error that is above.
The other file,
Is writing to postgres,  which is great and it is a mystery why half of it works.
In any event, i cant tell if the file that is written is correct.
And if anything critical seems to be missing.

I will have to test it today and see if it is retaining the variables by doing a few volleys and checking :variables.



  [ # 4 ]

USERS/topic_*  are essential
and you are using shared bot capability which is why _share file exists


  [ # 5 ]

It seems to be working.

MY TEST: I opened up the web interface for three physically different servers, with different IP addresses, all pointing to the same postgres.
I sent the same message using the same name to all three.
All three messages show up in the postgres USERS/topic_1742251328_share.txt
There is no USERS/topic_1742251328_botname.txt file in postgres or the server USERS or LOGS directory.
I only see USERS/log-1742251328.txt

Maybe it is retrieving the _share file from postgres in all cases?
I do not know if there is a better way, but this seems to be working.
I guess it would be faster to write _botname file to local disk in each volley. And use this, if we could somehow identify that it is the latest USERS/topic_* by the volley count.  If not, go to postgres and get _share.
It would almost always be faster to do this, but I dont know if CS has this built in.
In any case, I don’t know how I can test that it does not work.
Also, memory for new facts works between the servers. It remembers my name across servers, when supplied….

So, maybe it is working (?)

jul2116 Jun07’19-14:46:48 Jun07’19-14:47:12 0 |
1 3 ~introductions WPb F39R?Is*Ok3 DY 0 390 390 0 # start, input#, rejoindertopic,rejoinderid (a:  ( [ ~yes ~goodness ] $share_name?~boynameus ) Ok ^pick ( ~mmm ) great ^pick ( ~mmm ) $sh…  ),checksum
~cs_activities ~introductions #pending
#`end topics
#`end variables
0 #set flags
#`end fact sets
#`end user facts 0
#`end user
XXX You do yoga XXX
XXX That is great. how are you called? XXX
XXX I will call you bang. Ok there?  XXX  
#`end chatbot


  [ # 6 ]

I was testing and it is saving the files to postgres, but it is not saving the
USERS/topic_172314442_harry.txt3 Wed Jul 31 06:46:51 2019
it is, however, saving this file: USERS/topic_172314442_share.txt
so, it looks like it worked, but it does not

“Postgres filessys write failed ”

i have will to check the postgres logs and maybe trace through it


  [ # 7 ]

ok, I think I found the issue. If you are using postgres, it writes the topic file as bytea to the database.
Bytea no longer supports “\” without additional encoding.
The file sometimes includes this character.

if you have any code which looks like this:
$somename001 = “Some value”
you have to add the ^ to it, like this
$somename001 = ^“Some value”

This code sometimes ends up in the topic files, and postgres will not allow it.
So, I am going to regression test, but it looks like this is the fix.

pretty much, change all *.top files
= “
= ^”
unless it is related to an IF statement


  [ # 8 ]

is there a way I can adjust the TOPIC file and scan/replace where I see the “\” ?

i guess the other option would be to change the database column from bytea to something else, like character varying,  but this would require some changes to the postgres code, and database redefinition


  [ # 9 ]

OK. The way to work around this is to change the postgres database to allow the special characters.
You can do this within the database parameters in postgres or in the aws console.
here are the settings.

SET standard_conforming_strings = off;
SET escape_string_warning = off;
SET backslash_quote = on;

You will probably need to bounce the database to set these.
And any server connected to postgres will probably need to be reset.

Use this sql form the console to check that hey are set.
SHOW standard_conforming_strings;
SHOW escape_string_warning;
SHOW backslash_quote;

I just tested it and it finally works.


  login or register to react