You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by randy roy <rj...@hotmail.com> on 2007/08/02 22:37:18 UTC

Tuning JAMES & MySQL

When I first started with JAMES and MySQL, my mail load was pretty light.  
So I just used the default MySQL configuration and the default JAMES 
datasource configuration.  Over the years, the amount of mail I'm processing 
has grown significantly.  It has come to the point where MySQL is using 
90-98% of the CPU, with the CPU pegged at 100% a lot of the time.

So I started looking at some of the optional pre-canned config files that 
come with MySQL.  One is called my-huge.cnf.  Seemed logical that I have now 
grown into a need for an industrial strength config of MySQL.  So I tried 
reconfiguring MySQL to use the 'huge' config setup.

The good news is that the CPU utilization went way down, implying that MySQL 
is now running much more efficiently.  The bad news is that after running 
about 3-4 minutes with the new MySQL config, JAMES starts throwing hundreds 
of "Connection Pool Exhausted" exceptions, and JAMES grinds to a halt.

So I had to back out the huge config for MySQL and now no more connection 
pool exceptions.  But the CPU is at 100% again.

My question is, why would using the huge MySQL config cause JAMES to start 
running out of connections?  I played around with the max connections field 
in the JAMES config.  But it didn't seem to make any difference.  And I 
don't really want to just start setting super high max values without 
knowing any criteria.  But I really need to get MySQL reconfigured someway 
to get it running more efficiently.

Can somebody give me a quick recommendation on how to match the tuning 
parameters between JAMES and MySQL?  Is there some sort of formula to 
setting connection parameters such that it works efficiently, yet doesn't 
run out of connections?

Thanks.

_________________________________________________________________
Tease your brain--play Clink! Win cool prizes! 
http://club.live.com/clink.aspx?icid=clink_hotmailtextlink2


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Tuning JAMES & MySQL

Posted by Danny Angus <da...@apache.org>.
On 8/3/07, Stefano Bagnara <ap...@bago.org> wrote:
> randy roy ha scritto:
> > When I first started with JAMES and MySQL, my mail load was pretty
> > light.  So I just used the default MySQL configuration and the default
> > JAMES datasource configuration.  Over the years, the amount of mail I'm
> > processing has grown significantly.  It has come to the point where
> > MySQL is using 90-98% of the CPU, with the CPU pegged at 100% a lot of
> > the time.
>
> First try this:
> mysql> repair table spool;
> mysql> repair table inbox;


The james tables are indexed but they are also normally empty, this
seems to result in a large fragmented index, which reduces performance
with time. no index at all is slower but performance is stable. You
should rebuild the index regularly if you process large volumes of
mail. (This is not specific to James/MySQL but it also a problem with
other DB's and other scenarios where an indexed table is normally
empty, e.g. I've seen the same behaviour from Oracle AQ queues)

d.
d.

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: Tuning JAMES & MySQL

Posted by randy roy <rj...@hotmail.com>.

>Assuming that you don't run into directory size limits, you'll be better 
>off
>with dbfile rather than db for messages of these sizes.
>

Wow, I completely lost you on that one.  I run between 5,000 and 10,000 
emails through my server in one day (counting all the spam as well).  You're 
saying that text-file based file-system storage is better than using a tuned 
mySQL database???  How many emails would I have to be pushing through daily 
to get to a point where a database would be better?

_________________________________________________________________
Puzzles, trivia teasers, word scrambles and more. Play for your chance to 
win! http://club.live.com/home.aspx?icid=CLUB_hotmailtextlink


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: Tuning JAMES & MySQL

Posted by "Noel J. Bergman" <no...@devtech.com>.
Assuming that you don't run into directory size limits, you'll be better off
with dbfile rather than db for messages of these sizes.

	--- Noel



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Tuning JAMES & MySQL

Posted by Stefano Bagnara <ap...@bago.org>.
randy roy ha scritto:
> Stefano,
> 
> I have a fairly old version of mySQL 4.0.18.  But until now, I haven't
> had any problems with it.
> 
> My connector in the JAMES lib is: mm.mysql-2.0.14.jar

So first of all download connector/j 5.0.7 and try again:
mm.mylsql-2.0.14 has been tested against mysql 3 the last time. Any
newer mysql really needs a newer connector.

Are you using JAMES Server 2.3.1 or something older? If older you should
really upgrade.

> I have never been certain about the correct way to set up the config for
> mySQL (ini files vs. cnf files and different places you can optionally
> put them etc.)  In mySQL 4 version, they have a my.ini that has to be in
> /WINNT directory.  Then they have an optional my.cnf file that must be
> in c:\.  It appears the directory requirements have changed in later
> releases, and they have everything in the install dir.  But I'm still on
> the old way.  At this point, I have a tiny my.ini in c:/WINNT:
> 
> [mysqld]
> basedir=c:/mysql
> datadir=c:/mysql/data
> set-variable    = max_allowed_packet=16M
> [WinMySQLAdmin]
> Server=C:/mysql/bin/mysqld-nt.exe
> 
> (I remember some problem where I had to set the max_allowed_packet size
> here.  But it's been too long to remember why.)

You probably increased it to support bigger messages in db: mysql
protocol is a bit limited and it will try to transfer a single field
content in a single packet.

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Tuning JAMES & MySQL

Posted by randy roy <rj...@hotmail.com>.
Stefano,

I have a fairly old version of mySQL 4.0.18.  But until now, I haven't had 
any problems with it.

My connector in the JAMES lib is: mm.mysql-2.0.14.jar

I have never been certain about the correct way to set up the config for 
mySQL (ini files vs. cnf files and different places you can optionally put 
them etc.)  In mySQL 4 version, they have a my.ini that has to be in /WINNT 
directory.  Then they have an optional my.cnf file that must be in c:\.  It 
appears the directory requirements have changed in later releases, and they 
have everything in the install dir.  But I'm still on the old way.  At this 
point, I have a tiny my.ini in c:/WINNT:

[mysqld]
basedir=c:/mysql
datadir=c:/mysql/data
set-variable    = max_allowed_packet=16M
[WinMySQLAdmin]
Server=C:/mysql/bin/mysqld-nt.exe

(I remember some problem where I had to set the max_allowed_packet size 
here.  But it's been too long to remember why.)

In the c:\ root directory, when SMTP is working ok, I have zero other 
configuration (no my.cnf at all).  I figure it's simply using all the 
defaults.

When I started all of this investigation to attempt to make it run more 
efficiently, I realized that there should be a my.cnf file in the root.   
There were several sample cnf files in the mysql root, so I simply copied 
my-huge.cnf to c:\my.cnf.  That's when SMTP died.  If I rename my.cnf to 
my-cnf.inactive, SMTP starts working.  Rename it back, it dies.  The 
my-huge.cnf is below.  But I believe it's untouched from the shipped sample 
version.

If you tell me that it's time to bite the bullet and move up the entire 
mySQL and drivers to the current version, then I'll accept that.  I just 
don't want to add another degree of instability unless I have a pretty good 
idea that it will solve the problem.

I'm running Windows Server 2003.  1GB of memory. But memory usage is fine.  
Not coming close the ceiling on that.

I am using the distributed binaries of both JAMES (2.3.0) and mySQL.

# Example mysql config file.
# Copy this file to c:\my.cnf to set global options
#
# One can use all long options that the program supports.
# Run the program with --help to get a list of available options

# This will be passed to all mysql clients
[client]
#password=my_password
port=3306
#socket=MySQL

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# The MySQL server
[mysqld]
port=3306
#socket=MySQL
skip-locking
set-variable    = key_buffer=384M
set-variable    = max_allowed_packet=1M
set-variable    = table_cache=512
set-variable    = sort_buffer=2M
set-variable    = record_buffer=2M
set-variable    = thread_cache=8
# Try number of CPU's*2 for thread_concurrency
set-variable    = thread_concurrency=8
set-variable    = myisam_sort_buffer_size=64M
server-id       = 1

# Uncomment the following if you want to log updates
#log-bin

# Uncomment the following rows if you move the MySQL distribution to another
# location
#basedir = d:/mysql/
#datadir = d:/mysql/data/


# Uncomment the following if you are NOT using BDB tables
#skip-bdb

# Uncomment the following if you are using BDB tables
#set-variable   = bdb_cache_size=384M
#set-variable   = bdb_max_lock=100000

# Uncomment the following if you are using Innobase tables
#innodb_data_file_path = ibdata1:2000M;ibdata2:2000M
#innodb_data_home_dir = c:\ibdata
#innodb_log_group_home_dir = c:\iblogs
#innodb_log_arch_dir = c:\iblogs
#set-variable = innodb_mirrored_log_groups=1
#set-variable = innodb_log_files_in_group=3
#set-variable = innodb_log_file_size=5M
#set-variable = innodb_log_buffer_size=8M
#innodb_flush_log_at_trx_commit=1
#innodb_log_archive=0
#set-variable = innodb_buffer_pool_size=16M
#set-variable = innodb_additional_mem_pool_size=2M
#set-variable = innodb_file_io_threads=4
#set-variable = innodb_lock_wait_timeout=50

[mysqldump]
quick
set-variable    = max_allowed_packet=16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
set-variable    = key_buffer=256M
set-variable    = sort_buffer=256M
set-variable    = read_buffer=2M
set-variable    = write_buffer=2M

[myisamchk]
set-variable    = key_buffer=256M
set-variable    = sort_buffer=256M
set-variable    = read_buffer=2M
set-variable    = write_buffer=2M

[mysqlhotcopy]
interactive-timeout

_________________________________________________________________
Puzzles, trivia teasers, word scrambles and more. Play for your chance to 
win! http://club.live.com/home.aspx?icid=CLUB_hotmailtextlink


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Tuning JAMES & MySQL

Posted by Stefano Bagnara <ap...@bago.org>.
randy roy ha scritto:
> Stefano,
> 
> Sorry to bother you again on this.  But I've determined that James is
> actually not sending the final expected SMTP response.  I did an ethereal
> packet trace and initially determined what what happening.  Then I traced
> back through the JAMES logs and verified what I saw in ethereal.
> 
> I don't know if it's really a JAMES problem.  However, I have determined
> that JAMES is NOT sending the 'message received' response when I use the
> mySQL huge config (the mail DOES get sent) When I change back to the tiny
> config, JAMES does send the response.  This is very reproducable.

Can you post here the 2 different mysql ini?

I've them in my system, but I want to be sure they are like mine and we
are discussing the same thing.

Can you also tell me what mysql server are you using (version, platform
and where did you get the specific binaries: your distribution vs mysql
website) and what version of connector/J are you using?

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Tuning JAMES & MySQL

Posted by randy roy <rj...@hotmail.com>.
Stefano,

Sorry to bother you again on this.  But I've determined that James is 
actually not sending the final expected SMTP response.  I did an ethereal 
packet trace and initially determined what what happening.  Then I traced 
back through the JAMES logs and verified what I saw in ethereal.

I don't know if it's really a JAMES problem.  However, I have determined 
that JAMES is NOT sending the 'message received' response when I use the 
mySQL huge config (the mail DOES get sent) When I change back to the tiny 
config, JAMES does send the response.  This is very reproducable.

In the failure scenario, it appears that the smtp thread gets the message 
and forwards it to the spool, but then simply goes away (see comparison 
traces below).

The database is running fine in 'huge' mode (actually significantly more 
efficiently).  So I can't see anything that would point to database failure. 
  I have all the logs set to "DEBUG", and haven't found anything relevant.  
But to be honest, I'm not sure where to look or what I might be looking for.

Please take a look at the two traces below.  I'm very willing to drill down 
and do more debug.  I just need some pointers as to where to look.

The bottom line is that I really need to get mySQL tuned in order to free up 
CPU.  But I'm stuck with a pegged CPU in order to send mail.   I guess I 
could start trying a bunch of tweaking of mySQL parms.  But not knowing what 
the real problem is, I would simply be shooting in the dark.  And even if I 
got to accidentally work, it'll probably start failing again at some 
inconvenient time.  So I'd really like to figure out what is happening.  But 
I'm going to need a bit of help from somebody that understands the details 
of the code to give me some pointers.

Thanks a bunch.

Successful send -- (mySQL default config)

07/08/07 11:51:22 DEBUG smtpserver-in: Sent: 235 Authentication Successful
07/08/07 11:51:22 INFO  smtpserver-in: AUTH method PLAIN succeeded
07/08/07 11:51:22 DEBUG smtpserver-in: Calling reset() default Worker #122
07/08/07 11:51:22 DEBUG smtpserver-in: Lookup command handler for command: 
MAIL
07/08/07 11:51:22 DEBUG smtpserver-in: Sent: 250 2.1.0 Sender 
<Je...@Malcolms.com> OK
07/08/07 11:51:22 DEBUG smtpserver-in: Calling reset() default Worker #122
07/08/07 11:51:22 DEBUG smtpserver-in: Lookup command handler for command: 
RCPT
07/08/07 11:51:22 DEBUG smtpserver-in: Sent: 250 2.1.5 Recipient 
<in...@2gvp.com> OK
07/08/07 11:51:22 DEBUG smtpserver-in: Calling reset() default Worker #122
07/08/07 11:51:22 DEBUG smtpserver-in: Lookup command handler for command: 
DATA
07/08/07 11:51:22 DEBUG smtpserver-in: Sent: 354 Ok Send data ending with 
<CRLF>.<CRLF>
07/08/07 11:51:22 DEBUG smtpserver-in: Calling reset() default Worker #122
07/08/07 11:51:22 DEBUG smtpserver-in: executing message handlers
07/08/07 11:51:22 DEBUG smtpserver-in: sending mail
07/08/07 11:51:22 INFO  smtpserver-in: Successfully spooled mail 
Mail1186505482515-36 from Jerry@*******s.com on **.**.**.*** for 
[info@****.com]
07/08/07 11:51:22 DEBUG smtpserver-in: Sent: 250 2.6.0 Message received
07/08/07 11:51:22 DEBUG smtpserver-in: Lookup command handler for command: 
QUIT
07/08/07 11:51:22 DEBUG smtpserver-in: Sent: 221 2.0.0 mail.jwmhosting.com 
Service closing transmission channel
07/08/07 11:51:22 DEBUG smtpserver-in: Calling reset() default Worker #122
07/08/07 11:51:22 DEBUG smtpserver-in: Calling stop() default Worker #122
07/08/07 11:51:22 DEBUG smtpserver-in: Closing socket.
07/08/07 11:51:22 DEBUG smtpserver-in: Calling disposeWatchdog() default 
Worker #122
07/08/07 11:51:22 DEBUG smtpserver-in: Returning SMTPHandler to pool.

Failure scenario -- (mySQL huge config)  (note no "Sucessfully spooled 
mail...." message)

07/08/07 11:40:02 DEBUG smtpserver-in: Sent: 235 Authentication Successful
07/08/07 11:40:02 INFO  smtpserver-in: AUTH method PLAIN succeeded
07/08/07 11:40:02 DEBUG smtpserver-in: Calling reset() default Worker #55
07/08/07 11:40:02 DEBUG smtpserver-in: Lookup command handler for command: 
MAIL
07/08/07 11:40:02 DEBUG smtpserver-in: Sent: 250 2.1.0 Sender 
<Je...@Malcolms.com> OK
07/08/07 11:40:02 DEBUG smtpserver-in: Calling reset() default Worker #55
07/08/07 11:40:02 DEBUG smtpserver-in: Lookup command handler for command: 
RCPT
07/08/07 11:40:02 DEBUG smtpserver-in: Sent: 250 2.1.5 Recipient 
<in...@2gvp.com> OK
07/08/07 11:40:02 DEBUG smtpserver-in: Calling reset() default Worker #55
07/08/07 11:40:02 DEBUG smtpserver-in: Lookup command handler for command: 
DATA
07/08/07 11:40:02 DEBUG smtpserver-in: Sent: 354 Ok Send data ending with 
<CRLF>.<CRLF>
07/08/07 11:40:03 DEBUG smtpserver-in: Calling reset() default Worker #55
07/08/07 11:40:03 DEBUG smtpserver-in: executing message handlers
07/08/07 11:40:03 DEBUG smtpserver-in: sending mail
  (no other smtpserver lines in default log)

_________________________________________________________________
See what you’re getting into…before you go there 
http://newlivehotmail.com/?ocid=TXT_TAGHM_migration_HM_viral_preview_0507


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Tuning JAMES & MySQL

Posted by Stefano Bagnara <ap...@bago.org>.
randy roy ha scritto:
> Hmm, I'll try the Google route.  I'll also may may have to try a packet
> trace on both the cllent and server just to see if I can figure out what
> is happening.  (Most likely not related... but I also found that active
> FTP won't work with the DSL modem/router, but does work with cable.  So
> there are definite differences)
> 
> But strictly from a JAMES point of view, I know I get a Connection Reset
> exception in the log, yet the message is still sent.  On the client
> (Thunderbird), It says "contacting host..." then it changes to
> "Delivering message...".  But then it hangs for about a minute, and then
> finally times out and says it can't talk to smtp server (I know that's
> not correct... but Tbird obviously didn't get the final ack it was
> expecting).  The JAMES exception occurs apparently as a result of TBird
> finally timing out and aborting.  But the end result is that TBird (also
> tried on on Outlook... same results) thinks the message was NOT sent,
> but JAMES did deiliver it.  Then the client retries (that's where the
> multiple sends occur).

As I explained you the SMTP specification does not prevent from multiple
sends. When the client send the "." of the message the server have to
spool the message and then to tell the client that the message has been
succesfully received. If something goes wrong when it is replying that
he queued the message then the client will never know the message has
been delivered and will retry.

I don't have any idea about how this can be reproducible in your
environment, but I'm 99.9999999% sure this is not related to JAMES
Server but is related to your network.

I don't really know how to help: maybe if you can sniff the TCP/IP
packets we can understand whether the server never returns the message
received message or the client is ignoring it or something else happens
in the middle.

>From a JAMES Server point of view the "Connection reset" is a network
failure: at the java level we don't know anything else about the problem.

Stefano

> So it appears that the message is received by the smtp server and
> forwarded to the spooler before the socket connection is wrapped up
> since the connection reset exception gets logged each time.  Here is a
> representative log:
> 
> 03/08/07 10:59:51 DEBUG smtpserver: Sent: 220 mail.jwmhosting.com SMTP
> Server (JAMES SMTP Server 2.3.0) ready Fri, 3 Aug 2007 10:59:51 -0500 (CDT)
> 03/08/07 10:59:51 DEBUG smtpserver: Calling start()
> 03/08/07 10:59:51 DEBUG smtpserver: Watchdog default Worker #12 has time
> to sleep 359953
> 03/08/07 10:59:52 ERROR smtpserver: Socket to
> adsl-87-102-37-171.karoo.KCOM.COM (87.102.37.171) closed remotely.
> java.net.SocketException: Connection reset
>        at java.net.SocketInputStream.read(Unknown Source)
>        at java.io.BufferedInputStream.fill(Unknown Source)
>        at java.io.BufferedInputStream.read(Unknown Source)
>        at
> org.apache.james.util.CRLFTerminatedReader.read(CRLFTerminatedReader.java:151)
> 
>        at
> org.apache.james.util.CRLFTerminatedReader.readLine(CRLFTerminatedReader.java:111)
> 
>        at
> org.apache.james.smtpserver.SMTPHandler.readCommandLine(SMTPHandler.java:749)
> 
>        at
> org.apache.james.smtpserver.SMTPHandler.handleConnection(SMTPHandler.java:370)
> 
>        at
> org.apache.james.util.connection.ServerConnection$ClientConnectionRunner.run(ServerConnection.java:422)
> 
>        at
> org.apache.excalibur.thread.impl.ExecutableRunnable.execute(ExecutableRunnable.java:55)
> 
>        at
> org.apache.excalibur.thread.impl.WorkerThread.run(WorkerThread.java:116)
> 
> 
> I'm a software architect and have debug skills.  I'm not implying that
> there is any problem at all with JAMES.  I'm just trying to figure out
> what could be happening on the wire that would cause this exception to
> occur.
> 
> In the SMTP protocol, is it possible that the final ACK back to the
> client could be getting lost, and Tbird is timing out and closing the
> connection? Would that cause this exception?
> 
> Thanks.
> 
> 
>> From: Stefano Bagnara <ap...@bago.org>
>> Reply-To: "James Users List" <se...@james.apache.org>
>> To: James Users List <se...@james.apache.org>
>> Subject: Re: Tuning JAMES & MySQL
>> Date: Fri, 03 Aug 2007 19:06:23 +0200
>>
>> randy roy ha scritto:
>> > Stephan,
>> >
>> > Thanks for the info.  I was able to get rid of the connection pool
>> > problem.  But there was a situation that made me get into this to begin
>> > with that unfortunately is still there after all the performance tuning
>> > stuff.
>> >
>> > I changed my provider from cable to DSL, and I'm getting failures on
>> > send.  In the SMTP log I get SocketException: Connection Reset
>> messages.
>> >
>> > This is intermittent.  Sometimes it sends fine.  But then it will
>> get on
>> > a kick and fail for an hour or so, then start working again.
>>
>> Sorry, no advice here. TCP/IP should works the same and should be
>> transport agnostic.
>> There should be no way to see difference between a cable and a DSL from
>> the TCP/IP protocols.
>>
>> Maybe your new provider runs packet inspection hardware (this is a
>> privacy violation and a known source of all kinds of problems, IMO).
>>
>> Maybe you should run some google search using your new provider name and
>> problems: you should find someone complaining for this even if they are
>> not using JAMES Server.
>>
>> > The worst part about it is that even though a failure is returned, the
>> > email actually does get sent.  So the email client continues to try to
>> > send it resulting in a bunch of copies sent.
>>
>> SMTP protocol guarantee delivery of at least one copy of each sent
>> message. Sending multiple time the same mail is a known corner case
>> problem of SMTP protocol and while it can be minimized it cannot be
>> avoided at all.
>>
>> In your case I guess there are bad network problems.
>>
>> Stefano
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-user-help@james.apache.org
>>
> 
> _________________________________________________________________
> Tease your brain--play Clink! Win cool prizes!
> http://club.live.com/clink.aspx?icid=clink_hotmailtextlink2
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Tuning JAMES & MySQL

Posted by randy roy <rj...@hotmail.com>.
Hmm, I'll try the Google route.  I'll also may may have to try a packet 
trace on both the cllent and server just to see if I can figure out what is 
happening.  (Most likely not related... but I also found that active FTP 
won't work with the DSL modem/router, but does work with cable.  So there 
are definite differences)

But strictly from a JAMES point of view, I know I get a Connection Reset 
exception in the log, yet the message is still sent.  On the client 
(Thunderbird), It says "contacting host..." then it changes to "Delivering 
message...".  But then it hangs for about a minute, and then finally times 
out and says it can't talk to smtp server (I know that's not correct... but 
Tbird obviously didn't get the final ack it was expecting).  The JAMES 
exception occurs apparently as a result of TBird finally timing out and 
aborting.  But the end result is that TBird (also tried on on Outlook... 
same results) thinks the message was NOT sent, but JAMES did deiliver it.  
Then the client retries (that's where the multiple sends occur).

So it appears that the message is received by the smtp server and forwarded 
to the spooler before the socket connection is wrapped up since the 
connection reset exception gets logged each time.  Here is a representative 
log:

03/08/07 10:59:51 DEBUG smtpserver: Sent: 220 mail.jwmhosting.com SMTP 
Server (JAMES SMTP Server 2.3.0) ready Fri, 3 Aug 2007 10:59:51 -0500 (CDT)
03/08/07 10:59:51 DEBUG smtpserver: Calling start()
03/08/07 10:59:51 DEBUG smtpserver: Watchdog default Worker #12 has time to 
sleep 359953
03/08/07 10:59:52 ERROR smtpserver: Socket to 
adsl-87-102-37-171.karoo.KCOM.COM (87.102.37.171) closed remotely.
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(Unknown Source)
        at java.io.BufferedInputStream.fill(Unknown Source)
        at java.io.BufferedInputStream.read(Unknown Source)
        at 
org.apache.james.util.CRLFTerminatedReader.read(CRLFTerminatedReader.java:151)
        at 
org.apache.james.util.CRLFTerminatedReader.readLine(CRLFTerminatedReader.java:111)
        at 
org.apache.james.smtpserver.SMTPHandler.readCommandLine(SMTPHandler.java:749)
        at 
org.apache.james.smtpserver.SMTPHandler.handleConnection(SMTPHandler.java:370)
        at 
org.apache.james.util.connection.ServerConnection$ClientConnectionRunner.run(ServerConnection.java:422)
        at 
org.apache.excalibur.thread.impl.ExecutableRunnable.execute(ExecutableRunnable.java:55)
        at 
org.apache.excalibur.thread.impl.WorkerThread.run(WorkerThread.java:116)


I'm a software architect and have debug skills.  I'm not implying that there 
is any problem at all with JAMES.  I'm just trying to figure out what could 
be happening on the wire that would cause this exception to occur.

In the SMTP protocol, is it possible that the final ACK back to the client 
could be getting lost, and Tbird is timing out and closing the connection? 
Would that cause this exception?

Thanks.


>From: Stefano Bagnara <ap...@bago.org>
>Reply-To: "James Users List" <se...@james.apache.org>
>To: James Users List <se...@james.apache.org>
>Subject: Re: Tuning JAMES & MySQL
>Date: Fri, 03 Aug 2007 19:06:23 +0200
>
>randy roy ha scritto:
> > Stephan,
> >
> > Thanks for the info.  I was able to get rid of the connection pool
> > problem.  But there was a situation that made me get into this to begin
> > with that unfortunately is still there after all the performance tuning
> > stuff.
> >
> > I changed my provider from cable to DSL, and I'm getting failures on
> > send.  In the SMTP log I get SocketException: Connection Reset messages.
> >
> > This is intermittent.  Sometimes it sends fine.  But then it will get on
> > a kick and fail for an hour or so, then start working again.
>
>Sorry, no advice here. TCP/IP should works the same and should be
>transport agnostic.
>There should be no way to see difference between a cable and a DSL from
>the TCP/IP protocols.
>
>Maybe your new provider runs packet inspection hardware (this is a
>privacy violation and a known source of all kinds of problems, IMO).
>
>Maybe you should run some google search using your new provider name and
>problems: you should find someone complaining for this even if they are
>not using JAMES Server.
>
> > The worst part about it is that even though a failure is returned, the
> > email actually does get sent.  So the email client continues to try to
> > send it resulting in a bunch of copies sent.
>
>SMTP protocol guarantee delivery of at least one copy of each sent
>message. Sending multiple time the same mail is a known corner case
>problem of SMTP protocol and while it can be minimized it cannot be
>avoided at all.
>
>In your case I guess there are bad network problems.
>
>Stefano
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>For additional commands, e-mail: server-user-help@james.apache.org
>

_________________________________________________________________
Tease your brain--play Clink! Win cool prizes! 
http://club.live.com/clink.aspx?icid=clink_hotmailtextlink2


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Tuning JAMES & MySQL

Posted by Stefano Bagnara <ap...@bago.org>.
randy roy ha scritto:
> Stephan,
> 
> Thanks for the info.  I was able to get rid of the connection pool
> problem.  But there was a situation that made me get into this to begin
> with that unfortunately is still there after all the performance tuning
> stuff.
> 
> I changed my provider from cable to DSL, and I'm getting failures on
> send.  In the SMTP log I get SocketException: Connection Reset messages.
> 
> This is intermittent.  Sometimes it sends fine.  But then it will get on
> a kick and fail for an hour or so, then start working again.

Sorry, no advice here. TCP/IP should works the same and should be
transport agnostic.
There should be no way to see difference between a cable and a DSL from
the TCP/IP protocols.

Maybe your new provider runs packet inspection hardware (this is a
privacy violation and a known source of all kinds of problems, IMO).

Maybe you should run some google search using your new provider name and
problems: you should find someone complaining for this even if they are
not using JAMES Server.

> The worst part about it is that even though a failure is returned, the
> email actually does get sent.  So the email client continues to try to
> send it resulting in a bunch of copies sent.

SMTP protocol guarantee delivery of at least one copy of each sent
message. Sending multiple time the same mail is a known corner case
problem of SMTP protocol and while it can be minimized it cannot be
avoided at all.

In your case I guess there are bad network problems.

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Tuning JAMES & MySQL

Posted by randy roy <rj...@hotmail.com>.
Stephan,

Thanks for the info.  I was able to get rid of the connection pool problem.  
But there was a situation that made me get into this to begin with that 
unfortunately is still there after all the performance tuning stuff.

I changed my provider from cable to DSL, and I'm getting failures on send.  
In the SMTP log I get SocketException: Connection Reset messages.

This is intermittent.  Sometimes it sends fine.  But then it will get on a 
kick and fail for an hour or so, then start working again.

The worst part about it is that even though a failure is returned, the email 
actually does get sent.  So the email client continues to try to send it 
resulting in a bunch of copies sent.

Since I'm in transition with my provider, I still have the cable modem 
active.  So I swapped back to cable, and it works.  Back to DSL and it 
fails.  Now this being an intermittent problem, I realize this cable/dsl 
correlation is circumstantial.  But it does seem strange.  I understand that 
it's probably DSL per se... but it could easiliy be something assoicated 
with the DSL modem/router vs. the cable modem.

Can you please explain the scenario that might cause a Connection Reset 
exception to be thrown?  I'm assuming that it has to occur on the final 
acknowledgement of success since the message is indeed being sent.

Whether it's DSL related or not, I've GOT to figure out what is happening, 
and how to get around it.  It's been getting worse over the past few days.  
(moving back from DSL to cable is not a good answer... There are other 
unrelated problems with cable).

Please give me any advice you can think of.

_________________________________________________________________
Puzzles, trivia teasers, word scrambles and more. Play for your chance to 
win! http://club.live.com/home.aspx?icid=CLUB_hotmailtextlink


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Tuning JAMES & MySQL

Posted by Stefano Bagnara <ap...@bago.org>.
randy roy ha scritto:
> When I first started with JAMES and MySQL, my mail load was pretty
> light.  So I just used the default MySQL configuration and the default
> JAMES datasource configuration.  Over the years, the amount of mail I'm
> processing has grown significantly.  It has come to the point where
> MySQL is using 90-98% of the CPU, with the CPU pegged at 100% a lot of
> the time.

First try this:
mysql> repair table spool;
mysql> repair table inbox;

> So I started looking at some of the optional pre-canned config files
> that come with MySQL.  One is called my-huge.cnf.  Seemed logical that I
> have now grown into a need for an industrial strength config of MySQL. 
> So I tried reconfiguring MySQL to use the 'huge' config setup.
> 
> The good news is that the CPU utilization went way down, implying that
> MySQL is now running much more efficiently.  The bad news is that after
> running about 3-4 minutes with the new MySQL config, JAMES starts
> throwing hundreds of "Connection Pool Exhausted" exceptions, and JAMES
> grinds to a halt.
> 
> So I had to back out the huge config for MySQL and now no more
> connection pool exceptions.  But the CPU is at 100% again.
> 
> My question is, why would using the huge MySQL config cause JAMES to
> start running out of connections?  I played around with the max
> connections field in the JAMES config.  But it didn't seem to make any
> difference.  And I don't really want to just start setting super high
> max values without knowing any criteria.  But I really need to get MySQL
> reconfigured someway to get it running more efficiently.
> 
> Can somebody give me a quick recommendation on how to match the tuning
> parameters between JAMES and MySQL?  Is there some sort of formula to
> setting connection parameters such that it works efficiently, yet
> doesn't run out of connections?
> 
> Thanks.

I specify max, max_idle and max_wait to the pool (I don't remember the
details, but I remember that the default configuration was easy to ran
out of connections).

<data-source name="maildb"
class="org.apache.james.util.dbcp.JdbcDataSource">
 <driver>com.mysql.jdbc.Driver</driver>
 <dburl>jdbc:mysql://127.0.0.1/james</dburl>
 <user>XXXX</user>
 <password>XXXXX</password>
 <max_idle>5</max_idle>
 <max>10</max>
 <max_wait>60000</max_wait>
</data-source>

Then you notice that there is a max 10: if you have more that 10 threads
that concurrently will try to get a connection you will get an
exception. So you should also make sure to not abuse spool threads and
remote delivery threads.

About spool threads: if you don't have asynchronous or slow
matcher/mailets you probably don't need too much of them. I spool
thousands of mails per minute with a couple of spool threads.

Delivery threads are less "db" intensive so it is unlikely that you
finish the connections because of them.

The specific numbers depends on your configuration: start with small
numbers and increase them only if you see specific behavior (slow
spooling, slow delivery and so on)

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org