question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

level-party leader process holding memory

See original GitHub issue

env

  • OS: ubuntu 20.04
  • node: v16.13.1
  • level-party: v5.1.1
  • leveldown options: none

problem

Our level-party leader process holds up to 3GB of RAM, and refuses to release it once the activity peak passes, before being eventually killed by Linux OOM Killer (See https://github.com/inventaire/inventaire/issues/542)

It’s actually probably not a level-party-specific issue, as trying to run with only level produces the same behavior, but I didn’t know where to post: would that be a leveldown issue? Is that an expected amount of RAM for leveldb with the default options? Any clue on what we can try to address this?

Thanks for any help, I’m running short of ideas ^^’

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vweeverscommented, May 6, 2022

Glad to hear you found the issue, congrats!

Is this an expected behavior to be able to pass an array as a batch operation key?

Sort of, yes. It depends on the encoding. In this case the key goes through the utf8 encoding which just does String(key).

In general, encodings don’t validate input, in order to be fast and forgiving. They massage user input into a desired type. For example, db.get(Buffer.from('3')) and db.get(3) and db.get('3') all do the same thing. I’m not sure to what extent that’s by design (historically) but it’s fitting for JavaScript.

You could opt-in to stricter type checking by using TypeScript.

Is it possible to customize _serializeKey?

Encodings are applied before _serializeKey() so at that point your array key has already been converted to a string. Side note: the _serializeKey method no longer exists in abstract-level.

1reaction
maxlathcommented, May 6, 2022

I’m delighted to announce that this issue seems solved 😅

I went into details of the issue in the commit message here https://github.com/inventaire/inventaire/commit/4141906b7ea47fcbb6bf374104648706949b4db8 but here is a summary of what might be of interest for level-party:

An error in our code was making us build batch operations arrays with a big array mistakenly passed as an operation key. Somewhere between levelup batch function and abstratct-leveldown batch function, that array operation key was turned into a buffer, and the batch operations went on without throwing an error.

Is this an expected behavior to be able to pass an array as a batch operation key? If yes:

  • That issue can be closed, and sorry for bothering
  • Is there a way to optionally choose to forbid that? Is it possible to customize _serializeKey from a level-party db object, to make it reject an array passed as a key?

Minimum code to reproduce it:

const db = require('level-party')('/tmp/foo')

db.batch([
  {
    type: 'del',
    // This key will be converted to "foo,bar", no error will be raised
    // 'level' has the same behavior
    key: [ 'foo', 'bar' ]
  }
])
.then(res => console.log('success', res))
.catch(err => console.error('error', err))
Read more comments on GitHub >

github_iconTop Results From Across the Web

AP Government Chapter 9 Notes: Political Parties
A political party might be formally defined as a group of political activists who organize to win elections, to operate the government, and...
Read more >
Proficiency Levels for Leadership Competencies - OPM
accurate information to reduce conflict or concern within workplace. • Takes action to address employee grievances. U.S. Office of Personnel Management. 7. Page ......
Read more >
There are three main reasons a coalition is formed:
This document outlines some of the best practices of successful political coalitions and sets forth issues which political parties and other organizations ...
Read more >
Party members and leadership styles in new European ...
The determinants of leadership style assessment differ greatly across political parties. Introduction. Party leaders are of great importance to politics and to ...
Read more >
The role of politicians and political parties in combating racism ...
Politicians and political parties should protect against racism, racial discrimination, xenophobia and related intolerance by enacting laws and creating ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found