Обсуждение: PostgreSQL - unrecognized win32 error code: 38

Поиск
Список
Период
Сортировка

PostgreSQL - unrecognized win32 error code: 38

От
ZhenHua Cai
Дата:
Hi All

I encountered one problem. It repeats again and again. Please help.
"ComputeComputer" is one stored procedure. The version of PostgreSQL I am using is 12.

2019-10-26 07:36:58.880 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.880 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.889 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.889 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.889 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.890 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.890 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.890 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.900 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.900 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.900 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.900 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.900 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.900 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.910 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.910 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.910 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.911 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.911 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.911 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.919 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.919 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.919 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.920 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.920 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.920 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.933 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.933 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.933 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.934 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.934 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.934 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.943 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.943 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.943 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.944 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.944 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.944 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.953 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.953 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.953 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.954 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.954 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.954 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.963 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.963 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.963 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.964 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.964 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.964 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.973 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.973 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.973 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.974 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.974 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.974 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.983 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.983 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.983 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.984 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.984 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.984 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.993 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.993 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.993 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:58.994 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:58.994 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:58.994 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:59.003 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:59.003 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:59.003 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)
2019-10-26 07:36:59.004 HKT [5376] LOG:  unrecognized win32 error code: 38
2019-10-26 07:36:59.004 HKT [5376] CONTEXT:  SQL function "ComputeComputer" statement 1
2019-10-26 07:36:59.004 HKT [5376] STATEMENT:  CALL "dbo"."ComputeComputer"(1)

Thanks
Jacky

Re: PostgreSQL - unrecognized win32 error code: 38

От
Adrian Klaver
Дата:
On 10/25/19 5:19 PM, ZhenHua Cai wrote:
> Hi All
> 
> I encountered one problem. It repeats again and again. Please help.
> "ComputeComputer" is one stored procedure. The version of PostgreSQL I 
> am using is 12.
> 
> 2019-10-26 07:36:58.880 HKT [5376] CONTEXT:  SQL function 
> "ComputeComputer" statement 1

Not sure how that can be answered without knowing what ComputeComputer 
is doing?
> 
> Thanks
> Jacky


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: PostgreSQL - unrecognized win32 error code: 38

От
Michael Paquier
Дата:
On Sat, Oct 26, 2019 at 11:02:26AM -0700, Adrian Klaver wrote:
> Not sure how that can be answered without knowing what ComputeComputer is
> doing?

Yes, there is nothing of this kind in the PostgreSQL code.  So you may
want to check your own extension code if a module is involved here, or
perhaps you are just using a fork of Postgres..
--
Michael

Вложения

Re: PostgreSQL - unrecognized win32 error code: 38

От
Tom Lane
Дата:
Michael Paquier <michael@paquier.xyz> writes:
> On Sat, Oct 26, 2019 at 11:02:26AM -0700, Adrian Klaver wrote:
>> Not sure how that can be answered without knowing what ComputeComputer is
>> doing?

> Yes, there is nothing of this kind in the PostgreSQL code.

Sure there is: win32error.c produces exactly that message if its
mapping table has no entry for the Windows error code.

According to

https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-?redirectedfrom=MSDN

code 38 decimal is ERROR_HANDLE_EOF, "Reached the end of the file.",
which indeed is not in the doserrors[] table.

But that just deepens the mystery --- if we hit an EOF, why wasn't
that handled through more-normal channels?  We still need to know
what that function was trying to do, and whether any non-core
C code was involved.

            regards, tom lane



Re: PostgreSQL - unrecognized win32 error code: 38

От
ZhenHua Cai
Дата:
The following is the SQL statement of that function.

DROP TABLE IF EXISTS "GenericReadList" ;
CREATE TEMP TABLE "GenericReadList"(
"ComputerProfileId" int NOT NULL,
"Trustee" uuid NOT NULL,
"AccessControlType" smallint NULL,
"AceOrder" int NULL
);

INSERT INTO "GenericReadList"

SELECT t1."ComputerProfileId", t1."Trustee", t1."AccessControlType", t1."AceOrder" FROM

(

SELECT a."ComputerProfileId", s."ADUser" "Trustee", a."AccessControlType", a."AceOrder" FROM "TmpResult" r

INNER JOIN "TmpTrusteeSid" s ON s."ADUser" = r."Trustee"

INNER JOIN "AccessRights" a ON a."TrusteeSid" = s."Sid" AND r."ComputerProfileId" = a."ComputerProfileId" AND a."AccessRight" = 4

) t1

Thanks
Jacky

On Sun, Oct 27, 2019 at 7:45 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Michael Paquier <michael@paquier.xyz> writes:
> On Sat, Oct 26, 2019 at 11:02:26AM -0700, Adrian Klaver wrote:
>> Not sure how that can be answered without knowing what ComputeComputer is
>> doing?

> Yes, there is nothing of this kind in the PostgreSQL code.

Sure there is: win32error.c produces exactly that message if its
mapping table has no entry for the Windows error code.

According to

https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-?redirectedfrom=MSDN

code 38 decimal is ERROR_HANDLE_EOF, "Reached the end of the file.",
which indeed is not in the doserrors[] table.

But that just deepens the mystery --- if we hit an EOF, why wasn't
that handled through more-normal channels?  We still need to know
what that function was trying to do, and whether any non-core
C code was involved.

                        regards, tom lane

Re: PostgreSQL - unrecognized win32 error code: 38

От
Michael Paquier
Дата:
On Mon, Oct 28, 2019 at 09:51:07AM -0700, ZhenHua Cai wrote:
> The following is the SQL statement of that function.
>
> DROP TABLE IF EXISTS "GenericReadList" ;
> CREATE TEMP TABLE "GenericReadList"(
> "ComputerProfileId" int NOT NULL,
> "Trustee" uuid NOT NULL,
> "AccessControlType" smallint NULL,
> "AceOrder" int NULL
> );

The original complain comes from a function called ComputeComputer.
What does it do and where does it come from?  Does it call any in-core
code which would cause the failure.  If the function is a SQL
function, could you provide a self-contained test case?
--
Michael

Вложения

Re: PostgreSQL - unrecognized win32 error code: 38

От
ZhenHua Cai
Дата:
No, it doesn't call any in-core code. 
The following is the code in that function

DROP TABLE IF EXISTS "GenericReadList" ;
CREATE TEMP TABLE "GenericReadList"(
"ComputerProfileId" int NOT NULL,
"Trustee" uuid NOT NULL,
"AccessControlType" smallint NULL,
"AceOrder" int NULL
);

INSERT INTO "GenericReadList"

SELECT t1."ComputerProfileId", t1."Trustee", t1."AccessControlType", t1."AceOrder" FROM

(

SELECT a."ComputerProfileId", s."ADUser" "Trustee", a."AccessControlType", a."AceOrder" FROM "TmpResult" r

INNER JOIN "TmpTrusteeSid" s ON s."ADUser" = r."Trustee"

INNER JOIN "AccessRights" a ON a."TrusteeSid" = s."Sid" AND r."ComputerProfileId" = a."ComputerProfileId" AND a."AccessRight" = 4

) t1

On Mon, Oct 28, 2019 at 5:56 PM Michael Paquier <michael@paquier.xyz> wrote:
On Mon, Oct 28, 2019 at 09:51:07AM -0700, ZhenHua Cai wrote:
> The following is the SQL statement of that function.
>
> DROP TABLE IF EXISTS "GenericReadList" ;
> CREATE TEMP TABLE "GenericReadList"(
> "ComputerProfileId" int NOT NULL,
> "Trustee" uuid NOT NULL,
> "AccessControlType" smallint NULL,
> "AceOrder" int NULL
> );

The original complain comes from a function called ComputeComputer.
What does it do and where does it come from?  Does it call any in-core
code which would cause the failure.  If the function is a SQL
function, could you provide a self-contained test case?
--
Michael

Re: PostgreSQL - unrecognized win32 error code: 38

От
Thomas Munro
Дата:
On Tue, Oct 29, 2019 at 9:23 PM ZhenHua Cai <zhhua.cai@gmail.com> wrote:
> No, it doesn't call any in-core code.

I wondered if this could be coming from the new code in
src/port/pg_p{read,write}.c.  ERROR_HANDLE_EOF is a documented
GetLastError() return value after ReadFile() fails[1], but only for
asynchronous files.  We are using that interface ("overlapped" IO,
their name for asynchronous IO, but the same interface can also do
synchronous IO and happens to support an offset like Unix's pread()),
but we're not opening file handles with FILE_FLAG_OVERLAPPED so we
have a plain old synchronous handle here.

Searching the web for ERROR_HANDLE_EOF leads to a least one
discussion[2] of "mailslots" (like our syslog pipe?) and a couple of
possible underlying NT errors, and following those leads some other
stuff about SMB filesystems and sockets.  Is your database running on
a local or SMB (or other remote) filesystem?  Are you using the
PostgreSQL syslog process?  I don't know anything about Windows at all
but from these breadcrumbs I feel like there has to be a network or
asynchronous communication involved somewhere here, not a plain old
end-of-file on a regular synchronous file operation, which, as Tom
said, we have code paths for that don't look like this (because that
just shows up as 0 bytes read).

[1] https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile
[2] https://stackoverflow.com/questions/56510727/what-causes-writefile-to-return-error-38-error-handle-eof



Re: PostgreSQL - unrecognized win32 error code: 38

От
Thomas Munro
Дата:
On Wed, Oct 30, 2019 at 12:13 AM Thomas Munro <thomas.munro@gmail.com> wrote:
> On Tue, Oct 29, 2019 at 9:23 PM ZhenHua Cai <zhhua.cai@gmail.com> wrote:
> > No, it doesn't call any in-core code.
>
> I wondered if this could be coming from the new code in
> src/port/pg_p{read,write}.c.  ERROR_HANDLE_EOF is a documented
> GetLastError() return value after ReadFile() fails[1], but only for
> asynchronous files.  We are using that interface ("overlapped" IO,
> their name for asynchronous IO, but the same interface can also do
> synchronous IO and happens to support an offset like Unix's pread()),
> but we're not opening file handles with FILE_FLAG_OVERLAPPED so we
> have a plain old synchronous handle here.

> [1] https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile

Hi,

With a little help we got to the bottom of this:


https://www.postgresql.org/message-id/flat/CAC%2BAXB0_zNFUH1BrRGKUkFxvq3SxsojroJN70iTUA1gUNn_gag%40mail.gmail.com#cb324760c6a142ec4ed6abefa8e68f18

It should be fixed in the next release.  Thanks for the report!