-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running through java -jar fake-smtp-server-2.0.3.jar drains all CPU resources #199
Comments
I tried to reproduce the issue but for me it is working fine. Can you please explain in more detail what 'once serval messages sent' mean? |
I had the process running for one day with around 500 emails in queue. And the memory consumed was 1.2G and cpu 273%. Will take a screenshot next time. I restarted the server which solved it. |
A restart now caused a database corruption org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: File corrupted in chunk 30920, expected page length 4..384, got 0 [2.1.214/6]" [50000-214] org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: File corrupted in chunk 30920, expected page length 4..384, got 0 [2.1.214/6]" [50000-214] |
@jessec: To be honest I'm a bit confused. Based on your latest screenshot it seems you are running a version 0.1.0 and not version 2.0.3. A restart of the server should reset the whole database as the embedded h2 DB is running in embedded mode. It seems that you are running some kind of custom setup, maybe even with a custom compilation. Could you please describe your setup in more detail including:
|
Hello @gessnerfl , @jessec I'm using version 2.1.0, and I've just seen that I have the same problem. The docker container is launched before testing. The smtp server is launched. If I don't send any e-mail, the CPU never exceeds 10% utilization. I'm using version 2.1.0 via docker and a mac I'll try to investigate/profile Below you will find various information Docker fileFROM gessnerfl/fake-smtp-server:2.1.0
RUN yum update -y
RUN yum install -y nodejs-1:18.12.1-1.amzn2023.0.3
RUN npm install yarn -g
# The SMTP Server Port used by the Fake SMTP Server
ENV FAKESMTP_PORT=8025
# The following "secrets" are not real ones,
# they are just used for testing purposes
ENV FAKESMTP_AUTHENTICATION_USERNAME=xx
ENV FAKESMTP_AUTHENTICATION_PASSWORD=xx
# Port of the web interface
ENV SERVER_PORT=8080 docker stats informationsps informationsbash-5.2# ps
PID TTY TIME CMD
1 ? 00:16:02 java
186 ? 00:00:00 ps spring logs informations
|
@jessec @etidahouse I used de.gessnerfl.fakesmtp.TestDataCreator to create the emails. I guess this is caused by some specific emails which might result in an endless loop on the server. Can you share more details about your test data. |
In the meantime I provided version 2.1.1 which contains updates of 3rd party libraries only. |
The test data is extremely simple, this is only a test to verify the correct operation of a mail-sdk (emails with more complex data are done as integration tests with another mail server). test('send one simple plain text mail', async () => {
const { mailStorage, teardown, emailApiUrl } = mockMailClient()
const mail: Mail = {
from: 'Wino-System <wino-system@wino.fr>',
to: ['to@wino.fr'],
subject: 'test',
text: 'Hello World !',
}
const result = await send({
mailStorage,
mail,
})
expect(isSuccessful(result)).toStrictEqual(true)
expect(result).toStrictEqual(successful(expectAnyString()))
const messageId = result.value ?? ''
const emails = await retrieveEmailByMessageId(emailApiUrl, messageId)
expect(emails.content.length).toStrictEqual(1)
expect(emails.content).toStrictEqual([
{
id: expectAnyNumber(),
fromAddress: 'wino-system@wino.fr',
toAddress: 'to@wino.fr',
subject: 'test',
receivedOn: expectAnyString(),
rawData: expectAnyString(),
contents: [{ contentType: 'PLAIN', data: 'Hello World !' }],
attachments: [],
inlineImages: [],
messageId,
},
])
teardown()
}) I used an MacBook Pro Apple M1 Pro |
Hi, I've got the same behaviour with latest version 2.1.2 : java process starts nicely, stay calm even after first mails are received. But sometimes during the night (in my case), CPU usage goes 100% permanently. Nothing in the log, except for the periodic "Deleted 0 emails which exceeded the maximum number 100 of emails to be stored" which continues to be emitted. I've got two instances of fake-smtp-server on two differents VM (Redhat 6, yes I know...) and both have the same problem. |
I'm sorry for the delay. Yes I will try the 2x version. Yes I'm running H2 with a file for persistence. I'm now restarting the server daily to solve the cpu spikes for me this is an acceptable situation, but for other maybe not. |
Something I noticed (but without being 100% sure) : if I have some mails in the inbox and that it's not empty, the "100% CPU" problem doesn't happen. Could it be some sort of process / loop that goes mad with zero message ? |
I created a test setup to reproduce the issue. I run the latest version 2.1.3 on an AWS EC2 instance (t4g.small ARM64 2 VCPU, 2GB RAM) with 60% memory allocation for the JVM. In Addition to this I send every 10min 10 emails to the server. This is the server configuration: server:
port: 8080
shutdown: graceful
management:
server:
port: 8081
endpoints:
web:
exposure:
include: '*'
spring:
profiles:
active: default
datasource:
url: jdbc:h2:mem:mail
username: admin
password: Test1234
driver-class-name: org.h2.Driver
jpa:
hibernate:
ddl-auto: validate
data:
web:
pageable:
size-parameter: size
page-parameter: page
default-page-size: 10
one-indexed-parameters: false
max-page-size: 1000
h2:
console:
enabled: true
mvc:
hiddenmethod:
filter:
enabled: true
jackson:
serialization:
write-dates-as-timestamps: false
springdoc:
swagger-ui:
path: /swagger-ui.html
fakesmtp:
port: 8025
persistentce:
maxNumberEmails: 100 So far memory is on a very low level (between 128MB and 220MB). CPU is idling all time. I configured the JVM to create a Heap Dump on OutOfMemoryErrors.. I also installed a monitoring solution to gather near real time metrics. @Depact / @jessec / @slanglade / @etidahouse Can you please also share more details about your setup (CPU, Memory, Heap, Non Heap Memory). Is it the same for all of you that you have no messages stored as reported by @jessec? |
…en_client_stops_sending_data #199: fix command loop to terminate when no data is sent by client
@Depact / @etidahouse / @jessec / @slanglade Please let me know if the issue is resolved so that the issue can be closed. |
Hello @gessnerfl The fix works, no more CPU problems and connections are closed correctly (before, I had to force jest to close via Great job and many thanks ! 🙏 😄 |
I tested with latest version and it's not reproduce anymore for me. |
Yes indeed, the problem is solved! All the installations on my side are running smoothly since a couple of weeks. Many thanks ! |
Reproduces for me once several messages is sent.
The text was updated successfully, but these errors were encountered: