Skip to content
This repository has been archived by the owner on Aug 12, 2020. It is now read-only.

low RAM embedded vs external mserver behavior on linux #114

Open
ajdamico opened this issue Mar 4, 2017 · 3 comments
Open

low RAM embedded vs external mserver behavior on linux #114

ajdamico opened this issue Mar 4, 2017 · 3 comments
Milestone

Comments

@ajdamico
Copy link
Contributor

ajdamico commented Mar 4, 2017

@hannesmuehleisen is this what you expect to happen on linux? seems to make sense given your malloc() explanation. thanks

on rocks010

needed installs:

# devtools::install_github( "hannesmuehleisen/MonetDBLite" )
# devtools::install_github( "krlmlr/ulimit" )

2.5gb ulimit external mserver. anything lower than that, mserver does not open

> ulimit -v 2500000
> R

library(DBI)
library(MonetDBLite)

dbdir <- tempdir()

startscript <- monetdb.server.setup(dbdir,"/usr/local/monetdb/", "mydb", 50000)
# monetdb path for me on rocks010 #
# startscript <- monetdb.server.setup(dbdir,"/export/scratch1/home/damico/MonetDB/bin/", "mydb", 50000)

pid <- monetdb.server.start(startscript)
con <- dbConnect(MonetDB.R(), "monetdb://localhost:50000/mydb" , wait = TRUE )

# 5,000 record tables, 100,000 times
for( i in seq( 100000 ) ) { cat( i , "\r\n" ) ; dbWriteTable( con , 'x' , mtcars[ rep( 1:10 , 500 ) , ] , append = TRUE ) }


	# 2048
	# 2049
	# 2050
	# 2051
	# Error in .local(conn, statement, ...) :
	  # Unable to execute statement 'COMMIT'.
	# Server says 'ERROR: MT_mremap: mremap(0x7ff9fc850000,82051072,98500608) failed' [#GDKerror:].
	# >
	# > traceback()
	# 9: stop("Unable to execute statement '", statement, "'.\nServer says '",
		   # errmsg, "' [#", errno, "].")
	# 8: .local(conn, statement, ...)
	# 7: dbSendQuery(conn, "COMMIT")
	# 6: dbSendQuery(conn, "COMMIT")
	# 5: dbCommit(conn)
	# 4: dbCommit(conn)
	# 3: .local(conn, name, value, ...)
	# 2: dbWriteTable(con, "x", mtcars[rep(1:10, 500), ], append = TRUE)
	# 1: dbWriteTable(con, "x", mtcars[rep(1:10, 500), ], append = TRUE) at #1
	# >


	# 2050
	# 2051
	# Error in .local(conn, statement, ...) :
	  # Unable to execute statement 'COMMIT'.
	# Server says 'ERROR: MT_mremap: mremap(0x7f7aeee00000,82051072,98500608) failed' [#GDKerror:].
	# >

2.5gb ulimit embedded mserver: does not pass i=1800

> ulimit -v 2500000
> R

library(DBI)
library(MonetDBLite)

dbdir <- tempdir()

con <- dbConnect(MonetDBLite(), dbdir )

# 5,000 record tables, 100,000 times
for( i in seq( 100000 ) ) { cat( i , "\r\n" ) ; dbWriteTable( con , 'x' , mtcars[ rep( 1:10 , 500 ) , ] , append = TRUE ) }


	# 1708
	# 1709
	# Error in .local(conn, name, value, ...) :
	  # Failed to insert data: MALException:embedded:Could not convert column 9 gear to type 9
	# > traceback()
	# 4: stop("Failed to insert data: ", insres)
	# 3: .local(conn, name, value, ...)
	# 2: dbWriteTable(con, "x", mtcars[rep(1:10, 500), ], append = TRUE)
	# 1: dbWriteTable(con, "x", mtcars[rep(1:10, 500), ], append = TRUE) at #1
	# >


	# 1702
	# 1703
	# Error in .local(conn, statement, ...) :
	  # Unable to execute statement 'select schemas.name as sn, tables.name as tn from sys.tables join sys.schemas on tables.schema_id=sc...'.
	# Server says 'GDKerror:!ERROR: GDKreallocmax: failed for 40016 bytes !ERROR: MT_mmap: mmap(/tmp/Rtmp5mtmJx/bat/05/40/54061.tail,65536) failed !OS: Cannot allocate memory !ERROR: GDKmallocmax: failed for 40000 bytes !ERROR: GDKmallocmax: failed for 40000 bytes !ERROR: HEAPextend: failed to extend to 40000 for 05/40/54061.tail: h->storage == STORE_MEM && can_map && fd >= 0 && HEAPload_intern() != GDK_SUCCEED !ERROR: GDKreallocmax: failed for 40016 bytes !ERROR: MT_mmap: mmap(/tmp/Rtmp5mtmJx/bat/05/40/54062.tail,65536) failed !OS: Cannot allocate memory !ERROR: GDKmallocmax: failed for 40000 bytes !ERROR: GDKmallocmax: failed for 40000 bytes !ERROR: HEAPextend: failed to extend to 40000 for 05/40/54062.tail: h->storage == STORE_MEM && can_map && fd >= 0 && HEAPload_intern() != GDK_SUCCEED '.
	# >


	# 1421
	# 1422
	# 1423
	# 1424
	# 1425
	# 1426
	# Error in .local(conn, statement, ...) :
	  # Unable to execute statement 'select schemas.name as sn, tables.name as tn from sys.tables join sys.schemas on tables.schema_id=sc...'.
	# Server says 'GDKerror:!ERROR: MT_mremap: mremap(0x7f169cc80000,57016320,68419584) failed !OS: Cannot allocate memory !ERROR: HEAPextend: failed to extend to 68419584 for 03/346.tail: GDKmremap() failed '.
	# > traceback()
	# 14: stop("Unable to execute statement '", statement, "'.\nServer says '",
			# env$message, "'.")
	# 13: .local(conn, statement, ...)
	# 12: dbSendQuery(conn, statement, ...)
	# 11: dbSendQuery(conn, statement, ...)
	# 10: dbGetQuery(conn, q)
	# 9: dbGetQuery(conn, q)
	# 8: .local(conn, ...)
	# 7: dbListTables(conn, sys_tables = T)
	# 6: dbListTables(conn, sys_tables = T)
	# 5: dbExistsTable(conn, qname)
	# 4: dbExistsTable(conn, qname)
	# 3: .local(conn, name, value, ...)
	# 2: dbWriteTable(con, "x", mtcars[rep(1:10, 500), ], append = TRUE)
	# 1: dbWriteTable(con, "x", mtcars[rep(1:10, 500), ], append = TRUE) at #1
	# >

