RedisManager.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. let RedisManager
  2. const Settings = require('@overleaf/settings')
  3. const rclient = require('@overleaf/redis-wrapper').createClient(
  4. Settings.redis.documentupdater
  5. )
  6. const logger = require('@overleaf/logger')
  7. const metrics = require('./Metrics')
  8. const Errors = require('./Errors')
  9. const crypto = require('crypto')
  10. const async = require('async')
  11. const ProjectHistoryRedisManager = require('./ProjectHistoryRedisManager')
  12. const { docIsTooLarge } = require('./Limits')
  13. // Sometimes Redis calls take an unexpectedly long time. We have to be
  14. // quick with Redis calls because we're holding a lock that expires
  15. // after 30 seconds. We can't let any errors in the rest of the stack
  16. // hold us up, and need to bail out quickly if there is a problem.
  17. const MAX_REDIS_REQUEST_LENGTH = 5000 // 5 seconds
  18. // Make times easy to read
  19. const minutes = 60 // seconds for Redis expire
  20. const logHashReadErrors = Settings.documentupdater?.logHashErrors?.read
  21. const MEGABYTES = 1024 * 1024
  22. const MAX_RANGES_SIZE = 3 * MEGABYTES
  23. const keys = Settings.redis.documentupdater.key_schema
  24. const historyKeys = Settings.redis.history.key_schema // note: this is track changes, not project-history
  25. module.exports = RedisManager = {
  26. rclient,
  27. putDocInMemory(
  28. projectId,
  29. docId,
  30. docLines,
  31. version,
  32. ranges,
  33. pathname,
  34. projectHistoryId,
  35. _callback
  36. ) {
  37. const timer = new metrics.Timer('redis.put-doc')
  38. const callback = error => {
  39. timer.done()
  40. _callback(error)
  41. }
  42. const docLinesArray = docLines
  43. docLines = JSON.stringify(docLines)
  44. if (docLines.indexOf('\u0000') !== -1) {
  45. const error = new Error('null bytes found in doc lines')
  46. // this check was added to catch memory corruption in JSON.stringify.
  47. // It sometimes returned null bytes at the end of the string.
  48. logger.error({ err: error, docId, docLines }, error.message)
  49. return callback(error)
  50. }
  51. // Do an optimised size check on the docLines using the serialised
  52. // length as an upper bound
  53. const sizeBound = docLines.length
  54. if (docIsTooLarge(sizeBound, docLinesArray, Settings.max_doc_length)) {
  55. const docSize = docLines.length
  56. const err = new Error('blocking doc insert into redis: doc is too large')
  57. logger.error({ projectId, docId, err, docSize }, err.message)
  58. return callback(err)
  59. }
  60. const docHash = RedisManager._computeHash(docLines)
  61. // record bytes sent to redis
  62. metrics.summary('redis.docLines', docLines.length, { status: 'set' })
  63. logger.debug(
  64. { projectId, docId, version, docHash, pathname, projectHistoryId },
  65. 'putting doc in redis'
  66. )
  67. RedisManager._serializeRanges(ranges, (error, ranges) => {
  68. if (error) {
  69. logger.error({ err: error, docId, projectId }, error.message)
  70. return callback(error)
  71. }
  72. // update docsInProject set before writing doc contents
  73. rclient.sadd(
  74. keys.docsInProject({ project_id: projectId }),
  75. docId,
  76. error => {
  77. if (error) return callback(error)
  78. if (!pathname) {
  79. metrics.inc('pathname', 1, {
  80. path: 'RedisManager.setDoc',
  81. status: pathname === '' ? 'zero-length' : 'undefined',
  82. })
  83. }
  84. rclient.mset(
  85. {
  86. [keys.docLines({ doc_id: docId })]: docLines,
  87. [keys.projectKey({ doc_id: docId })]: projectId,
  88. [keys.docVersion({ doc_id: docId })]: version,
  89. [keys.docHash({ doc_id: docId })]: docHash,
  90. [keys.ranges({ doc_id: docId })]: ranges,
  91. [keys.pathname({ doc_id: docId })]: pathname,
  92. [keys.projectHistoryId({ doc_id: docId })]: projectHistoryId,
  93. },
  94. callback
  95. )
  96. }
  97. )
  98. })
  99. },
  100. removeDocFromMemory(projectId, docId, _callback) {
  101. logger.debug({ projectId, docId }, 'removing doc from redis')
  102. const callback = err => {
  103. if (err) {
  104. logger.err({ projectId, docId, err }, 'error removing doc from redis')
  105. _callback(err)
  106. } else {
  107. logger.debug({ projectId, docId }, 'removed doc from redis')
  108. _callback()
  109. }
  110. }
  111. let multi = rclient.multi()
  112. multi.strlen(keys.docLines({ doc_id: docId }))
  113. multi.del(
  114. keys.docLines({ doc_id: docId }),
  115. keys.projectKey({ doc_id: docId }),
  116. keys.docVersion({ doc_id: docId }),
  117. keys.docHash({ doc_id: docId }),
  118. keys.ranges({ doc_id: docId }),
  119. keys.pathname({ doc_id: docId }),
  120. keys.projectHistoryId({ doc_id: docId }),
  121. keys.projectHistoryType({ doc_id: docId }),
  122. keys.unflushedTime({ doc_id: docId }),
  123. keys.lastUpdatedAt({ doc_id: docId }),
  124. keys.lastUpdatedBy({ doc_id: docId })
  125. )
  126. multi.exec((error, response) => {
  127. if (error) {
  128. return callback(error)
  129. }
  130. const length = response?.[0]
  131. if (length > 0) {
  132. // record bytes freed in redis
  133. metrics.summary('redis.docLines', length, { status: 'del' })
  134. }
  135. multi = rclient.multi()
  136. multi.srem(keys.docsInProject({ project_id: projectId }), docId)
  137. multi.del(keys.projectState({ project_id: projectId }))
  138. multi.exec(callback)
  139. })
  140. },
  141. checkOrSetProjectState(projectId, newState, callback) {
  142. const multi = rclient.multi()
  143. multi.getset(keys.projectState({ project_id: projectId }), newState)
  144. multi.expire(keys.projectState({ project_id: projectId }), 30 * minutes)
  145. multi.exec((error, response) => {
  146. if (error) {
  147. return callback(error)
  148. }
  149. logger.debug(
  150. { projectId, newState, oldState: response[0] },
  151. 'checking project state'
  152. )
  153. callback(null, response[0] !== newState)
  154. })
  155. },
  156. clearProjectState(projectId, callback) {
  157. rclient.del(keys.projectState({ project_id: projectId }), callback)
  158. },
  159. getDoc(projectId, docId, callback) {
  160. const timer = new metrics.Timer('redis.get-doc')
  161. const collectKeys = [
  162. keys.docLines({ doc_id: docId }),
  163. keys.docVersion({ doc_id: docId }),
  164. keys.docHash({ doc_id: docId }),
  165. keys.projectKey({ doc_id: docId }),
  166. keys.ranges({ doc_id: docId }),
  167. keys.pathname({ doc_id: docId }),
  168. keys.projectHistoryId({ doc_id: docId }),
  169. keys.unflushedTime({ doc_id: docId }),
  170. keys.lastUpdatedAt({ doc_id: docId }),
  171. keys.lastUpdatedBy({ doc_id: docId }),
  172. ]
  173. rclient.mget(...collectKeys, (error, result) => {
  174. if (error) {
  175. return callback(error)
  176. }
  177. let [
  178. docLines,
  179. version,
  180. storedHash,
  181. docProjectId,
  182. ranges,
  183. pathname,
  184. projectHistoryId,
  185. unflushedTime,
  186. lastUpdatedAt,
  187. lastUpdatedBy,
  188. ] = result
  189. const timeSpan = timer.done()
  190. // check if request took too long and bail out. only do this for
  191. // get, because it is the first call in each update, so if this
  192. // passes we'll assume others have a reasonable chance to succeed.
  193. if (timeSpan > MAX_REDIS_REQUEST_LENGTH) {
  194. error = new Error('redis getDoc exceeded timeout')
  195. return callback(error)
  196. }
  197. // record bytes loaded from redis
  198. if (docLines != null) {
  199. metrics.summary('redis.docLines', docLines.length, { status: 'get' })
  200. }
  201. // check sha1 hash value if present
  202. if (docLines != null && storedHash != null) {
  203. const computedHash = RedisManager._computeHash(docLines)
  204. if (logHashReadErrors && computedHash !== storedHash) {
  205. logger.error(
  206. {
  207. projectId,
  208. docId,
  209. docProjectId,
  210. computedHash,
  211. storedHash,
  212. docLines,
  213. },
  214. 'hash mismatch on retrieved document'
  215. )
  216. }
  217. }
  218. try {
  219. docLines = JSON.parse(docLines)
  220. ranges = RedisManager._deserializeRanges(ranges)
  221. } catch (e) {
  222. return callback(e)
  223. }
  224. version = parseInt(version || 0, 10)
  225. // check doc is in requested project
  226. if (docProjectId != null && docProjectId !== projectId) {
  227. logger.error({ projectId, docId, docProjectId }, 'doc not in project')
  228. return callback(new Errors.NotFoundError('document not found'))
  229. }
  230. if (docLines && version && !pathname) {
  231. metrics.inc('pathname', 1, {
  232. path: 'RedisManager.getDoc',
  233. status: pathname === '' ? 'zero-length' : 'undefined',
  234. })
  235. }
  236. callback(
  237. null,
  238. docLines,
  239. version,
  240. ranges,
  241. pathname,
  242. projectHistoryId,
  243. unflushedTime,
  244. lastUpdatedAt,
  245. lastUpdatedBy
  246. )
  247. })
  248. },
  249. getDocVersion(docId, callback) {
  250. rclient.mget(
  251. keys.docVersion({ doc_id: docId }),
  252. keys.projectHistoryType({ doc_id: docId }),
  253. (error, result) => {
  254. if (error) {
  255. return callback(error)
  256. }
  257. let [version, projectHistoryType] = result || []
  258. version = parseInt(version, 10)
  259. callback(null, version, projectHistoryType)
  260. }
  261. )
  262. },
  263. getDocLines(docId, callback) {
  264. rclient.get(keys.docLines({ doc_id: docId }), (error, docLines) => {
  265. if (error) {
  266. return callback(error)
  267. }
  268. callback(null, docLines)
  269. })
  270. },
  271. getPreviousDocOps(docId, start, end, callback) {
  272. const timer = new metrics.Timer('redis.get-prev-docops')
  273. rclient.llen(keys.docOps({ doc_id: docId }), (error, length) => {
  274. if (error) {
  275. return callback(error)
  276. }
  277. rclient.get(keys.docVersion({ doc_id: docId }), (error, version) => {
  278. if (error) {
  279. return callback(error)
  280. }
  281. version = parseInt(version, 10)
  282. const firstVersionInRedis = version - length
  283. if (start < firstVersionInRedis || end > version) {
  284. error = new Errors.OpRangeNotAvailableError(
  285. 'doc ops range is not loaded in redis'
  286. )
  287. logger.debug(
  288. { err: error, docId, length, version, start, end },
  289. 'doc ops range is not loaded in redis'
  290. )
  291. return callback(error)
  292. }
  293. start = start - firstVersionInRedis
  294. if (end > -1) {
  295. end = end - firstVersionInRedis
  296. }
  297. if (isNaN(start) || isNaN(end)) {
  298. error = new Error('inconsistent version or lengths')
  299. logger.error(
  300. { err: error, docId, length, version, start, end },
  301. 'inconsistent version or length'
  302. )
  303. return callback(error)
  304. }
  305. rclient.lrange(
  306. keys.docOps({ doc_id: docId }),
  307. start,
  308. end,
  309. (error, jsonOps) => {
  310. let ops
  311. if (error) {
  312. return callback(error)
  313. }
  314. try {
  315. ops = jsonOps.map(jsonOp => JSON.parse(jsonOp))
  316. } catch (e) {
  317. return callback(e)
  318. }
  319. const timeSpan = timer.done()
  320. if (timeSpan > MAX_REDIS_REQUEST_LENGTH) {
  321. error = new Error('redis getPreviousDocOps exceeded timeout')
  322. return callback(error)
  323. }
  324. callback(null, ops)
  325. }
  326. )
  327. })
  328. })
  329. },
  330. getHistoryType(docId, callback) {
  331. rclient.get(
  332. keys.projectHistoryType({ doc_id: docId }),
  333. (error, projectHistoryType) => {
  334. if (error) {
  335. return callback(error)
  336. }
  337. callback(null, projectHistoryType)
  338. }
  339. )
  340. },
  341. setHistoryType(docId, projectHistoryType, callback) {
  342. rclient.set(
  343. keys.projectHistoryType({ doc_id: docId }),
  344. projectHistoryType,
  345. callback
  346. )
  347. },
  348. DOC_OPS_TTL: 60 * minutes,
  349. DOC_OPS_MAX_LENGTH: 100,
  350. updateDocument(
  351. projectId,
  352. docId,
  353. docLines,
  354. newVersion,
  355. appliedOps,
  356. ranges,
  357. updateMeta,
  358. callback
  359. ) {
  360. if (appliedOps == null) {
  361. appliedOps = []
  362. }
  363. RedisManager.getDocVersion(
  364. docId,
  365. (error, currentVersion, projectHistoryType) => {
  366. if (error) {
  367. return callback(error)
  368. }
  369. if (currentVersion + appliedOps.length !== newVersion) {
  370. error = new Error(`Version mismatch. '${docId}' is corrupted.`)
  371. logger.error(
  372. {
  373. err: error,
  374. docId,
  375. currentVersion,
  376. newVersion,
  377. opsLength: appliedOps.length,
  378. },
  379. 'version mismatch'
  380. )
  381. return callback(error)
  382. }
  383. const jsonOps = appliedOps.map(op => JSON.stringify(op))
  384. for (const op of jsonOps) {
  385. if (op.indexOf('\u0000') !== -1) {
  386. error = new Error('null bytes found in jsonOps')
  387. // this check was added to catch memory corruption in JSON.stringify
  388. logger.error({ err: error, docId, jsonOps }, error.message)
  389. return callback(error)
  390. }
  391. }
  392. const newDocLines = JSON.stringify(docLines)
  393. if (newDocLines.indexOf('\u0000') !== -1) {
  394. error = new Error('null bytes found in doc lines')
  395. // this check was added to catch memory corruption in JSON.stringify
  396. logger.error({ err: error, docId, newDocLines }, error.message)
  397. return callback(error)
  398. }
  399. // Do an optimised size check on the docLines using the serialised
  400. // length as an upper bound
  401. const sizeBound = newDocLines.length
  402. if (docIsTooLarge(sizeBound, docLines, Settings.max_doc_length)) {
  403. const err = new Error('blocking doc update: doc is too large')
  404. const docSize = newDocLines.length
  405. logger.error({ projectId, docId, err, docSize }, err.message)
  406. return callback(err)
  407. }
  408. const newHash = RedisManager._computeHash(newDocLines)
  409. const opVersions = appliedOps.map(op => op?.v)
  410. logger.debug(
  411. {
  412. docId,
  413. version: newVersion,
  414. hash: newHash,
  415. op_versions: opVersions,
  416. },
  417. 'updating doc in redis'
  418. )
  419. // record bytes sent to redis in update
  420. metrics.summary('redis.docLines', newDocLines.length, {
  421. status: 'update',
  422. })
  423. RedisManager._serializeRanges(ranges, (error, ranges) => {
  424. if (error) {
  425. logger.error({ err: error, docId }, error.message)
  426. return callback(error)
  427. }
  428. if (ranges && ranges.indexOf('\u0000') !== -1) {
  429. error = new Error('null bytes found in ranges')
  430. // this check was added to catch memory corruption in JSON.stringify
  431. logger.error({ err: error, docId, ranges }, error.message)
  432. return callback(error)
  433. }
  434. const multi = rclient.multi()
  435. multi.mset({
  436. [keys.docLines({ doc_id: docId })]: newDocLines,
  437. [keys.docVersion({ doc_id: docId })]: newVersion,
  438. [keys.docHash({ doc_id: docId })]: newHash,
  439. [keys.ranges({ doc_id: docId })]: ranges,
  440. [keys.lastUpdatedAt({ doc_id: docId })]: Date.now(),
  441. [keys.lastUpdatedBy({ doc_id: docId })]:
  442. updateMeta && updateMeta.user_id,
  443. })
  444. multi.ltrim(
  445. keys.docOps({ doc_id: docId }),
  446. -RedisManager.DOC_OPS_MAX_LENGTH,
  447. -1
  448. ) // index 3
  449. // push the ops last so we can get the lengths at fixed index position 7
  450. if (jsonOps.length > 0) {
  451. multi.rpush(keys.docOps({ doc_id: docId }), ...jsonOps) // index 5
  452. // expire must come after rpush since before it will be a no-op if the list is empty
  453. multi.expire(
  454. keys.docOps({ doc_id: docId }),
  455. RedisManager.DOC_OPS_TTL
  456. ) // index 6
  457. if (
  458. Settings.disableTrackChanges ||
  459. projectHistoryType === 'project-history'
  460. ) {
  461. metrics.inc('history-queue', 1, { status: 'skip-track-changes' })
  462. logger.debug(
  463. { docId },
  464. 'skipping push of uncompressed ops for project using project-history'
  465. )
  466. } else {
  467. // project is using old track-changes history service
  468. metrics.inc('history-queue', 1, { status: 'track-changes' })
  469. multi.rpush(
  470. historyKeys.uncompressedHistoryOps({ doc_id: docId }),
  471. ...jsonOps
  472. ) // index 7
  473. }
  474. // Set the unflushed timestamp to the current time if the doc
  475. // hasn't been modified before (the content in mongo has been
  476. // valid up to this point). Otherwise leave it alone ("NX" flag).
  477. multi.set(keys.unflushedTime({ doc_id: docId }), Date.now(), 'NX')
  478. }
  479. multi.exec((error, result) => {
  480. if (error) {
  481. return callback(error)
  482. }
  483. let docUpdateCount
  484. if (
  485. Settings.disableTrackChanges ||
  486. projectHistoryType === 'project-history'
  487. ) {
  488. docUpdateCount = undefined // only using project history, don't bother with track-changes
  489. } else {
  490. // project is using old track-changes history service
  491. docUpdateCount = result[4]
  492. }
  493. if (jsonOps.length > 0 && Settings.apis?.project_history?.enabled) {
  494. metrics.inc('history-queue', 1, { status: 'project-history' })
  495. ProjectHistoryRedisManager.queueOps(
  496. projectId,
  497. ...jsonOps,
  498. (error, projectUpdateCount) => {
  499. if (error) {
  500. // The full project history can re-sync a project in case
  501. // updates went missing.
  502. // Just record the error here and acknowledge the write-op.
  503. metrics.inc('history-queue-error')
  504. }
  505. callback(null, docUpdateCount, projectUpdateCount)
  506. }
  507. )
  508. } else {
  509. callback(null, docUpdateCount)
  510. }
  511. })
  512. })
  513. }
  514. )
  515. },
  516. renameDoc(projectId, docId, userId, update, projectHistoryId, callback) {
  517. RedisManager.getDoc(projectId, docId, (error, lines, version) => {
  518. if (error) {
  519. return callback(error)
  520. }
  521. if (lines != null && version != null) {
  522. if (!update.newPathname) {
  523. logger.warn(
  524. { projectId, docId, update },
  525. 'missing pathname in RedisManager.renameDoc'
  526. )
  527. metrics.inc('pathname', 1, {
  528. path: 'RedisManager.renameDoc',
  529. status: update.newPathname === '' ? 'zero-length' : 'undefined',
  530. })
  531. }
  532. rclient.set(
  533. keys.pathname({ doc_id: docId }),
  534. update.newPathname,
  535. callback
  536. )
  537. } else {
  538. callback()
  539. }
  540. })
  541. },
  542. clearUnflushedTime(docId, callback) {
  543. rclient.del(keys.unflushedTime({ doc_id: docId }), callback)
  544. },
  545. getDocIdsInProject(projectId, callback) {
  546. rclient.smembers(keys.docsInProject({ project_id: projectId }), callback)
  547. },
  548. /**
  549. * Get lastupdatedat timestamps for an array of docIds
  550. */
  551. getDocTimestamps(docIds, callback) {
  552. async.mapSeries(
  553. docIds,
  554. (docId, cb) => rclient.get(keys.lastUpdatedAt({ doc_id: docId }), cb),
  555. callback
  556. )
  557. },
  558. /**
  559. * Store the project id in a sorted set ordered by time with a random offset
  560. * to smooth out spikes
  561. */
  562. queueFlushAndDeleteProject(projectId, callback) {
  563. const SMOOTHING_OFFSET =
  564. Settings.smoothingOffset > 0
  565. ? Math.round(Settings.smoothingOffset * Math.random())
  566. : 0
  567. rclient.zadd(
  568. keys.flushAndDeleteQueue(),
  569. Date.now() + SMOOTHING_OFFSET,
  570. projectId,
  571. callback
  572. )
  573. },
  574. /**
  575. * Find the oldest queued flush that is before the cutoff time
  576. */
  577. getNextProjectToFlushAndDelete(cutoffTime, callback) {
  578. rclient.zrangebyscore(
  579. keys.flushAndDeleteQueue(),
  580. 0,
  581. cutoffTime,
  582. 'WITHSCORES',
  583. 'LIMIT',
  584. 0,
  585. 1,
  586. (err, reply) => {
  587. if (err) {
  588. return callback(err)
  589. }
  590. // return if no projects ready to be processed
  591. if (!reply || reply.length === 0) {
  592. return callback()
  593. }
  594. // pop the oldest entry (get and remove in a multi)
  595. const multi = rclient.multi()
  596. // Poor man's version of ZPOPMIN, which is only available in Redis 5.
  597. multi.zrange(keys.flushAndDeleteQueue(), 0, 0, 'WITHSCORES')
  598. multi.zremrangebyrank(keys.flushAndDeleteQueue(), 0, 0)
  599. multi.zcard(keys.flushAndDeleteQueue()) // the total length of the queue (for metrics)
  600. multi.exec((err, reply) => {
  601. if (err) {
  602. return callback(err)
  603. }
  604. if (!reply || reply.length === 0) {
  605. return callback()
  606. }
  607. const [key, timestamp] = reply[0]
  608. const queueLength = reply[2]
  609. callback(null, key, timestamp, queueLength)
  610. })
  611. }
  612. )
  613. },
  614. _serializeRanges(ranges, callback) {
  615. let jsonRanges = JSON.stringify(ranges)
  616. if (jsonRanges && jsonRanges.length > MAX_RANGES_SIZE) {
  617. return callback(new Error('ranges are too large'))
  618. }
  619. if (jsonRanges === '{}') {
  620. // Most doc will have empty ranges so don't fill redis with lots of '{}' keys
  621. jsonRanges = null
  622. }
  623. callback(null, jsonRanges)
  624. },
  625. _deserializeRanges(ranges) {
  626. if (ranges == null || ranges === '') {
  627. return {}
  628. } else {
  629. return JSON.parse(ranges)
  630. }
  631. },
  632. _computeHash(docLines) {
  633. // use sha1 checksum of doclines to detect data corruption.
  634. //
  635. // note: must specify 'utf8' encoding explicitly, as the default is
  636. // binary in node < v5
  637. return crypto.createHash('sha1').update(docLines, 'utf8').digest('hex')
  638. },
  639. }