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

pgwire: Flush message is not supported during execution of a portal #83613

Closed
markddrake opened this issue Jun 29, 2022 · 6 comments · Fixed by #83675
Closed

pgwire: Flush message is not supported during execution of a portal #83613

markddrake opened this issue Jun 29, 2022 · 6 comments · Fixed by #83675
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner

Comments

@markddrake
Copy link

markddrake commented Jun 29, 2022

Attempting to use PG Query stream to stream a large dataset results in error: unimplemented: multiple active portals not supported, even though a single table is being accessed,

Running the following code against Postgres 14 works as expected

import pg                             from 'pg';
const {Client,Pool} = pg;
import QueryStream                    from 'pg-query-stream'
import {
  Transform
}                                     from 'stream';

import {
  pipeline
}                                     from 'stream/promises';

const props = {
          user: 'postgres',
          host: 'yadamu-db2',
          database: 'yadamu',
          password: 'oracle',
          port: 5432
}

class t extends Transform {

  constructor() {
    super({objectMode: true });  
  }
  
  async doTransform(data) {
    return JSON.stringify(data)
  }

  _transform(data,enc,callback) {
    this.doTransform(data).then((row) => { this.push(row);callback()}).catch((e) => { callback(e)})
  }

}

async function main() {
              process.on('unhandledRejection', (err, p) => {
                            console.log(err);
                            process.exit()
                          })

                      const pgClient = new Client(props);
                      console.log('connecting')
                      await pgClient.connect();
                      console.log('connected')
                      const queryStream = new QueryStream(`select * from INFORMATION_SCHEMA.COLUMNS`,[],{rowMode : "array"})
                      const inputStream = await pgClient.query(queryStream)   					  
					  await pipeline(inputStream,new t,process.stdout,{end:false})
					  await pgClient.end();
                      console.log('disconnected')

}

main().then(() => {console.log('DONE')}).catch((e) => {console.log(e)});

However when run against Cockroack it fails with

C:\Development\YADAMU>node src\scratch\postgres\pgTestStream.js
connecting
connected
error: unimplemented: multiple active portals not supported
    at Parser.parseErrorMessage (C:\Development\YADAMU\src\node_modules\pg-protocol\dist\parser.js:287:98)
    at Parser.handlePacket (C:\Development\YADAMU\src\node_modules\pg-protocol\dist\parser.js:126:29)
    at Parser.parse (C:\Development\YADAMU\src\node_modules\pg-protocol\dist\parser.js:39:38)
    at Socket.<anonymous> (C:\Development\YADAMU\src\node_modules\pg-protocol\dist\index.js:11:42)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 285,
  severity: 'ERROR',
  code: '0A000',
  detail: 'cannot perform operation sql.Flush while a different portal is open',
  hint: 'You have attempted to use a feature that is not yet implemented.\n' +
    'See: https://go.crdb.dev/issue-v/40195/v22.1',
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'distsql_running.go',
  line: '1181',
  routine: 'init'
}

Since the code only peforms a single query against a single table I would have expected it to work.

Per Rafi's comments here #40195 (comment)

it looks like this can be fixed prior to a full solution for the "multiple active portals" issue referenced here

#40195

This was reproduced using the Cockroach docker image


Note from @rafiss : Since Flush doesn't really do anything, we should just be able to ignore it rather than returning an error.


Jira issue: CRDB-17174
Epic CRDB-2466

@markddrake markddrake added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Jun 29, 2022
@blathers-crl
Copy link

blathers-crl bot commented Jun 29, 2022

Hello, I am Blathers. I am here to help you get the issue triaged.

It looks like you have not filled out the issue in the format of any of our templates. To best assist you, we advise you to use one of these templates.

I have CC'd a few people who may be able to assist you:

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels Jun 29, 2022
@blathers-crl blathers-crl bot added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Jun 29, 2022
@markddrake
Copy link
Author

Cloned from brianc/node-postgres#2767

@rafiss rafiss changed the title Unexpected "unimplemented: multiple active portals not supported" when streaming a large dataset using Node PG QueryStream pgwire: Flush message is not supported during execution of a portal Jun 29, 2022
@craig craig bot closed this as completed in a0b1222 Jul 7, 2022
@markddrake
Copy link
Author

Any idea when the official docker image will contain this fix

@rafiss
Copy link
Collaborator

rafiss commented Jul 7, 2022

The current schedule is that v22.1.4 and v21.2.14 will be released at the beginning of August. The timelines are subject to change, but those are the two release tags to watch out for.

@markddrake
Copy link
Author

Thank you

@markddrake
Copy link
Author

markddrake commented Jul 30, 2022

Picked up the docker image containing CockroachDB CCL v22.1.5 (x86_64-pc-linux-gnu, built 2022/07/28 14:58:04, go1.17.11) and can confirm issue is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants