Skip to content

[Bug]: BCP import memory leak with varchar(max) #2462

@staticlibs

Description

@staticlibs

What happened?

This issue is similar to #2455, there seems to be a leak in processing Partially Length-prefixed (PLP) incoming records. Memory is allocated in MessageContext, so it is released after BCP import finishes. Still can be a problem when importing large files.

Excessive memory usage can be shown using BCP import with a table like this:

create table tab1 (col1 varchar(max))
insert into tab1 values('foobar')
insert into tab1 values(null)
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
insert into tab1 select * from tab1
select count(*) from tab1
> 2097152

Will submit a PR.

Version

BABEL_3_X_DEV (Default)

Extension

babelfishpg_tds

Which flavor of Linux are you using when you see the bug?

Fedora

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions