[GENERAL] Autodocumenting plpgsql function
Hey all, somebody knows of a way to autodocument plpgsql function, in a docxygen style (adding tags in comments for instance, or creating doc templates to fill). It would really help to write the doc and maintain it. Thanks, Rémi-C
Re: [GENERAL] Wrap around id failure and after effects
On 26/11/13 07:15, Arun P.L wrote: Hi all, We had a wraparound failure in the db and most of the tables and data were missing. So we have done a full vacuum in db and after that the tables reappeared but now the problem is, all the tables have duplicate when listing tables with /dt. And also after the vacuum we recievied the following warning. *INFO: free space map: 48 relations, 29977 pages stored; 134880 total pages needed* *DETAIL: Allocated FSM size: 1000 relations + 2 pages = 215 kB shared memory.* *WARNING: some databases have not been vacuumed in over 2 billion transactions* *DETAIL: You may have already suffered transaction-wraparound data loss.* * * Is this an error happened between the vacuum? If so what can be done next to prevent data loss? The vacuum was not done as superuser, we are doing a second time vacuum as superuser now. And what are the further steps to be followed now like reindexing,etc? 1. Did you take a full file-level backup of things before vacuuming? 2. What version? 3. How far back in the logs do the warnings go (you should have been receiving warnings for a long time)? 4. How/why had you disabled/altered the autovacuum daemon? This shouldn't really be possible without disabling autovaccuum or configuring it strangely. http://www.postgresql.org/docs/current/static/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND -- Richard Huxton Archonet Ltd -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] Autodocumenting plpgsql function
Rémi Cura wrote: > somebody knows of a way to autodocument plpgsql function, in a docxygen style > (adding tags in comments for instance, or creating doc templates to fill). > > It would really help to write the doc and maintain it. I am not sure what you need, but I see two ways to document a function: 1) With /** .. */ comments in the beginning. Maybe doxygen can be used to parse a database dump. 2) With COMMENT ON FUNCTION ... IS '...'; That also keeps the documentation close to where the code is, and it shows up in database dumps. Yours, Laurenz Albe -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
[GENERAL] a PostgreSQL slogan misused
I suppose the PostgreSQL Publice Relations people might be interested in this misuse of PostgreSQL phrase: http://www.computerweekly.com/blogs/open-source-insider/2013/11/why-elephants-never-forget-big-data.html Karsten -- GPG key ID E4071346 @ gpg-keyserver.de E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346 -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] Autodocumenting plpgsql function
Hey thanks for the answer. I'm thinking way more than that. Typically in you comments you include special tags, like @input, then doxygen will parse it and generate an html documentation. Cheers, Rémi-C 2013/11/26 Albe Laurenz > Rémi Cura wrote: > > somebody knows of a way to autodocument plpgsql function, in a docxygen > style > > (adding tags in comments for instance, or creating doc templates to > fill). > > > > It would really help to write the doc and maintain it. > > I am not sure what you need, but I see two ways to > document a function: > > 1) With /** .. */ comments in the beginning. >Maybe doxygen can be used to parse a database dump. > > 2) With COMMENT ON FUNCTION ... IS '...'; >That also keeps the documentation close to where >the code is, and it shows up in database dumps. > > Yours, > Laurenz Albe >
[GENERAL] xmlagg doesn't honor LIMIT?
Is anyone able to reproduce? When I run the query below all 5 rows are returned instead of 2. Or is this the default behaviour.. "PostgreSQL 9.2.4 on i686-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52), 32-bit" DROP TABLE IF EXISTS __pg_test_table CASCADE; CREATE TABLE __pg_test_table( id serial, some_value int, __rel int ); INSERT INTO __pg_test_table(some_value,__rel)VALUES(1,5); INSERT INTO __pg_test_table(some_value,__rel)VALUES(2,5); INSERT INTO __pg_test_table(some_value,__rel)VALUES(3,5); INSERT INTO __pg_test_table(some_value,__rel)VALUES(4,5); INSERT INTO __pg_test_table(some_value,__rel)VALUES(5,5); INSERT INTO __pg_test_table(some_value,__rel)VALUES(6,6); INSERT INTO __pg_test_table(some_value,__rel)VALUES(7,6); INSERT INTO __pg_test_table(some_value,__rel)VALUES(8,6); INSERT INTO __pg_test_table(some_value,__rel)VALUES(9,6); INSERT INTO __pg_test_table(some_value,__rel)VALUES(10,6); SELECT xmlagg( xmlconcat( xmlelement(name test_element, xmlattributes( 0 AS m ), xmlforest( dh.id AS i ,dh.some_value AS sv )--xmlforest )--test_element )--xmlconcat ORDER BY id DESC )--xmlagg FROM __pg_test_table AS dh WHERE dh.__rel=5 LIMIT 2 --OFFSET 10;
Re: [GENERAL] Autodocumenting plpgsql function
Rémi Cura wrote: >>> somebody knows of a way to autodocument plpgsql function, in a docxygen >>> style >>> (adding tags in comments for instance, or creating doc templates to fill). >>> >>> It would really help to write the doc and maintain it. > Typically in you comments you include special tags, like @input, then doxygen > will parse it and > generate an html documentation. I can't think of a way to automatically generate such documentation from within PostgreSQL, except maybe that you write a stored procedure that analyzes all functions and adds a comment with the result. Yours, Laurenz Albe -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] xmlagg doesn't honor LIMIT?
Peter Kroon wrote: > Is anyone able to reproduce? > When I run the query below all 5 rows are returned instead of 2. > Or is this the default behaviour.. > SELECT > xmlagg( [...] > )--xmlagg > FROM __pg_test_table AS dh > WHERE dh.__rel=5 LIMIT 2 --OFFSET 10; According to the documentation, that query should return exactly one row since xmlagg is an aggregate. So the LIMIT 2 won't do anything to the result. You can wrap your query in a SELECT count(*) FROM (SELECT ...) AS dummy; to see how many rows you got. Yours, Laurenz Albe -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] Inserting rows containing composite foreign keys
> To: pgsql-general@postgresql.org > Date: Tue, 26 Nov 2013 08:15:45 +0100 > > Nelson Green, 25.11.2013 23:01: > > Hello, > > When inserting a record into the jobs table that references projects by > > name, do I have to query the projects table twice, > > once to get the funding source number, and once to get the project sequence > > number, even though both results will > > return the same row? Or put another way, is there a way to insert a row > > into the jobs table without having to > > perform two sub-queries for the same row, thus avoiding this: > > > > INSERT INTO jobs > >VALUES ((SELECT fundsrc_number FROM projects > > WHERE project_name = 'proj1-1'), > >(SELECT project_seq FROM projects > > WHERE project_name = 'proj1-1'), > > 1, 'job1-1.1', 'first project 1-1 job'); > > > > Use an INSERT based on a SELECT, not based on VALUES: > > INSERT INTO projects (fundsrc_number, project_seq, project_name, > project_desc) > SELECT fundsrc_number, 1, 'proj1-1', 'first source01 project' > FROM fundsrc > WHERE fundsrc_name IN ('source01', 'source02'); > > INSERT INTO jobs (fundsrc_number, project_seq, job_seq, job_name, job_desc) > SELECT fundsrc_number, project_seq, 1, 'job1-1.1', 'first project 1-1 job' > FROM projects > WHERE project_name = 'proj1-1'; This works perfectly. I could swear I tried something similar and was unsuccessful, but I can't find any indication that I did in my history or my notes. Regardless, if you heard a loud smacking noise a few seconds ago that was my palm hitting my forehead. I appreciate you taking the time to state the obvious to the obviously blind. > Note that it's good coding style to always specify the columns in an INSERT > statement. > It makes your statements more robust against changes. I do. I just saved a few keystrokes and a bit of reading for this simple example. I know to specify and qualify at all times. Thanks for both tips!
Re: [GENERAL] xmlagg doesn't honor LIMIT?
This is how I solved it: SELECT xmlagg( xmlconcat( xmlelement(name test_element, xmlforest( ff.d AS a )--xmlforest ) )--xmlconcat )--xmlagg FROM ( SELECT --xmlagg( xmlconcat( xmlelement(name test_element, xmlattributes( 0 AS m ), xmlforest( dh.id AS i ,dh.some_value AS sv )--xmlforest )--test_element ) AS d --) FROM __pg_test_table AS dh WHERE dh.__rel=5 LIMIT 2 --OFFSET 10; ) AS ff; 2013/11/26 Albe Laurenz > Peter Kroon wrote: > > Is anyone able to reproduce? > > When I run the query below all 5 rows are returned instead of 2. > > Or is this the default behaviour.. > > > SELECT > > xmlagg( > [...] > > )--xmlagg > > FROM __pg_test_table AS dh > > WHERE dh.__rel=5 LIMIT 2 --OFFSET 10; > > According to the documentation, that query should return > exactly one row since xmlagg is an aggregate. > > So the LIMIT 2 won't do anything to the result. > > You can wrap your query in a > SELECT count(*) FROM (SELECT ...) AS dummy; > to see how many rows you got. > > Yours, > Laurenz Albe >
[GENERAL] restore crashes PG on Linux, works on Windows
I'm working with a vendor who is in the process of converting their system from "something else" to Postgres. Yay! My vendor took a dump of our "something else" database (which runs on Windows), did their conversion to Postgres, and then sent me back a postgres dump (custom format) of the database for me to load onto my servers for testing. I was interested to find that while I can load the dump onto a PG 9.3 server running on Windows, I'm unable to load it on either 9.2 or 9.3 running on Linux. At some point during the restore process (and it's not a consistent point), PG on Linux crashes. I suspect that the problem is related to the encoding specified in the database dump: CREATE DATABASE "TestDatabase" WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'English_United States.1252' LC_CTYPE = 'English_United States.1252'; So my questions for the brain trust are: 1) Would you expect this to work? 2) If I had to load this database on Linux, what would be the best way to go about it? (see if I can find that charset/encoding for Linux? Ask the vendor for a plain-text dump? )
Re: [GENERAL] restore crashes PG on Linux, works on Windows
On Tue, Nov 26, 2013 at 09:25:17AM -0500, Chris Curvey wrote: > > CREATE DATABASE "TestDatabase" WITH TEMPLATE = template0 ENCODING = 'UTF8' > LC_COLLATE = 'English_United States.1252' LC_CTYPE = 'English_United > States.1252'; Guess guessing, but I bet the collation is what hurts, just because that collation causes problems generally. Maybe you could get them to ditch that in favour of something else? LC_COLLATE = en_US.UTF-8 would perhaps be better. (The background for my guess: on your Linux box UTF-8 is likely the normal local encoding, but on Windows that isn't true, and 1252 is _almost_ but not quite Unicode. This bites people generally in internationalization.) A -- Andrew Sullivan a...@crankycanuck.ca -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] restore crashes PG on Linux, works on Windows
Chris Curvey wrote: > My vendor took a dump of our "something else" database (which runs on > Windows), did their conversion > to Postgres, and then sent me back a postgres dump (custom format) of the > database for me to load onto > my servers for testing. > > > I was interested to find that while I can load the dump onto a PG 9.3 server > running on Windows, I'm > unable to load it on either 9.2 or 9.3 running on Linux. At some point > during the restore process > (and it's not a consistent point), PG on Linux crashes. You mean, the database server dies? Or that there is an error message? If it is the latter, can we see the error message? > I suspect that the problem is related to the encoding specified in the > database dump: > > CREATE DATABASE "TestDatabase" WITH TEMPLATE = template0 ENCODING = 'UTF8' > LC_COLLATE = > 'English_United States.1252' LC_CTYPE = 'English_United States.1252'; Yes, that should throw an error on a Linux system. But you should get that error consistently, different from what you write above. > So my questions for the brain trust are: > > > 1) Would you expect this to work? No, as stated above. > 2) If I had to load this database on Linux, what would be the best way to go > about it? (see if I can > find that charset/encoding for Linux? Ask the vendor for a plain-text dump? ) You can create the database beforehand and ignore the one error from pg_restore. You can convert the custom format dump into an SQL file with pg_restore -f dumpfile.sql dumpfile.dmp Yours, Laurenz Albe -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] restore crashes PG on Linux, works on Windows
Andrew Sullivan wrote: > Guess guessing, but I bet the collation is what hurts, [...] > (The background for my guess: on your Linux box UTF-8 is likely the > normal local encoding, but on Windows that isn't true, and 1252 is > _almost_ but not quite Unicode. This bites people generally in > internationalization.) I beg your pardon, but Windows-1252 has nothing to do with Unicode or UTF-8. The only connection is that Windows-1252 and UTF-8 both are ASCII supersets. Yours, Laurenz Albe -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] restore crashes PG on Linux, works on Windows
On Tue, Nov 26, 2013 at 02:48:34PM +, Albe Laurenz wrote: > I beg your pardon, but Windows-1252 has nothing to do with Unicode Sorry, you're quite right, I'm having a brain fade (I meant ISO 8859-1, of course). The point I wanted to make, however, is that the collation often causes trouble with UTF-8 encoding. I liked your conversion suggestion, however, in your other mail. A -- Andrew Sullivan a...@crankycanuck.ca -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
[GENERAL] tracking scripts...
I have a fairly large table (4.3 billion rows) that I am running an update script on (a bit over 127 thousand individual update queries). I am using the gui. It has been running for about 24 hours now. Is there any good way to gauge progress (as in, how many of the individual update queries have finished)?
Re: [GENERAL] tracking scripts...
Now it's too late, but maybe you could allow to not use a single transaction ( but instead 127k transactions).4 Then at the end of every transaction you could print something in gui (print for pgscript, raise for plpgsql) or execute a command to write in a file (copy for instance). It would also be in the log, but not so clear. Cheers, Rémi-C 2013/11/26 Joey Quinn > I have a fairly large table (4.3 billion rows) that I am running an update > script on (a bit over 127 thousand individual update queries). I am using > the gui. It has been running for about 24 hours now. Is there any good way > to gauge progress (as in, how many of the individual update queries have > finished)? > > >
Re: [GENERAL] tracking scripts...
Connect to the DB and run "select * from pg_stat_activity" to see what specific query your other connection is running. Then find that in your file to see how far it has progressed. I hope you profiled your queries to make sure they run fast before you started. :) On Tue, Nov 26, 2013 at 10:28 AM, Joey Quinn wrote: > I have a fairly large table (4.3 billion rows) that I am running an update > script on (a bit over 127 thousand individual update queries). I am using > the gui. It has been running for about 24 hours now. Is there any good way > to gauge progress (as in, how many of the individual update queries have > finished)? > > >
Re: [GENERAL] tracking scripts...
The queries themselves are written like so: update ipv4_table set country='xx' where ipv4 between 'xxx.xxx.xxx.xxx' and 'xxx.xxx.xxx.xxx'; There are 127k lines like that (each with a different range and the appropriate country code). Each is terminated with a semi-colon. Does that make them individual transactions in postgres or not? (postgres newbie here). Is there something else I need to do for them to be treated like separate transactions? On Tue, Nov 26, 2013 at 11:16 AM, Rémi Cura wrote: > Now it's too late, > but maybe you could allow to not use a single transaction ( but instead > 127k transactions).4 > > Then at the end of every transaction you could print something in gui > (print for pgscript, raise for plpgsql) or execute a command to write in a > file (copy for instance). > It would also be in the log, but not so clear. > > Cheers, > > Rémi-C > > > 2013/11/26 Joey Quinn > >> I have a fairly large table (4.3 billion rows) that I am running an >> update script on (a bit over 127 thousand individual update queries). I am >> using the gui. It has been running for about 24 hours now. Is there any >> good way to gauge progress (as in, how many of the individual update >> queries have finished)? >> >> >> >
Re: [GENERAL] tracking scripts...
On Tue, Nov 26, 2013 at 12:11 PM, Joey Quinn wrote: > update ipv4_table set country='xx' where ipv4 between 'xxx.xxx.xxx.xxx' > and 'xxx.xxx.xxx.xxx'; > > There are 127k lines like that (each with a different range and the > appropriate country code). Each is terminated with a semi-colon. Does that > make them individual transactions in postgres or not? (postgres newbie > here). Is there something else I need to do for them to be treated like > separate transactions? > If you did not wrap the whole thing with begin/commit then each is its own transaction. I certainly hope you have an appopriate index on that ipv4 column and it is appropriately typed.
Re: [GENERAL] tracking scripts...
When I ran that command (select * from pg_stat_activity"), it returned the first six lines of the scripts. I'm fairly sure it has gotten a bit beyond that (been running over 24 hours now, and the size has increased about 300 GB). Am I missing something for it to tell me what the last line processed was? I didn't do any profiling (postgres newbie here). All of the updates are fairly straightforward and only hit a single table. They are updating a single column based upon a "where between" clause which hits an index. I did run a single one initially, and then a group of about 10k to make sure they were behaving properly before launching the rest of the pile... This is my first postgres project. It's a table of the complete IPV4 address space. Trying out postgres because the MySQL (actually MariaDB) attempt was not scaling well. On Tue, Nov 26, 2013 at 11:20 AM, Vick Khera wrote: > Connect to the DB and run "select * from pg_stat_activity" to see what > specific query your other connection is running. Then find that in your > file to see how far it has progressed. > > I hope you profiled your queries to make sure they run fast before you > started. :) > > > On Tue, Nov 26, 2013 at 10:28 AM, Joey Quinn wrote: > >> I have a fairly large table (4.3 billion rows) that I am running an >> update script on (a bit over 127 thousand individual update queries). I am >> using the gui. It has been running for about 24 hours now. Is there any >> good way to gauge progress (as in, how many of the individual update >> queries have finished)? >> >> >> >
Re: [GENERAL] tracking scripts...
The ipv4 column is of type inet. It is the primary key (btree access) and access times for queries on individual ip addresses have been around 10-15 ms. On Tue, Nov 26, 2013 at 12:13 PM, Vick Khera wrote: > > On Tue, Nov 26, 2013 at 12:11 PM, Joey Quinn wrote: > >> update ipv4_table set country='xx' where ipv4 between 'xxx.xxx.xxx.xxx' >> and 'xxx.xxx.xxx.xxx'; >> >> There are 127k lines like that (each with a different range and the >> appropriate country code). Each is terminated with a semi-colon. Does that >> make them individual transactions in postgres or not? (postgres newbie >> here). Is there something else I need to do for them to be treated like >> separate transactions? >> > > If you did not wrap the whole thing with begin/commit then each is its own > transaction. I certainly hope you have an appopriate index on that ipv4 > column and it is appropriately typed. >
[GENERAL] AccessShareLock and Resource Contention
I have a 9.2 server that occasionally becomes CPU bound. Disk wait is nominal and there's no memory pressure. The workload is almost all reads and the cache hit rate is high. For some one minute periods, my monitoring shows around 1.5k to 2k access share locks out of a total of 7.5 to 8k transactions. What's the best strategy for finding out if that is creating a bottleneck?
Re: [GENERAL] AccessShareLock and Resource Contention
Hit send on that one too soon. I see 6.5k access share locks out of 7.5k transactions. On Tue, Nov 26, 2013 at 12:41 PM, wrote: > I have a 9.2 server that occasionally becomes CPU bound. Disk wait is > nominal and there's no memory pressure. The workload is almost all reads > and the cache hit rate is high. > > For some one minute periods, my monitoring shows around 1.5k to 2k access > share locks out of a total of 7.5 to 8k transactions. What's the best > strategy for finding out if that is creating a bottleneck? >
Re: [GENERAL] Re: corruption issue after server crash - ERROR: unexpected chunk number 0
The restore of a post-crash production backup worked as hoped and the 2nd replication slave is back into its happy hot standby state. So if this problem replicated to our standby servers does that indicate that the potential problematic fsync occurred during a pg_xlog write? Would breaking replication at the time of the crash have prevented this from cascading or was it already too late at that point? Thanks again for the input, its been very helpful! Mike On Mon, Nov 25, 2013 at 12:20 PM, Mike Broers wrote: > Thanks Shaun, > > Im planning to schedule a time to do the vacuum freeze suggested > previously. So far the extent of the problem seems limited to the one > session table and the one session row that was being used by a heavy bot > scan at the time of the crash. Currently Im testing a recovery of a > production backup from today to rebase one of the replication targets that > I was using to test fixes last week. Hopefully that validates the current > backups and I can proceed inquiring with our managed services provider > about the false notification of the disk write and ways to prevent that > going forward. > > I'll update the list if I uncover anything interesting in the process > and/or need more advice, thanks again for your input - its much appreciated > as always. Nothing like a little crash corruption to get the blood flowing! > > Mike > > > On Mon, Nov 25, 2013 at 10:29 AM, Shaun Thomas > wrote: > >> > Update - I have two hot replication slaves of this db, both have the >> problem. >> > I took one out of recovery and ran REINDEX table session_session and it >> > fixed the errors about this row. Now Im going to run vacuum and see if >> > there are other tables that complain, but Im guessing if so I will need >> to see >> > if there is a way to force vacuum to continue on error, worst case I >> might >> > have to script a table by table vacuum script I guess.. If anyone has >> a better >> > suggestion for determining the extent of the damage Id appreciate it. >> >> Oh man. I'm sorry, Mike. >> >> One of the cardinal rules I have is to disconnect any replication >> following a database crash. It's just too easy for damaged replicated rows >> to be propagated unless you're on 9.3 and have checksums enabled. If you >> want to perform a table-by-table check, don't vacuum the database, but the >> individual tables. I'd go with a DO loop and have it raise notices into the >> log so you can investigate further: >> >> COPY ( >> SELECT 'VACUUM ' || oid::regclass::text || ';' >> FROM pg_class >> WHERE relkind = 'r' >> ) to '/tmp/vac_all.sql'; >> >> Run the /tmp/vac_all.sql through psql and pipe the contents into a log >> file. Any table that doesn't vacuum successfully will need to be repaired >> manually. One way you can do this if there are dupes, is by checking the >> ctid value after disabling index scans: >> >> SET enable_indexscan TO False; >> >> SELECT ctid, * FROM [broken_table] WHERE ...; >> >> Just construct the WHERE clause based on the error output, and you should >> get all rows if there are dupes. You'll need to figure out which row to >> keep, then delete the bad row based on the ctid. Do this as many times as >> it takes, then reindex to make sure the proper row versions are indexed. >> >> It's also a good idea to dump any table that came back with an error, >> just in case. >> >> After you've done all of that, you should re-base your replicas once >> you've determined your production system is usable. In the meantime, I >> highly recommend you set up a VIP you can assign to one of your replicas if >> your production system dies again, and remove any autostart code. If your >> production system crashes, switch the VIP immediately to a replica, and >> invalidate your old production system. Data corruption is insidious when >> streaming replication is involved. >> >> Look into tools like repmgr to handle managing your replicas as a cluster >> to make forced invalidation and re-basing easier. >> >> Good luck! >> >> -- >> Shaun Thomas >> OptionsHouse | 141 W. Jackson Blvd | Suite 500 | Chicago IL, 60604 >> 312-676-8870 >> stho...@optionshouse.com >> >> __ >> >> See http://www.peak6.com/email_disclaimer/ for terms and conditions >> related to this email >> > >
[GENERAL] Any advantage of using SSL with a certificate of authority?
Looking to implement SSL. Every tutorial/sample I have found uses self signed certificates. Would there be any advantage of using a certificate from a CA such as digicertor rapidssl? Att. == Jesus Rafael Sanchez Medrano "Life is a dream, of which all must wake up"
Re: [GENERAL] tracking scripts...
On 11/26/2013 9:24 AM, Joey Quinn wrote: When I ran that command (select * from pg_stat_activity"), it returned the first six lines of the scripts. I'm fairly sure it has gotten a bit beyond that (been running over 24 hours now, and the size has increased about 300 GB). Am I missing something for it to tell me what the last line processed was? that means your GUI lobbed the entire file at postgres in a single PQexec call, so its all being executed as a single statement. psql -f "filename.sql" dbname would have processed the queries one at a time. -- john r pierce 37N 122W somewhere on the middle of the left coast -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] Any advantage of using SSL with a certificate of authority?
On Tue, Nov 26, 2013 at 02:24:01PM -0400, Jesus Rafael Sanchez Medrano wrote: > Looking to implement SSL. Every tutorial/sample I have found uses self signed > certificates. Would there be any advantage of using a certificate from a CA > such as digicertor rapidssl? Well, by using a CA you are giving the CA rights to the key, while you fully control a self signed key. Since you probably don't expect unknown individuals to be connecting to your database, and self signed key is recommended. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] Any advantage of using SSL with a certificate of authority?
On 11/26/2013 10:24 AM, Jesus Rafael Sanchez Medrano wrote: Looking to implement SSL. Every tutorial/sample I have found uses self signed certificates. Would there be any advantage of using a certificate from a CA such as digicertor rapidssl? depends entirely on your use case.generally, since you control both ends of a postgresql connection, there's no advantage to using signed certificates, but if you have your own CA already, by all means go ahead and use it. -- john r pierce 37N 122W somewhere on the middle of the left coast
Re: [GENERAL] tracking scripts...
On Tue, Nov 26, 2013 at 12:24 PM, Joey Quinn wrote: > When I ran that command (select * from pg_stat_activity"), it returned the > first six lines of the scripts. I'm fairly sure it has gotten a bit beyond > that (been running over 24 hours now, and the size has increased about 300 > GB). Am I missing something for it to tell me what the last line processed > was? > I agree with what John R Pierce says about your GUI lumping all of it into one statement. What you can do is get indirect evidence by looking to see which rows are set. I'm assuming that your IP ranges are non-overlapping, so just do a binary search until you narrow it down to see how far along you are.
Re: [GENERAL] Any advantage of using SSL with a certificate of authority?
On Tue, Nov 26, 2013 at 10:33:47AM -0800, John R Pierce wrote: > On 11/26/2013 10:24 AM, Jesus Rafael Sanchez Medrano wrote: > > Looking to implement SSL. Every tutorial/sample I have found uses self > signed certificates. Would there be any advantage of using a certificate > from a CA such as digicertor rapidssl? > > > > depends entirely on your use case. generally, since you control both ends > of > a postgresql connection, there's no advantage to using signed certificates, > but > if you have your own CA already, by all means go ahead and use it. Yes, definately use your private CA so you can verify the chain. It is public CAs that are not useful in this case. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] AccessShareLock and Resource Contention
> On Tue, Nov 26, 2013 at 12:41 PM, wrote: > > > I have a 9.2 server that occasionally becomes CPU bound. Disk wait is > > nominal and there's no memory pressure. The workload is almost all reads > > and the cache hit rate is high. Maybe you'd benefit from something like the patch proposed here: http://www.postgresql.org/message-id/20131115194725.gg5...@awork2.anarazel.de perhaps you can help test the patchset. -- Álvaro Herrerahttp://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] Any advantage of using SSL with a certificate of authority?
On Tue, Nov 26, 2013 at 1:31 PM, Bruce Momjian wrote: > Well, by using a CA you are giving the CA rights to the key, while you > fully control a self signed key. Since you probably don't expect > unknown individuals to be connecting to your database, and self signed > key is recommended. > You never give the key to them, just a signing request based on the key. You lose no control over anything. They will in general insist your key be at least 2048 bits. The only advantage of having a CA key is if the client does authentication of the server, and you have no prior arrangement with the client to accept a certificate from your signing authority. Using self-signed certs you can give them longevity of 10+ years, so never have to worry about them again :)
Re: [GENERAL] Any advantage of using SSL with a certificate of authority?
On Tue, Nov 26, 2013 at 02:18:58PM -0500, Vick Khera wrote: > Using self-signed certs you can give them longevity of 10+ years, so never > have to worry about them again :) Unless of course you turn out to have a weak algorithm and, say, No Such Agency decides to take up residence on your network. (It's not clear that CAs are any protection against that either, though, of course.) In general, 10+ years is probably too short a time to be using a cert unless you are completely certain to whom it could be exposed. (Some would argue that if you had that certainty, you might not need TLS/SSL anyway. I guess I'd respond that you could use TLS anyway because it would help in case of a network compromise.) Best, A -- Andrew Sullivan a...@crankycanuck.ca -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
[GENERAL] having difficulty with explain analyze output
I'm not really looking for information on how to speed this query up. I'm just trying to interpret the output enough to tell me which step is slow: Seq Scan on mags (cost=0.00..187700750.56 rows=47476 width=4) (actual time=3004851.889..3004851.889 rows=0 loops=1) Filter: ((signum IS NOT NULL) AND (NOT (SubPlan 1))) SubPlan 1 -> Materialize (cost=0.00..3713.93 rows=95862 width=4) (actual time=0.011..16.145 rows=48139 loops=94951) -> Seq Scan on sigs (cost=0.00..2906.62 rows=95862 width=4) (actual time=0.010..674.201 rows=95862 loops=1) Total runtime: 3004852.005 ms It looks like the inner seq scan takes 674ms, then the materialize takes an additional 16ms? Or is that 16ms * 94951? Or 674 * 94951? And the outer seq scan takes 3004851-3004851 = 0ms? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] tracking scripts...
Sounds like I will have to get comfortable with the command line version of things... sigh... hate that. Would that command be from within the psql SQL Shell that came as part of the install? (I'm living in Windows land). (and thank-you for the command) On Tue, Nov 26, 2013 at 1:24 PM, John R Pierce wrote: > On 11/26/2013 9:24 AM, Joey Quinn wrote: > >> When I ran that command (select * from pg_stat_activity"), it returned >> the first six lines of the scripts. I'm fairly sure it has gotten a bit >> beyond that (been running over 24 hours now, and the size has increased >> about 300 GB). Am I missing something for it to tell me what the last line >> processed was? >> > > that means your GUI lobbed the entire file at postgres in a single PQexec > call, so its all being executed as a single statement. > > psql -f "filename.sql" dbname would have processed the queries one at a > time. > > > -- > john r pierce 37N 122W > somewhere on the middle of the left coast > > > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general >
Re: [GENERAL] tracking scripts...
The ranges are indeed overlapping, though the update statements were generated alphabetically rather than in IP order... If the command line will let me query the table directly without being blocked by the ongoing updates, then I could get a rough order of magnitude of progress by doing a null count on the county field... hate to throw queries at it while it's busy updating though... On Tue, Nov 26, 2013 at 1:43 PM, Vick Khera wrote: > > On Tue, Nov 26, 2013 at 12:24 PM, Joey Quinn wrote: > >> When I ran that command (select * from pg_stat_activity"), it returned >> the first six lines of the scripts. I'm fairly sure it has gotten a bit >> beyond that (been running over 24 hours now, and the size has increased >> about 300 GB). Am I missing something for it to tell me what the last line >> processed was? >> > > I agree with what John R Pierce says about your GUI lumping all of it into > one statement. What you can do is get indirect evidence by looking to see > which rows are set. I'm assuming that your IP ranges are non-overlapping, > so just do a binary search until you narrow it down to see how far along > you are. > >
Re: [GENERAL] having difficulty with explain analyze output
On Tue, Nov 26, 2013 at 02:43:42PM -0500, David Rysdam wrote: > I'm not really looking for information on how to speed this query > up. I'm just trying to interpret the output enough to tell me which step > is slow: > >Seq Scan on mags (cost=0.00..187700750.56 rows=47476 width=4) (actual > time=3004851.889..3004851.889 rows=0 loops=1) > Filter: ((signum IS NOT NULL) AND (NOT (SubPlan 1))) > SubPlan 1 > -> Materialize (cost=0.00..3713.93 rows=95862 width=4) > (actual time=0.011..16.145 rows=48139 loops=94951) > -> Seq Scan on sigs (cost=0.00..2906.62 rows=95862 > width=4) (actual time=0.010..674.201 rows=95862 loops=1) >Total runtime: 3004852.005 ms > > It looks like the inner seq scan takes 674ms, then the materialize takes > an additional 16ms? Or is that 16ms * 94951? Or 674 * 94951? The Seq Scan took 674ms and was run once (loops=1) The Materialise was run 94951 times and took, on average, 0.011ms to return the first row and 16ms to complete. 16.145 * 94951 = 1532983.895 > And the outer seq scan takes 3004851-3004851 = 0ms? The outer plan took 3004851ms to return its first row, and last row also as apparently it matched now rows at all. And if this is the complete plan, it took 1,500 seconds for itself. Hope this helps, -- Martijn van Oosterhout http://svana.org/kleptog/ > He who writes carelessly confesses thereby at the very outset that he does > not attach much importance to his own thoughts. -- Arthur Schopenhauer signature.asc Description: Digital signature
Re: [GENERAL] tracking scripts...
On Tue, Nov 26, 2013 at 2:48 PM, Joey Quinn wrote: > The ranges are indeed overlapping, though the update statements were > generated alphabetically rather than in IP order... If the command line > will let me query the table directly without being blocked by the ongoing > updates, then I could get a rough order of magnitude of progress by doing a > null count on the county field... hate to throw queries at it while it's > busy updating though... > Try a SELECT ... LIMIT 1; it will find the first row that matches and exit. So you can see if any particular country code has been set. Again, binary search on the codes.
Re: [GENERAL] AccessShareLock and Resource Contention
On Tue, Nov 26, 2013 at 9:50 AM, wrote: > Hit send on that one too soon. I see 6.5k access share locks out of 7.5k > transactions. > > > On Tue, Nov 26, 2013 at 12:41 PM, wrote: > >> I have a 9.2 server that occasionally becomes CPU bound. Disk wait is >> nominal and there's no memory pressure. The workload is almost all reads >> and the cache hit rate is high. >> > Do you see higher user time, or high system time? What is the maximum number of concurrent connections you have? > >> For some one minute periods, my monitoring shows around 1.5k to 2k access >> share locks out of a total of 7.5 to 8k transactions. What's the best >> strategy for finding out if that is creating a bottleneck? >> > How are you monitoring? What do those numbers mean, that you took that many access shared locks, or you held that many simultaneously at the peak, or that you blocked on them that many times? Cheers, Jeff
Re: [GENERAL] tracking scripts...
On 11/26/2013 11:45 AM, Joey Quinn wrote: Would that command be from within the psql SQL Shell that came as part of the install? (I'm living in Windows land). if you're already in psql, logged onto your database, it would be \i filename.sql psql -f filename.sql dbname...would be at the system shell prompt, but that assumes the postgresql binary directory is in your path, which it may not be on default Windows installs. -- john r pierce 37N 122W somewhere on the middle of the left coast -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] Any advantage of using SSL with a certificate of authority?
There is a downside to self-signed certificates. 1. A self-signed certificate can be issued by anybody, there is no way of authenticating the issuer. 2. Distributing self-signed certificates becomes a pain - if signed by a CA, its easy to lodge your public key where everybody can find it, and knows where to look for it. 3. Maintenance becomes a problem I only use self signed certs for testing. Robin St.Clair On 26/11/2013 19:34, Andrew Sullivan wrote: On Tue, Nov 26, 2013 at 02:18:58PM -0500, Vick Khera wrote: Using self-signed certs you can give them longevity of 10+ years, so never have to worry about them again :) Unless of course you turn out to have a weak algorithm and, say, No Such Agency decides to take up residence on your network. (It's not clear that CAs are any protection against that either, though, of course.) In general, 10+ years is probably too short a time to be using a cert unless you are completely certain to whom it could be exposed. (Some would argue that if you had that certainty, you might not need TLS/SSL anyway. I guess I'd respond that you could use TLS anyway because it would help in case of a network compromise.) Best, A
Re: [GENERAL] tracking scripts...
nope, that appears to be being blocked by the updates... tried "select * from ipv4_table where country='gb' limit 1;" it just sat there... On Tue, Nov 26, 2013 at 3:00 PM, Vick Khera wrote: > > On Tue, Nov 26, 2013 at 2:48 PM, Joey Quinn wrote: > >> The ranges are indeed overlapping, though the update statements were >> generated alphabetically rather than in IP order... If the command line >> will let me query the table directly without being blocked by the ongoing >> updates, then I could get a rough order of magnitude of progress by doing a >> null count on the county field... hate to throw queries at it while it's >> busy updating though... >> > > Try a SELECT ... LIMIT 1; it will find the first row that matches and > exit. So you can see if any particular country code has been set. Again, > binary search on the codes. >
Re: [GENERAL] tracking scripts...
yeah, unlikely that it is already in the path (I certainly didn't add it yet). Thanks for the command (new version). On Tue, Nov 26, 2013 at 3:13 PM, John R Pierce wrote: > On 11/26/2013 11:45 AM, Joey Quinn wrote: > >> Would that command be from within the psql SQL Shell that came as part of >> the install? (I'm living in Windows land). >> > > if you're already in psql, logged onto your database, it would be \i > filename.sql > > psql -f filename.sql dbname...would be at the system shell prompt, > but that assumes the postgresql binary directory is in your path, which it > may not be on default Windows installs. > > > > > -- > john r pierce 37N 122W > somewhere on the middle of the left coast > > > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general >
Re: [GENERAL] Re: corruption issue after server crash - ERROR: unexpected chunk number 0
> So if this problem replicated to our standby servers does that indicate > that the potential problematic fsync occurred during a pg_xlog write? Pretty much. You have a couple issues here, and no easy way to approach them. Primarily, you got data corruption during a sync operation. This means either the OS or the hardware somewhere along the line lied about the write, or the write was corrupted and the filesystem log replayed incorrectly upon reboot. Once that happens, you can't trust *any* data in your database. Pre-checksum PostgreSQL has no way to verify integrity of existing data, and system crashes can corrupt quite a bit of data that was only tangentially involved. What likely happens in these scenarios, is that the database startup succeeds, and then it read some rows in from a corrupted table. By corrupted, I mean even a single data page with a mangled pointer. That mangled pointer gave the database incorrect information about the state of that data page's contents, and the database continued on that information. That means subsequent transaction logs from that point are *also* corrupt, and hence any streaming or warm standby replicas are subsequently damaged as well. But they'll be damaged differently, because they likely didn't have the initial corruption, just the byte changes dictated by the WAL stream. Unless you know where the initial corruption came from, the system that caused it should be quarantined for verification. RAM, disk, CPU, everything should pass integrity checks before putting it back into production. > Would breaking replication at the time of the crash have prevented > this from cascading or was it already too late at that point? Most likely. If, at the time of the crash, you switched to one of your replicas and made it the new master, it would give you the opportunity to check out the crashed system before it spread the love. Even if you don't have a true STONITH model, starting up a potentially data-compromised node in an active cluster is a gamble. I did something similar once. One of our DRBD nodes crashed and came back up and re-attached to the DRBD pair after a quick data discard and replay. I continued with some scheduled system maintenance, and performed a node failover with no incident. It wasn't until 20 minutes later that the corrupt disk pages started making their presence felt, and by then It was too late. Luckily we were still verifying, but with our secondaries ruined, we had to restore from backup. A 30-minute outage became a 4-hour one. Afterwards, we put in a new policy that any crash means a DRBD verify at minimum, and until the node passes, it is to be considered invalid and unusable. If you haven't already, I suggest something similar for your setup. Verify a crashed node before using it again, no matter how much pressure you're under. It can always get worse. -- Shaun Thomas OptionsHouse | 141 W. Jackson Blvd | Suite 500 | Chicago IL, 60604 312-676-8870 stho...@optionshouse.com __ See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] tracking scripts...
On Tue, Nov 26, 2013 at 9:28 AM, Joey Quinn wrote: > I have a fairly large table (4.3 billion rows) that I am running an update > script on (a bit over 127 thousand individual update queries). I am using > the gui. It has been running for about 24 hours now. Is there any good way > to gauge progress (as in, how many of the individual update queries have > finished)? There are not many ways to Hand off information outside of the database while a transaction Is running. one way Is to write a Simple trigger in plpgsql that 'raise'es A notice every 'n' times trigger condition fires. that'S Essentially the only Clean way to do it in such a way that the information is Returned to the Executing console. Thanks! merlin -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] Any advantage of using SSL with a certificate of authority?
On 11/26/2013 12:16 PM, Robin wrote: 1. A self-signed certificate can be issued by anybody, there is no way of authenticating the issuer. 2. Distributing self-signed certificates becomes a pain - if signed by a CA, its easy to lodge your public key where everybody can find it, and knows where to look for it. 3. Maintenance becomes a problem while that's all true for public https or whatever, none of this applies to a point to point connection like libpq -> postmaster. -- john r pierce 37N 122W somewhere on the middle of the left coast
Re: [GENERAL] tracking scripts...
On 11/26/2013 12:30 PM, Merlin Moncure wrote: There are not many ways to Hand off information outside of the database while a transaction Is running. one way Is to write a Simple trigger in plpgsql that 'raise'es A notice every 'n' times trigger condition fires. that'S Essentially the only Clean way to do it in such a way that the information is Returned to the Executing console. Thanks! how would that trigger track N? -- john r pierce 37N 122W somewhere on the middle of the left coast -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] tracking scripts...
On Tue, Nov 26, 2013 at 2:38 PM, John R Pierce wrote: > On 11/26/2013 12:30 PM, Merlin Moncure wrote: >> >> There are not many ways to Hand off information outside of the >> database while a transaction Is running. one way Is to write a Simple >> trigger in plpgsql that 'raise'es A notice every 'n' times trigger >> condition fires. that'S Essentially the only Clean way to do it in >> such a way that the information is Returned to the Executing console. >> Thanks! > > > how would that trigger track N? A couple of different ways. Easiest would just be to manage a sequence. merlin -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] tracking scripts...
On 26/11/2013 20:30, Merlin Moncure wrote: > There are not many ways to Hand off information outside of the > database while a transaction Is running. one way Is to write a Simple > trigger in plpgsql that 'raise'es A notice every 'n' times trigger > condition fires. that'S Essentially the only Clean way to do it in > such a way that the information is Returned to the Executing console. > Thanks! Totally unrelated to the thread I noticed that the capitalised letters in the email above spell out this: THIISASECRET .. which (almost) spells "This is a secret". Was this intentional, or am I just working too hard? :-) Ray. -- Raymond O'Donnell :: Galway :: Ireland r...@iol.ie -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] tracking scripts...
On Tue, Nov 26, 2013 at 3:20 PM, Raymond O'Donnell wrote: > On 26/11/2013 20:30, Merlin Moncure wrote: >> There are not many ways to Hand off information outside of the >> database while a transaction Is running. one way Is to write a Simple >> trigger in plpgsql that 'raise'es A notice every 'n' times trigger >> condition fires. that'S Essentially the only Clean way to do it in >> such a way that the information is Returned to the Executing console. >> Thanks! > > Totally unrelated to the thread I noticed that the capitalised > letters in the email above spell out this: > > THIISASECRET > > .. which (almost) spells "This is a secret". Was this intentional, or am > I just working too hard? :-) Well, bad spelling on my part. To get the joke, you have to be A. observant, B. be using a gmail account, and C. be a comic book geek that grew up in the 80's. merlin -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
[GENERAL] help interpreting "explain analyze" output
I'm not really looking for information on how to speed this query up. I'm just trying to interpret the output enough to tell me which step is slow: Seq Scan on mags (cost=0.00..187700750.56 rows=47476 width=4) (actual time=3004851.889..3004851.889 rows=0 loops=1) Filter: ((signum IS NOT NULL) AND (NOT (SubPlan 1))) SubPlan 1 -> Materialize (cost=0.00..3713.93 rows=95862 width=4) (actual time=0.011..16.145 rows=48139 loops=94951) -> Seq Scan on sigs (cost=0.00..2906.62 rows=95862 width=4) (actual time=0.010..674.201 rows=95862 loops=1) Total runtime: 3004852.005 ms It looks like the inner seq scan takes 674ms, then the materialize takes an additional 16ms? Or is that 16ms * 94951? Or 674 * 94951? And the outer seq scan takes 3004851-3004851 = 0ms? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] Any advantage of using SSL with a certificate of authority?
On Tue, Nov 26, 2013 at 12:30:08PM -0800, John R Pierce wrote: > On 11/26/2013 12:16 PM, Robin wrote: > > 1. A self-signed certificate can be issued by anybody, there is no way of > authenticating the issuer. > 2. Distributing self-signed certificates becomes a pain - if signed by a > CA, its easy to lodge your public key where everybody can find it, and > knows where to look for it. > 3. Maintenance becomes a problem > > > > while that's all true for public https or whatever, none of this applies to a > point to point connection like libpq -> postmaster. Right. I know of no mechanism to verify a certificate via a public CA through SSL. Browsers have a list of trusted certificates, but SSL alone doesn't, as far as I know. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general