Skip to content
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

[Bug]: BCP import records are buffered in memory #2468

Open
1 task done
staticlibs opened this issue Apr 5, 2024 · 0 comments
Open
1 task done

[Bug]: BCP import records are buffered in memory #2468

staticlibs opened this issue Apr 5, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@staticlibs
Copy link
Contributor

What happened?

When BCP import is performed, fields of type varchar (and some other types) from incoming records are allocated in MessageContext. These buffered fields are kept in memory for all incoming records until the end of BCP import call.

For example, for table like this, backend memory usage on BCP import will grow linearly if we increase the number of records:

create table tab1(col1 varchar(10))
insert into tab1 values('foobar')
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
insert into tab1 select col1 from tab1
select count(*) from tab1
> 1048576

Unlike #2455 and #2462, it is not trivial to free these allocations promptly because of two levels of batching - implicit one on protocol side and MAX_BUFFERED_TUPLES (1000) on executor side.

I'll file a PR with an experimental patch to track these allocations and free them as soon as possible.

Version

BABEL_3_X_DEV (Default)

Extension

babelfishpg_tsql (Default)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants