agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
[Pljava-dev] Question regarding triggers and data visibility
7+ messages / 0 participants
[nested] [flat]

* [Pljava-dev] Question regarding triggers and data visibility
@ 2005-11-11 21:27  
  0 siblings, 0 replies; 7+ messages in thread

From:  @ 2005-11-11 21:27 UTC (permalink / raw)

I have created a trigger that notifies a daemon process (via the java
RMI mechanism) that a new record has been inserted into a table.  The
problem I am having is that the record is not visible to the daemon
process after it performs a 'select' on the table in question.  Further
investigation shows that the new record was successfully inserted into
the table.  The strange thing is that if I do a table lock (i.e. 'lock
table') in the trigger method before notifying the daemon the data
becomes visible to the daemon!!  I don't like using the lock as I have
had issues with the lock causing random problems.  Any ideas as to how I
can make the new data visible?

 

Regards,

John Burtenshaw

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20051111/7c56f5dd/attachment.html;



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* [Pljava-dev] Question regarding triggers and data visibility
@ 2005-11-11 21:57  
  0 siblings, 1 reply; 7+ messages in thread

From:  @ 2005-11-11 21:57 UTC (permalink / raw)

Thanks for the quick reply Rakesh.  It turns out I was not using
transaction blocks (i.e. allowing "autocommit") so I just tried the
insert statement in a Begin/commit block and it did not make a
difference.  Any other ideas as to what could cause this strange
phenomena?

 

Regards,

John Burtenshaw

 

 

________________________________

From: Rakesh Vidyadharan [mailto:rakesh at rakeshv.org] 
Sent: Friday, November 11, 2005 4:32 PM
To: Burtenshaw, John J.
Subject: Re: [Pljava-dev] Question regarding triggers and data
visibility

 

 

On Nov 11, 2005, at 3:27 PM, Burtenshaw, John J. wrote:





I have created a trigger that notifies a daemon process (via the java
RMI mechanism) that a new record has been inserted into a table.  The
problem I am having is that the record is not visible to the daemon
process after it performs a 'select' on the table in question.  Further
investigation shows that the new record was successfully inserted into
the table.  The strange thing is that if I do a table lock (i.e. 'lock
table') in the trigger method before notifying the daemon the data
becomes visible to the daemon!!  I don't like using the lock as I have
had issues with the lock causing random problems.  Any ideas as to how I
can make the new data visible?

That sounds like a transaction commit issue to me.  If the insert has
not been committed, then another connection will not be able to see the
record.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20051111/5c51d78a/attachment.html;



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* [Pljava-dev] Question regarding triggers and data visibility
@ 2005-11-11 22:07  
  parent: 
  0 siblings, 1 reply; 7+ messages in thread

From:  @ 2005-11-11 22:07 UTC (permalink / raw)


On Nov 11, 2005, at 3:57 PM, Burtenshaw, John J. wrote:

> Thanks for the quick reply Rakesh.  It turns out I was not using  
> transaction blocks (i.e. allowing ?autocommit?) so I just tried the  
> insert statement in a Begin/commit block and it did not make a  
> difference.  Any other ideas as to what could cause this strange  
> phenomena?
I believe the problem is caused by the fact that the message is sent  
from a trigger.  If I am not mistaken, the database modification  
would not have been committed until the trigger returns successfully,  
at which point the transaction would have been committed.  Does the  
trigger just send a message, or does it wait for a response?

Rakesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20051111/774977a7/attachment.html;



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* [Pljava-dev] Question regarding triggers and data visibility
@ 2005-11-11 22:12  
  parent: 
  0 siblings, 0 replies; 7+ messages in thread

From:  @ 2005-11-11 22:12 UTC (permalink / raw)


On Nov 11, 2005, at 4:07 PM, Rakesh Vidyadharan wrote:

>
> On Nov 11, 2005, at 3:57 PM, Burtenshaw, John J. wrote:
>
>> Thanks for the quick reply Rakesh.  It turns out I was not using  
>> transaction blocks (i.e. allowing ?autocommit?) so I just tried  
>> the insert statement in a Begin/commit block and it did not make a  
>> difference.  Any other ideas as to what could cause this strange  
>> phenomena?
> I believe the problem is caused by the fact that the message is  
> sent from a trigger.  If I am not mistaken, the database  
> modification would not have been committed until the trigger  
> returns successfully, at which point the transaction would have  
> been committed.  Does the trigger just send a message, or does it  
> wait for a response?

Come to think of it, since the trigger already has access to the  
information in the record being inserted, there should be no reason  
for the remote object to fetch the new record from the database.  You  
should be able to send a transfer object with the data to the remote  
object.  I do not think you will save any network bandwidth using  
this technique, since you will be spending some anyway to fetch from  
the database.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20051111/81cf71f9/attachment.html;



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* [Pljava-dev] Question regarding triggers and data visibility
@ 2005-11-14 13:59  
  0 siblings, 1 reply; 7+ messages in thread

From:  @ 2005-11-14 13:59 UTC (permalink / raw)


Rakesh: You are right that I should be able to pass the new information to the Daemon through the network but the one inconvenient problem is that the ResultSet object is not serializable which is a requirement for RMI objects.  I suppose I could break the result down to a serialized string stream or something to that effect.  Can you think of another way?


Thanks again
John Burtenshaw




-----Original Message-----
From: pljava-dev-bounces at gborg.postgresql.org on behalf of Rakesh Vidyadharan
Sent: Fri 11/11/2005 5:12 PM
Cc: Pljava-dev at gborg.postgresql.org
Subject: Re: [Pljava-dev] Question regarding triggers and data visibility
 

On Nov 11, 2005, at 4:07 PM, Rakesh Vidyadharan wrote:

>
> On Nov 11, 2005, at 3:57 PM, Burtenshaw, John J. wrote:
>
>> Thanks for the quick reply Rakesh.  It turns out I was not using  
>> transaction blocks (i.e. allowing "autocommit") so I just tried  
>> the insert statement in a Begin/commit block and it did not make a  
>> difference.  Any other ideas as to what could cause this strange  
>> phenomena?
> I believe the problem is caused by the fact that the message is  
> sent from a trigger.  If I am not mistaken, the database  
> modification would not have been committed until the trigger  
> returns successfully, at which point the transaction would have  
> been committed.  Does the trigger just send a message, or does it  
> wait for a response?

Come to think of it, since the trigger already has access to the  
information in the record being inserted, there should be no reason  
for the remote object to fetch the new record from the database.  You  
should be able to send a transfer object with the data to the remote  
object.  I do not think you will save any network bandwidth using  
this technique, since you will be spending some anyway to fetch from  
the database.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20051114/2798e85a/attachment.html;



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* [Pljava-dev] Question regarding triggers and data visibility
@ 2005-11-14 14:08  
  parent: 
  0 siblings, 0 replies; 7+ messages in thread

From:  @ 2005-11-14 14:08 UTC (permalink / raw)


On 14 Nov 2005, at 07:59, Burtenshaw, John J. wrote:

>
> Rakesh: You are right that I should be able to pass the new  
> information to the Daemon through the network but the one  
> inconvenient problem is that the ResultSet object is not  
> serializable which is a requirement for RMI objects.  I suppose I  
> could break the result down to a serialized string stream or  
> something to that effect.  Can you think of another way?
I do not know any other convenient way to pass the information.  I  
think the easiest way is to create a transfer object.  If you have  
created PGobject sub-classes to represent your data, then you already  
have it.  If not, just create a custom transfer object and pass that  
to the RMI object.  You can also pass custom strings, or XML if  
performance is not an absolute must.  You can easily create the  
transfer object or String representation from the information in the  
Trigger.

Rakesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20051114/7c07111c/attachment.html;



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* [Pljava-dev] Question regarding triggers and data visibility
@ 2005-11-14 14:14  
  0 siblings, 0 replies; 7+ messages in thread

From:  @ 2005-11-14 14:14 UTC (permalink / raw)


Thanks Rakesh.  I found a couple of mailing lists that suggest putting the results to a collection which should be simple enough.  I'm sure this will work fine for me!

Regards,
John Burtenshaw




-----Original Message-----
From: pljava-dev-bounces at gborg.postgresql.org on behalf of Rakesh Vidyadharan
Sent: Mon 11/14/2005 9:08 AM
Cc: Pljava-dev at gborg.postgresql.org
Subject: Re: [Pljava-dev] Question regarding triggers and data visibility
 

On 14 Nov 2005, at 07:59, Burtenshaw, John J. wrote:

>
> Rakesh: You are right that I should be able to pass the new  
> information to the Daemon through the network but the one  
> inconvenient problem is that the ResultSet object is not  
> serializable which is a requirement for RMI objects.  I suppose I  
> could break the result down to a serialized string stream or  
> something to that effect.  Can you think of another way?
I do not know any other convenient way to pass the information.  I  
think the easiest way is to create a transfer object.  If you have  
created PGobject sub-classes to represent your data, then you already  
have it.  If not, just create a custom transfer object and pass that  
to the RMI object.  You can also pass custom strings, or XML if  
performance is not an absolute must.  You can easily create the  
transfer object or String representation from the information in the  
Trigger.

Rakesh



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20051114/7258486a/attachment.html;



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2005-11-14 14:14 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-11-11 21:27 [Pljava-dev] Question regarding triggers and data visibility 
2005-11-11 21:57 [Pljava-dev] Question regarding triggers and data visibility 
2005-11-11 22:07 ` 
2005-11-11 22:12   ` 
2005-11-14 13:59 [Pljava-dev] Question regarding triggers and data visibility 
2005-11-14 14:08 ` 
2005-11-14 14:14 [Pljava-dev] Question regarding triggers and data visibility 

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox