Skip to Content.
Sympa Menu

freetds - RE: [freetds] Reconnection and asserts problem - tolerantness/less?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] Reconnection and asserts problem - tolerantness/less?
  • Date: Fri, 5 Nov 2004 11:19:51 -0500

> From: V.Kukushkin
> Sent: Friday, November 05, 2004 1:02 AM
>
> I have encountered the following reconnection problem:
>
> My task keeps persistent connection with SQL server (MSSQL 2000) and
> periodically checks if connection is alive (by calling getpeername()).
> If the connection is lost I use tds_connect() to reconnect.
>
> And, in situation when connection is lost during this call, I get
> assert(in_wire == -1) and my task is broken. Two questions: 1) What's
> wrong in sequence of calls? Should I free and then allocate socket
again
> ? I.e.: tds_free_socket() tds_alloc_socket() tds_connect() 2) Do you
> think that this assert is acceptable even in debug mode ?

I can't find the code you're referring to. Combinations of "assert" and
"wire" that I find:

src/tds/iconv.c tds_iconv_info_init 410 assert(char_conv->to_wire ==
(iconv_t) - 1);
src/tds/iconv.c tds_iconv_info_init 411 assert(char_conv->to_wire2 ==
(iconv_t) - 1);
src/tds/iconv.c tds_iconv_info_init 412 assert(char_conv->from_wire ==
(iconv_t) - 1);
src/tds/iconv.c tds_iconv_info_init 413 assert(char_conv->from_wire2 ==
(iconv_t) - 1);
src/tds/read.c read_and_convert 712 assert(*wire_size == 0 ||
*outbytesleft == 0);

So, as to whether or not it's reasonable, I guess not? Because it's
gone now?

> Could we (users of TDS) get more tolerant code? I mean tolerant to
lost
> connections during tds_connect() tds_submit_xx() and tds_process_xx()
?
> For example, I got assert/abort when tried to process short simple
query
> but server was heavy LOADED with night cleanings. Just timeout 60 sec
> wasn't enough. Do you suppose is it a reason for assert ?

assert(3) is used for "impossible" conditions; the author doesn't
anticipate the asserted condition, and might not have written the
ensuing logic to cope with it. I normally assert pointers before I
dereference them, because I'd rather hear about an assert than a
segmentation fault. When I call a function that my man page says always
returns >=0, I like to assert that, in case someone else's library
behaves differently.

That said, the FreeTDS code often has the characteristic that it works
well when it works, but when it fails, it fails spectacularly. The
connection/timeout logic is an example. I've actually tried to tackle
it a couple of times (even though I have no real experience with tcp/ip
programming), but I haven't gotten a large enough block of time.

> At the end I am sorry for rather loud sounds, tired to fix these
problems ;-)

Patches welcome, my friend. If you know how this should be fixed and
send us a working patch, we'll apply it and give you credit. It's your
itch, after all.

--jkl

-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the original
message. Please note that we do not accept account orders and/or instructions
by e-mail, and therefore will not be responsible for carrying out such orders
and/or instructions.
If you, as the intended recipient of this message, the purpose of which is to
inform and update our clients, prospects and consultants of developments
relating to our services and products, would not like to receive further
e-mail correspondence from the sender, please "reply" to the sender
indicating your wishes. In the U.S.: 1345 Avenue of the Americas, New York,
NY 10105.






Archive powered by MHonArc 2.6.24.

Top of Page