database - After I restart PostgreSQL all my tables are empty (zero rows) -


using mac os x 10.10 (yosemite) , homebrew (0.9.5), i've installed postgresql 9.4.1. current versions of time of posting...

i've managed import brutally large database (56m records - 15 hours import), , written app work locally. found app, pgadmin3, lets me sorts of admin tasks gui. good.

every time restart computer, once due kernel panic usb firewire audio interface, once power failure, , 2 user initiated restarts - each time after reboot, database empty. database users/roles still there, tables , relations there, however, tables empty. 0 records. nothing. pgadmin3 shows table has space allocated number of millions of records, "undefined" count. refreshing count, reveals 0 records. browsing data reveals 0 records. mac application (using libpq) connects database successfully, , gets 0 results any/all of select statements. redundant mention each re-import of database takes 15 hours? (rhetorical question)

any , suggestions appreciated.

mac os x 10.0.2 (yosemite) homebrew 0.9.5 postgresql 9.4.1 on x86_64-apple-darwin14.1.0, compiled apple llvm version 6.0 (clang-600.0.56) (based on llvm 3.5svn), 64-bit

the behaviour describe consistent tables being unlogged.

an unlogged table halfway between normal table , temp table. it's normal table in that:

  • it's usable multiple sessions
  • it isn't cleared when session exits
  • it's stored in main tablespace, not temp tablespace

but it's temp table in that:

  • it isn't crash safe. contents of unlogged tables preserved when postgresql shuts down , restarts, if it's shut down cleanly. on unclean shutdown, unlogged tables may truncated, still exist contain 0 rows.

  • writing doesn't produce write-ahead log records in pg_xlog

  • it can't replicated other nodes on streaming or log-based replication

  • writing unlogged table causes half disk i/o regular table

see the manual.

at guess, tables defined unlogged , aren't shutting postgresql down cleanly when mac shuts down. it's truncating unlogged tables, since can't sure they're in consistent state.

shut postgresql down cleanly (e.g. pg_ctl -m fast -w stop, or launchd configuration makes sue that). or don't use unlogged tables. or willing re-load data when restart.

since wondered unlogged tables for:

  • they're great data loading , transform, want load bunch of data, extract , transform loading other tables.

  • reporting tables

  • work queues , task queues whole system can restarted, don't need make lists of in-progress tasks etc crash-safe


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -