Discussion:
v2 problem, multiple duplicate events for a single query
Jason Moehlman
2006-07-19 20:09:15 UTC
Permalink
Hello,

I am new to using v2. I have been attempting to integrate v2 into an
existing project. Because of the structure I have also been trying
to as closely as possible mimick the function of the v1 code, more
linear or sequential operation.

I have run into a problem with an OutOfBounds error that seems to
occur with multiple events firing for a single simple query.

I have set breakpoints on every line of code in the cache and socket
event handlers. The exception is not generated in any of that code,
all very simple.

They only real indication of a problem was that the program recieved
2 sets of every event it has in the cache before dying with the
OutOfBounds exception I presume on the 3rd set of event calls.
DataRecieved, Ready, CommandCompleted, PopulateDone all fired
multiple times for the first and only statement the program tries to
execute before it's untimely death.

I was hoping someone else has seen some similar symptoms or can point
me in the right direction.

Thanks....Jason
Aliacta Support
2006-07-19 21:17:38 UTC
Permalink
[Jason already wrote to me off list.]
Post by Jason Moehlman
I am new to using v2. I have been attempting to integrate v2 into an
existing project. Because of the structure I have also been trying
to as closely as possible mimick the function of the v1 code, more
linear or sequential operation.
Since you're using a loop to wait for the query to finish, are you
doing this with an App.DoEvents? That would be a risk. (Search the
pdf manual for "App.DoEvents" to find detailed information about
this.) Using threads would be another explanation for similar
misbehavior.
Post by Jason Moehlman
I have run into a problem with an OutOfBounds error that seems to
occur with multiple events firing for a single simple query.
OutOfBounds generally suggests a ListBox that receives more than 64
rows. It hasn't to be bound through visual control binding, i.e.
binding a pgSQLlistBox with a cache through code is the same thing.
If I understood you correctly however you're not using any GUI
controls at all.

Please read the whole troubleshooting part of the manual as well
where you might find inspiration regarding the cause of your problem
or ways to investigate, e.g. using a log.

Also if you're doing this on Linux, have you tried to see how it
behaves on Windows or Mac--just to rule out an RB problem of this
nature.

Marc

PS: I'm on limited bandwidth once more for the coming months and
can't be sure I'll be able to connect every day to read my mail,
especially around the first half of September.
Jason Moehlman
2006-07-21 14:57:10 UTC
Permalink
Post by Aliacta Support
[Jason already wrote to me off list.]
Post by Jason Moehlman
I am new to using v2. I have been attempting to integrate v2 into an
existing project. Because of the structure I have also been trying
to as closely as possible mimick the function of the v1 code, more
linear or sequential operation.
Since you're using a loop to wait for the query to finish, are you
doing this with an App.DoEvents? That would be a risk. (Search the
pdf manual for "App.DoEvents" to find detailed information about
this.) Using threads would be another explanation for similar
misbehavior.
I removed the App.DoEvents, and it did not help the problem. There
are not multiple threads either. I was wondering if there are any
other issues or things to be careful of when subclassing the socket
and cache. I have gone through the manual in detail including the
trouble shooting section, trying to find something that I am doing
wrong, or not setting properly. No luck so far.
Post by Aliacta Support
Post by Jason Moehlman
I have run into a problem with an OutOfBounds error that seems to
occur with multiple events firing for a single simple query.
OutOfBounds generally suggests a ListBox that receives more than 64
rows. It hasn't to be bound through visual control binding, i.e.
binding a pgSQLlistBox with a cache through code is the same thing.
If I understood you correctly however you're not using any GUI
controls at all.
Nope, no binding, no ListBox, during the first phase of the program
this is literally the first query to be sent. The program starts,
does a connection box, then starts checking to see if the tables for
the app exist in the named database. This first query is breaking
down and getting the error, multiple firings of the pgcache events,
etc. It runs fine on v1 and on all the other database versions it
has been coded for.
Post by Aliacta Support
Please read the whole troubleshooting part of the manual as well
where you might find inspiration regarding the cause of your problem
or ways to investigate, e.g. using a log.
I added a log, 4 messages come across, 3 possibly all after the
exception has been thrown, hard to tell with all the breakpoints and
redrawing. There were no errors listed.
Cache Source Type Message Extra Info
1. Client Query SQL Statement
2. (Socket) Client Startup Initializing
3. (Socket) Server Startup Connected and Ready
4. (Socket) Server Row Description 2 Colums Starting to rec...

That is all in the log.
Post by Aliacta Support
Also if you're doing this on Linux, have you tried to see how it
behaves on Windows or Mac--just to rule out an RB problem of this
nature.
All of the development is done on a MacBook Pro or G5 Tower depending
on where I am at. I do compile for Linux, but right now all the
testing and development is on a Mac.

I know that the focus is on v2, but what is the plan for any support
for v1? Not new features, just keeping it compatible with future RB
releases so it works?

I really like the things v2 brings to the table, and I will continue
to try to work out my issues, but I also have a large contingent of
code that depends on at least being able to get a result without
having to resort to total event based design. Possibly an option
of requesting the cache to wait to return until the result is known
would be great.

Like many other developers, I have developed several classes/
interfaces that allow my projects to be compiled against PostgreSQL
(pgSQL4RB), ODBC, RealDB, RealSQLDB, and Valentina without change.
That is one of the reasons I cannot easily change how my system
behaves to all event based model short term.

Anyway any advice on the expected life of v1 would be greatly
appreciated.

Jason
Post by Aliacta Support
Marc
PS: I'm on limited bandwidth once more for the coming months and
can't be sure I'll be able to connect every day to read my mail,
especially around the first half of September.
_______________________________________________
Postgresql mailing list
http://aliacta.com/mailman/listinfo/postgresql_aliacta.com
Aliacta Support
2006-07-22 06:49:08 UTC
Permalink
Hi Jason,

From looking at your log my hunch is that all you need to do is to
move your initial query to the Connected event of the socket.

Cheers,

Marc

PS: if my hypothesis above is right then it's only been pure luck
that it used to work with v1.
Jason Moehlman
2006-07-23 02:40:08 UTC
Permalink
Hello Marc,

This is the code snippet that has been running and that is giving me
problems now.

pgSQL4RBactivateLicense(pgAuth(0), pgAuth(1), pgAuth(2), pgAuth
(3), pgAuth(4), pgAuth(5), pgAuth(6),pgAuth(7),pgAuth(8),pgAuth
(9),pgAuth(10),pgAuth(11))
pgSock.address=pgAddress
pgSock.port=pgPort
pgSock.userName=pgUser
pgSock.password=pgPassword
pgSock.DataBaseName=pgDBName
pgSock.connect
while pgSock.isConnected=false
pgSock.poll
app.SleepCurrentThread 30
wend
if pgcache=nil then
pgCache=new lslpgcache2
end if
pgcache.AutoDialog=true
pgcache.AutoBeep=true
pgsock.AutoBeep=true
pgsock.AutoDialog=true

pgsock.BindLog(wmain.pglb1)

updateStatus(10)

tmpsql="select tablename from pg_tables where tablename like
'sysconfig';"

pgcache.errorsdisplayed=true
pgcache.waitflag=true
pgcache.QueueSimpleQuery(tmpsql)
while pgcache.waitflag
pgSock.poll // throws exception in the loop, after double
events on the 4 populated event handlers.
app.SleepCurrentThread 30
wend
result=pgcache.checkdberror(pgcache)

if pgcache.emptyreturn then
result = createtables
updateStatus(35)
result = populatedb
...

I thought the above code would wait in loop until the socket had
connected properly, before attempting to send the query.

Any insight would be appreciated if something looks wrong. I will
work on changing the event driven aspect of the socket initdb code.

Thanks....Jason
Post by Aliacta Support
Hi Jason,
From looking at your log my hunch is that all you need to do is to
move your initial query to the Connected event of the socket.
Cheers,
Marc
PS: if my hypothesis above is right then it's only been pure luck
that it used to work with v1.
_______________________________________________
Postgresql mailing list
http://aliacta.com/mailman/listinfo/postgresql_aliacta.com
Aliacta Support
2006-07-23 07:15:58 UTC
Permalink
Hi Jason,

Socket.Poll throws errors because you can no longer use it. (It can
help cause hard to track RB bugs.) People (including myself at
first) have been using App.Doevents instead to still be able to have
a waiting loop but that's probably even worse. The only way to have
full peace of mind is to do it event-based. This is a direct result
of how the RB TCPSocket works. It's not possible to implement an
entirely trouble-free "wait for completion before continuing" based
on the current RB TCPSocket.

Here's how to change your sequential code to event-based code:


pgSQL4RBactivateLicense(pgAuth(0), pgAuth(1), pgAuth(2), pgAuth
(3), pgAuth(4), pgAuth(5), pgAuth(6),pgAuth(7),pgAuth(8),pgAuth
(9),pgAuth(10),pgAuth(11))
pgSock.address=pgAddress
pgSock.port=pgPort
pgSock.userName=pgUser
pgSock.password=pgPassword
pgSock.DataBaseName=pgDBName
pgSock.connect


In the pgSock Connected event:

if pgcache=nil then
pgCache=new lslpgcache2
end if
pgcache.AutoDialog=true
pgcache.AutoBeep=true
pgsock.AutoBeep=true
pgsock.AutoDialog=true //you could put this at the start to see
errors on the socket when connecting too, not only when querying.

pgsock.BindLog(wmain.pglb1) //this should be at the start too for
the same reason.

tmpsql="select tablename from pg_tables where tablename like
'sysconfig';"

pgcache.errorsdisplayed=true
pgcache.QueueSimpleQuery(tmpsql, "checking for tables")


In pgCache DataReceived event:

result=pgcache.checkdberror(pgcache) //I figure you always use
this line, not just when "checking for tables" therefore I left out
the [If QueryName = "checking for tables"].


In pgCache EmptyResult event:

If QueryName = "checking for tables" Then
result = createtables
updateStatus(35)
result = populatedb
...
End If


You can see that with only tiny modifications to your subclassed
cache and socket you'll obtain what you're looking for.

Cheers,

Marc
Jason Moehlman
2006-07-25 14:45:50 UTC
Permalink
Hello Marc,
Post by Aliacta Support
Socket.Poll throws errors because you can no longer use it. (It
can help cause hard to track RB bugs.) People (including myself at
first) have been using App.Doevents instead to still be able to
have a waiting loop but that's probably even worse. The only way
to have full peace of mind is to do it event-based. This is a
direct result of how the RB TCPSocket works. It's not possible to
implement an entirely trouble-free "wait for completion before
continuing" based on the current RB TCPSocket.
This was the problem. It was never really in the cache, it was the
socket connection. Even though it reported as connected with the
property the socket.poll had caused some issues.

Once the connection was done as you suggested with waiting on the
pgsocket.connected event everything started working as expected.

I really appreciate your help, guidance, and patience with the
trouble shooting.

Thanks again.....Jason
Aliacta Support
2006-08-19 17:15:54 UTC
Permalink
Hello everyone,

pgSQL4RB v2.0 fc1 is now available for download from following link:

<http://www.aliacta.com/download/pgSQL4RBv2fc1.zip>

This single download works on all operating systems supported by REALbasic.

Note however that this new version requires REALbasic 2006 r3 and
will not work with existing license keys. (New keys will be sent
around with the next release--there are no new features in this
release conmpared to the last beta. We're not updating our web site
yet either.)

Cheers,

Marc

PS: And thanks for your patience to those who waited for this!
dazz
2006-08-19 19:22:11 UTC
Permalink
great news :)
Thanks a lot
Post by Aliacta Support
Hello everyone,
<http://www.aliacta.com/download/pgSQL4RBv2fc1.zip>
This single download works on all operating systems supported by REALbasic.
Note however that this new version requires REALbasic 2006 r3 and
will not work with existing license keys. (New keys will be sent
around with the next release--there are no new features in this
release conmpared to the last beta. We're not updating our web site
yet either.)
Cheers,
Marc
PS: And thanks for your patience to those who waited for this!
_______________________________________________
Postgresql mailing list
http://aliacta.com/mailman/listinfo/postgresql_aliacta.com
Loading...