Django

Code

Ticket #6623 (new)

Opened 8 months ago

Last modified 2 months ago

commit_manually decorator: Better error message (show exception)

Reported by: guettli Assigned to: nobody
Milestone: post-1.0 Component: Database layer (models, ORM)
Version: SVN Keywords:
Cc: hv@tbz-pariv.de, farhan@thebitguru.com Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Hi,

if there is an unhandled exception in a 'commit_manually' method, it is very hard to see the root of the problem, since you only see 'Transaction managed block ended with pending COMMIT/ROLLBACK'.

This patch creates a debug message, which gets passed to leave_transaction_management().

Attachments

commit_manually_better_error_message.diff (2.0 kB) - added by guettli on 02/19/08 03:02:56.
commit_manually_exception_pass_thru.diff (2.0 kB) - added by justine <jtunney@lobstertech.com> on 07/31/08 01:13:27.
commit_manually_exception_pass_thru2.diff (2.6 kB) - added by justine <jtunney@lobstertech.com> on 08/19/08 04:32:19.

Change History

02/19/08 03:02:56 changed by guettli

  • attachment commit_manually_better_error_message.diff added.

02/23/08 12:00:48 changed by Bernd Schlapsi

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

I tested this patch today and it works fine for me

06/10/08 20:40:38 changed by programmerq

  • stage changed from Unreviewed to Accepted.

This looks helpful, and the patch seems to work with current trunk. The last hunk was set to 'fuzzy' but it applied just fine.

07/22/08 11:55:32 changed by thebitguru

  • cc changed from hv@tbz-pariv.de to hv@tbz-pariv.de, farhan@thebitguru.com.

07/31/08 01:10:29 changed by justine <jtunney@lobstertech.com>

I would very much like to see this bug fix committed, as I got burned by this today. I have a few comments on the patch though:

- If the transaction was committed manually before the error was raised, this patch will eat up the exception

- You cannot have except and finally in the same try block in python 2.4

- I'm afraid I don't understand the significance of logging.error("ok")?

- I don't think it's necessary to append the exception to the Commit error exception. The fact that the transaction wasn't committed is probably a side effect of whatever exception was raised.

I've attached a more up-to-date patch I think should work. Thanks everyone :-)

Also, should my error handler catch KeyboardInterrupt? and SystemExit? too? I'm not sure I understand that.

07/31/08 01:13:27 changed by justine <jtunney@lobstertech.com>

  • attachment commit_manually_exception_pass_thru.diff added.

08/16/08 19:05:13 changed by mtredinnick

  • milestone set to 1.0.

I probably prefer the approach in the second patch, because the first exception is really going to be the real point here. The patch needs a bit of tweaking, mostly in light of #7241 and comment:4 of this ticket. Our current behaviour is hiding real problems and making our own code hard to debug (that transaction exception message appears in a few bugs where I suspect it's disguising the real issue).

08/19/08 04:32:19 changed by justine <jtunney@lobstertech.com>

  • attachment commit_manually_exception_pass_thru2.diff added.

08/22/08 17:39:12 changed by ubernostrum

  • milestone changed from 1.0 to post-1.0.

Add/Change #6623 (commit_manually decorator: Better error message (show exception))




Change Properties
Action