Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 24989 invoked from network); 25 Jul 2006 09:50:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 25 Jul 2006 09:50:22 -0000 Received: (qmail 77614 invoked by uid 500); 25 Jul 2006 09:50:06 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 77584 invoked by uid 500); 25 Jul 2006 09:50:06 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 77573 invoked by uid 99); 25 Jul 2006 09:50:06 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jul 2006 02:50:06 -0700 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=HTML_MESSAGE,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [128.222.32.20] (HELO mexforward.lss.emc.com) (128.222.32.20) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jul 2006 02:50:05 -0700 Received: from mailhub.lss.emc.com (uraeus.lss.emc.com [10.254.144.14]) by mexforward.lss.emc.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id k6P9nhWo008598 for ; Tue, 25 Jul 2006 05:49:43 -0400 (EDT) Received: from mxic2.corp.emc.com (mxic2.corp.emc.com [128.221.12.9]) by mailhub.lss.emc.com (Switch-3.1.8/Switch-3.1.7) with ESMTP id k6P9nebe016031 for ; Tue, 25 Jul 2006 05:49:40 -0400 (EDT) Received: by mxic2.corp.emc.com with Internet Mail Service (5.5.2653.19) id ; Tue, 25 Jul 2006 05:49:40 -0400 Message-ID: <396C95029B79F449B3767543B1491E167A769C@CORPUSMX60A.corp.emc.com> From: samoilov_denis@emc.com To: users@tomcat.apache.org Subject: corrupted stream Date: Tue, 25 Jul 2006 05:49:33 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C6AFCF.A23C31A8" X-PMX-Version: 4.7.1.128075, Antispam-Engine: 2.4.0.264935, Antispam-Data: 2006.7.25.21432 X-PerlMx-Spam: Gauge=, SPAM=3%, Reason='EMC_FROM_0+ -2, HTML_70_90 0.1, NO_REAL_NAME 0, __CP_MEDIA_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_ALT 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HTML_FONT_BLUE 0, __HTML_FONT_GREEN 0, __HTML_FONT_RED 0, __IMS_MSGID 0, __IMS_MUA 0, __MIME_HTML 0, __MIME_VERSION 0, __SANE_MSGID 0, __TAG_EXISTS_HTML 0' X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------_=_NextPart_001_01C6AFCF.A23C31A8 Content-Type: text/plain Hello, We entercounter the problem that under high workload we get corrupted data from Inputstream. The interesting moment that corruption has following structure: imagine correct data as number of chunks - 1,2,3,4,5 received data - 3,4,3,4,5 (the first two chunks replaced by middle chunks). The size of such chunks is exactly 1260 bytes. the corruption can occure in the middle of file(e.g. 1,2,5,4,5). Number of corrupted chunks can vary Here is situation description: We have Tomcat 5.0.28(JVM: 1.5.0._06) and java servlet that works on it. The servlet application receives binary files. The workload is high: more than 200 concurent users(and more than 2000 total). Every user uploads to server number image files(size of each is about 700Kb). Tomcat has default settings (see below). Clients connect to Tomcat directly. Our code is (not exactly because it spared between different classes): BufferedInputStream sis = null; File f = new File(fileName); BufferedOutputStream bos = null; FileOutputStream fos = null; long totalBytesReceived = 0L; try { sis = new BufferedInputStream(m_request.getInputStream()); byte[] buffer = new byte[FILE_UPLOAD_BUFFER_SIZE]; File f = new File(fileName); fos = new FileOutputStream(f, true); bos = new BufferedOutputStream(fos); int bytesRead; while ((bytesRead = sis.read(buffer)) >= 0) { bos.write(buffer, 0, bytesRead); totalBytesReceived += bytesRead; } } catch (IOException e) { ... } } finally { try { if (bos != null) bos.close(); if (fos != null) fos.close(); } catch (IOException e) { logger.warn("Close output stream throws an exception", e); throw new MyException(MyException.ERR_REQUEST_PROCESS, e); } } Can anybody suggest to use what we can do to resolve this situation. Regards, Denis Additional info: Tomcat runs on Windows 2003 (Windows Server 2003 Enterprise SP1 Intel Xeon CPU 3.60 Ghz 2.00 GB of RAM). Tomcat(server.xml): - - - - factory org.apache.catalina.users.MemoryUserDatabaseFactory - pathname conf/tomcat-users.xml - - - Tomcat ------_=_NextPart_001_01C6AFCF.A23C31A8--