programing

간헐적 ORA-22288 오류 - 명령 길이가 부정확함

elecom 2023. 9. 5. 19:41
반응형

간헐적 ORA-22288 오류 - 명령 길이가 부정확함

정기적인 작업의 일부로 데이터베이스 서버에 있는 파일을 열어야 하는 웹 응용 프로그램에 간헐적인 문제가 있습니다.대부분의 시간 동안 이 기능은 문제 없이 작동하지만, 겉보기에는 무작위로 나타나는 시간에 해당 요청이 HTTP 400 오류를 반환하기 시작합니다.Apache 서버를 바운스하면 한동안 문제가 해결되지만 항상 하루 또는 최대 일주일 내에 반환됩니다.

관련 pl/sql 코드(아니요, 도망가지 마세요! come back!)에 로그를 추가했습니다. 이 코드는 참고를 위해 아래에 나열했습니다.

declare
  bl_blob blob;
  bf_file bfile := bfilename(<directory that totally exists>, <file that totally exists>);
begin
  dbms_lob.createTemporary(bl_blob, true);
  dbms_lob.open(bf_file, dbms_lob.lob_readonly);
  dbms_lob.open(bl_blob, dbms_lob.lob_readwrite);
  dbms_lob.loadfromfile(bl_blob, bf_file, dbms_lob.getLength(bf_file));
  dbms_lob.close(bf_file);
  return bl_blob;
end;

400개의 오류는 다음과 같은 ORA-22288 오류에 해당하는 것으로 나타났습니다.

file or LOB operation FILEOPEN failed
The program issued a command but the command length is incorrect

제 질문은 왜 작업이 갑자기 반복적으로 동일한 파일을 문제 없이 열 수 있는 위치에서 오류를 발생시키기 시작하느냐는 것입니다.기본 파일은 변경되지 않으며 읽기 전용 권한을 사용하여 프로그래밍 방식으로만 열립니다.

제가 지금까지 진행한 포럼 발굴은 대부분 "끄고 켜는" 해결책을 만들어냈습니다.네.

어떤 도움이든 대단히 감사합니다.

이 코드가 정확히 당신이 실행하고 있는 코드인지 아니면 SO용으로 단순화했는지 모르겠습니다.당신의 b 파일은 기본적으로 포인터이기 때문에 포인터를 설정한 후 디스크에서 파일을 수정하면 어떻게 되는지 모르겠습니다.이와 같은 익명 블록이 SQL 문과 같은 방식으로 구문 분석되고 캐시되는지도 잘 모르겠습니다.간단히 말해서, 이것을 시도해 보십시오.

declare
  bl_blob blob;
  bf_file bfile;
begin
  bf_file := bfilename(<directory that totally exists>, <file that totally exists>);
  dbms_lob.createTemporary(bl_blob, true);
  dbms_lob.open(bf_file, dbms_lob.lob_readonly);
  dbms_lob.open(bl_blob, dbms_lob.lob_readwrite);
  dbms_lob.loadfromfile(bl_blob, bf_file, dbms_lob.getLength(bf_file));
  dbms_lob.close(bf_file);
  return bl_blob;
end;

사용하는 대신dbms_lob.getLength(bf_file)로드할 금액에 대해 다음을 사용해 보십시오.DBMS_LOB.LOBMAXSIZE도움이 될 수 있습니다.

앱 서버의 프레임워크를 메모하지 않았거나 보지 못했지만 앱 서버에서 Java를 실행할 수 있다면 코드를 상당히 단순화할 수 있습니다.그것이 당신의 문제를 해결할 수 있을지는 모르겠지만 적어도 b 파일의 길이를 알 필요는 없을 것입니다.

public void getFile (String oradir, String filename, String filesysdir) throws FileNotFoundException, IOException, SQLException, Exception {
    CallableStatement s = this.conn.prepareCall("select bfilename(?,?) from dual");
    s.setString(1, oradir);
    s.setString(2, filename);
    OracleResultSet r = (OracleResultSet) s.executeQuery();
    if (r.next())
        saveBFILE(r.getBFILE(1), filesysdir);
}

private void saveBFILE (BFILE b, String dir) throws FileNotFoundException, IOException, SQLException {
    b.openFile();
    InputStream s = b.getBinaryStream();
    InputStreamReader r = new InputStreamReader(s);
    String name = b.getName();
    String path = dir == null ? name : dir + '/' + name;
    System.out.println("creating " + name);
    FileOutputStream w = new FileOutputStream(new File(path));
    int nb;
    byte[] ba = new byte[4096];
    while ((nb = s.read(ba)) != -1)
        w.write(ba, 0, nb);
    w.close();
    b.closeFile();
}

언급URL : https://stackoverflow.com/questions/25913032/intermittent-ora-22288-error-command-length-incorrect

반응형