5

When I do a query with isql I get the following message and the query blocks.

The transaction log in database foo is almost full. Your transaction is being suspended until space is made available in the log.

When I do the same from Python:

cursor.execute(sql)

The query blocks, but I would like see this message.

I tried:

Sybase.set_debug(sys.stderr)
connection.debug = 1

I'm using:

  • python-sybase-0.40pre1
  • Adaptive Server Enterprise/15.5/EBF 18164

EDIT: The question is, "How do I capture this warning message in the python program?"

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
Eddy Pronk
  • 6,527
  • 5
  • 33
  • 57
  • What database are you using? What python library? – Chris Lacasse Sep 23 '11 at 00:16
  • I edited the question to add those details. – Eddy Pronk Sep 23 '11 at 01:37
  • I don't know enough about the library in question to suggest a full-fledged answer, but is it possible to specify a timeout somewhere? Alternatively, can you run the query in a separate thread and have another thread abort the query after a certain amount of time if the query hasn't returned? –  Oct 04 '11 at 11:16

3 Answers3

1

Good question and I'm not sure I can completely answer it. Here are some ideas.

Sybase.py uses logging. Make sure you are using it. To "bump" the logging out I would do this:

import logging
logging.basicConfig(level = logging.INFO,
                    format = "%(asctime)s %(levelname)s [%(filename)s] (%(name)s) %(message)s",
                    datefmt = "%H:%M:%S", stream = sys.stdout)
log = logging.getLogger('sybase')
log.setLevel(logging.DEBUG)

And apparently (why is beyond me??) to get this working in Sybase.py you need to set a global DEBUG=True (see line 38)

But then if we look at def execute we can see (as you point out) that it's blocking. We'll that sort of answers your question. You aren't going to get anything back as it's blocking it. So how do you fix this - write a non-blocking excute method;) There is some hints in examples/timeout.py. Apparently someone else has run up on this but hasn't really fixed it.

I know this didn't probably help but I spent 15 minutes looking - I should at least tell you what I found.. You would think that execute would give you some result -- Wait what is the value of result in line 707??

                while 1:
                    status, result = self._cmd.ct_results()
                    if status != CS_SUCCEED:
                        break

If status != CS_SUCCEED (which I'm assuming in your case is True) can you simply see what "result" is equal to? I wonder if they just failed raise the result as an exception?

rh0dium
  • 6,811
  • 4
  • 46
  • 79
-1

Your query may be large which is overflowing the transaction log (e.g. you are inserting large binary files). Or you may not be truncating your transaction logs often enough if that's an option.

During runtime you will want to have an except statement that catches the exception Error.

See the Sybase Python documentation.

James Oltmans
  • 1,057
  • 13
  • 26
  • 1
    The call is blocking and does not raise an exception. – Eddy Pronk Oct 03 '11 at 23:43
  • I'm not talking about how many rows it updated, what I meant was that the content of the query might be large. As I said, if you're inserting a lot of binary data into that 1 row. – James Oltmans Oct 05 '11 at 15:06
-2

The reason is obvious, transaction log is full, you can check the blocikng queries in sybase MDA table monSysStatement .. here u can check sql statement which is taking high Io, time, number of row affecting etc.

Gopal Sanodiya
  • 204
  • 2
  • 3
  • 1
    Thanks, but this does not answer the question on how to capture this warning message in the python program, so the user can see why the query call doesn't come back. – Eddy Pronk Sep 27 '11 at 23:22