random strangeness enforcing ulimit with library(ulimit) rather than ulimit -v

300mb embedded lite error

# out of memory (error, not crash)
library(DBI)
ulimit::memory_limit( 300 )
db <- dbConnect( MonetDBLite::MonetDBLite() )
for( i in seq( 1000 ) ) { cat( i , "\r\n" ) ; dbWriteTable( db , 'x' , mtcars , append = TRUE ) }
	# Error in .local(conn, statement, ...) :
	  # Unable to execute statement 'select schemas.name as sn, tables.name as tn from sys.tables join sys.schemas on tables.schema_id=sc...'.
	# Server says 'MALException:bat.new:GDK reported error. !ERROR: GDKmallocmax: failed for 10240 bytes !ERROR: GDKmallocmax: failed for 40 bytes !ERROR: GDKmallocmax: failed for 40 bytes !ERROR: HEAPalloc: Insufficient space for HEAP of 10240 bytes. '.

200mb embedded lite crash

# segfault (crash)
library(DBI)
ulimit::memory_limit( 200 )
db <- dbConnect( MonetDBLite::MonetDBLite() )
 # *** caught segfault ***
# address 0x6498, cause 'memory not mapped'

# Traceback:
 # 1: .Call("monetdb_startup_R", dir, quiet, getOption("monetdb.squential",     sequential), PACKAGE = libfilename)
 # 2: monetdb_embedded_startup(embedded, !getOption("monetdb.debug.embedded",     FALSE), getOption("monetdb.sequential", FALSE))
 # 3: .local(drv, ...)
 # 4: dbConnect(MonetDBLite::MonetDBLite())
 # 5: dbConnect(MonetDBLite::MonetDBLite())

# Possible actions:
# 1: abort (with core dump, if enabled)
# 2: normal R exit
# 3: exit R without saving workspace
# 4: exit R saving workspace
# Selection:
# Selection:
@ajdamico ajdamico self-assigned this Mar 4, 2017
@ajdamico ajdamico changed the title low memory embedded versus external mserver behavior low RAM embedded vs external mserver behavior on mac and unix Mar 4, 2017
@ajdamico ajdamico changed the title low RAM embedded vs external mserver behavior on mac and unix low RAM embedded vs external mserver behavior on linux Mar 4, 2017
@ajdamico ajdamico removed their assignment Mar 4, 2017
@hannes
Copy link
Owner

hannes commented Mar 5, 2017

Ok if it throws an error thats fine by me. It should not crash however.

@ajdamico ajdamico self-assigned this Mar 5, 2017
@ajdamico
Copy link
Contributor Author

ajdamico commented Mar 5, 2017

thanks. i'll hold onto this issue and keep thinking, and write a similar one for windows. opening separate issue for you for the crash

@ajdamico ajdamico modified the milestone: 0.4.0 Mar 5, 2017
@hannes
Copy link
Owner

hannes commented Jun 15, 2017

still an issue? there have been various checks added to monetdb to avoid this.

@ajdamico ajdamico modified the milestones: 0.4.0, 0.5.0 Jun 24, 2017
@ajdamico ajdamico removed their assignment Nov 5, 2017
@hannes hannes modified the milestones: 0.5.0, 0.6.0 Nov 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants