Thread: Another LargeObject problem

Another LargeObject problem

From
Ole Streicher
Date:
Hi,

I have another Problem when using LargeObjects.
From time to time, I get the exception

FastPath call returned ERROR:  lo_lseek: invalid large obj descriptor (369)

What does this exception mean? It occurs randomly; a repeated
retrieval works usually.

The code I use here is appended below.

BTW, yesterday I posted another question, but that has not arrived at
the mailing list (even the retry after I subscribed). Is there any
problem with the list or does it just take some days to appear there?

Ciao

Ole

-----------------------------8<------------------------------------------
PreparedStatement queryStmt
  = dbConn.prepareStatement("SELECT Values, From_Date, To_Date FROM "
                            + tableName
                            +" WHERE From_Date <= ? AND To_Date > ?");

queryStmt.setTimestamp(1, from);
queryStmt.setTimestamp(2, to);
ResultSet rs = queryStmt.executeQuery();
while (rs.next()) {
  Timestamp f = rs.getTimestamp(2);
  Timestamp t = rs.getTimestamp(3);
  int oid = rs.getInt(1);
  LargeObject obj = lobj.open(oid, LargeObjectManager.READ);

  byte[] b = new byte[obj.size()]; //  *** Here it happens ****
  obj.read(b, 0, b.length);
  // ...
}

Re: Another LargeObject problem

From
Tom Lane
Date:
Ole Streicher <ole-usenet-spam@gmx.net> writes:
> I have another Problem when using LargeObjects.
>> From time to time, I get the exception
> FastPath call returned ERROR:  lo_lseek: invalid large obj descriptor (369)
> What does this exception mean?

It means the descriptor you opened with lo_open isn't open anymore (or
that you're passing the wrong descriptor number, but the former is more
likely).  Descriptors are closed at transaction end, so you have to hold
open a transaction block for your entire lo_open .. lo_close sequence.

> It occurs randomly; a repeated retrieval works usually.

If it seems "random" then you are probably being careless with
connection pooling.  You've got to hold onto the same connection and
same transaction for as long as you're using the LO.

            regards, tom lane